Skip to content

vklsaravanan/nptel-programmingInJava

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nptel

Programming In Java

Exercise1_1 - Complete the code segment to find the perimeter and area of a circle given a value of radius.
Exercise1_2 - Complete the code segment to find the largest among three numbers x,y, and z. You should use if-then-else construct in Java.
Exercise1_3 - Consider First n even numbers starting from zero(0).Complete the code segment to calculate sum of all the numbers divisible by 3 from 0 to n. Print the sum.
Exercise1_4 - Complete the code segment to check whether the number is an Armstrong number or not.
Exercise1_5 - Complete the code segment to help Ragav , find the highest mark and average mark secured by him in "s" number of subjects.

Exercise2_1 - Complete the code segment to call the method print() of class Student first and then call print() method of class School.
Exercise2_2 - Complete the code segment to call the method print() of class given class Printer to print the following.
Exercise2_3 - Complete the code segment to call print() method of class Question by creating a method named ‘studentMethod()’.
Exercise2_4 - Complete the code segment to call default constructor first and then any other constructor in the class.
Exercise2_5 - Complete the code segment to debug / complete the program which is intended to print 'NPTEL JAVA'.

Excercise3_1 - This program is related to the generation of Fibonacci numbers.>For example: 0,1, 1,2, 3,5, 8, 13,… is a Fibonacci sequence where 13 is the 8th Fibonacci number.
Exercise3_2 - Define a class Point with two fields x and y each of type double. Also, define a method distance(Point p1, Point p2) to calculate the distance between points p1 and p2 and return the value in double.
Exercise3_3 - A class Shape is defined with two overloading constructors in it. Another class Test1 is partially defined which inherits the class Shape. The ...,
Exercise3_4 - This program to exercise the call of static and non-static methods. A partial code is given defining two methods, namely sum( ) and multiply ( ). You......,
Exercise3_5 - Complete the code segment to swap two numbers using call by object reference.

Exercise4_1 - Complete the code segment to execute the following program successfully. You should import the correct package(s) and/or class(s) to complete the code.
Exercise4_2 - Complete the code segment to print the current year. Your code should compile successfully.
Exercise4_3 - The program in this assignment is attempted to print the following output:
Exercise4_4 - Complete the code segment to call the default method in the interface First and Second.
Exercise4_5 - Modify the code segment to print the following output.

Exercise5_1 - An interface Number is defined in the following program. You have to declare a class A,which will implement the interface Number. Note that the method findSqr(n) will return the square of the number n.
Exercise5_2 - An interface Number is defined in the following program. You have to declare a class A,which will implement the interface Number. Note that the method findSqr(n) will return the square of the number n.
Exercise5_3 - Complete the code segment to catch the ArithmeticException in the following, if any. On the occurrence of such an exception, your program should print “Exception caught: Division by zero.” If there is no such exception, it will print the result of division operation on two integer values.
Exercise5_4 - In the following program, an array of integer data to be initialized. During the initialization, if a user enters a value other than integer value, then it will throw InputMismatchException..,
Exercise5_5 - In the following program, there may be multiple exceptions. You have to complete the code using only one try-catch block to handle all the possible exceptions.

Exercise6_1 - Complete the code segment to print the following using the concept of extending the Thread class in Java:
Exercise6_2 - In the following program, a thread class Question62 is created using the Runnable interface Complete the main() to create a thread object of the class Question62 and run the thread. It should print the output as given below.
Exercise6_3 - Given a snippet of code, add necessary codes to print the following:
-----------------OUTPUT-------------------
Name of thread 't1':Thread-0
Name of thread 't2':Thread-1
New name of thread 't1':Week 6 Assignment Q5
New name of thread 't2':Week 6 Assignment Q5 New
-------------------------------------------------
Exercise6_4 - Execution of two or more threads occurs in a random order. The keyword 'synchronized' in Java is used to control the execution of thread ..,
Exercise6_5 - In the following program, a thread class Question62 is created using the Runnable interface Complete the main() to create a thread object of the class Question62 and run the thread. It should print the output as given below.

Exercise7_1 - Complete the following code fragment to read three integer values from the keyboard and find the sum of the values. Declare a variable "sum" of type int and store the result in it.
Exercise7_2 - Complete the code segment to catch the exception in the following, if any. On the occurrence of such an exception, your program should print “Please enter valid data” .If there is no such exception, it will print the "square of the number".
Exercise7_3 - A byte char array is initialized. You have to enter an index value"n". According to index your program will print the byte and its corresponding char value. Complete the code segment to catch the exception in the..,
Exercise7_4 - The following program reads a string from the keyboard and is stored in the String variable "s1"..,
Exercise7_5 -A string "s1" is already initialized. You have to read the index "n" from..,

Exercise8_1 - Write a program which will print a pyramid of "" 's of height "n" and print the number of "" 's in the pyramid.
Exercise8_2 - Write a program which will print a pascal pyramid of "" 's of height "l" .
Exercise8_3 - Write a program which will print a pyramid of "numbers" 's of height "n" and print the sum of all number's in the pyramid.
Exercise8_4 - Write a program to print symmetric Pascal's triangle of "
" 's of height "l" of odd length . If input "l" is even then your program will print "Invalid line number".
Exercise8_5 - Write a program to display any digit(n) from 0-9 represented as a "7 segment display".

Exercise9_1 - Complete the code to develop a BASIC CALCULATOR that can perform operations like Addition, Subtraction, Multiplication and Division.
Exercise9_2 - Complete the code to develop an ADVANCED CALCULATOR that emulates all the functions of the GUI Calculator as shown in the image.
Exercise9_3 - Complete the code to perform a 45 degree anti clock wise rotation with respect to the center of a 5 × 5 2D Array as shown below:
Exercise9_4 - A program needs to be developed which can mirror reflect any 5 × 5 2D character array into its side-by-side reflection. Write suitable code to achieve this transformation as shown below:
Exercise9_5 - Write suitable code to develop a 2D Flip-Flop Array with dimension 5 × 5, which replaces all input elements with values 0 by 1 and 1 by 0. An example is shown below:

Exercise10_1 - The following code needs some package to work properly. Write appropriate code to import the required package(s) in order to make the program compile and execute successfully.
Exercise10_2 - Write the JDBC codes needed to create a Connection interface using the DriverManager class and the variable DB_URL. Check whether the connection is successful using 'isAlive(timeout)
Exercise10_3 - Due to some mistakes in the below code, the code is not compiled/executable. Modify and debug the JDBC code to make it execute successfully.
Exercise10_4 - Complete the code segment to rename an already created table named ‘PLAYERS’ into ‘SPORTS’.
Exercise10_5 - Complete the code segment to rename an already created table named ‘PLAYERS’ into ‘SPORTS’.

Download all files as zip

Author @vklsaravanan

Connect with me: