Java Week 1:Q1 To find the perimeter and area of a circle given a value of radius.
Java Week 1:Q2 To find the largest among three numbers x, y, and z.
Java Week 1:Q3 Consider First n even numbers starting from zero(0) and calculate sum of all the numbers divisible by 3 from 0 to n. Print the sum.
Java Week 1:Q4 To check whether the number is an Armstrong number or not.
Java Week 1:Q5 To help Ram , find the highest mark and average mark secured by him in "s" number of subjects.
Java Week 2:Q1 To call the method print() in class Student following the concept of inner class.
Java Week 2:Q2 To call the method print() of class Student first and then call print() method of class School.
Java Week 2:Q3 To call print() method of class Question by creating a method named ‘studentMethod()’.
Java Week 2:Q4 To call default constructor first and then any other constructor in the class Answer.
Java Week 2:Q5 To debug the program which is intended to print 'NPTEL JAVA'.
Java Week 3:Q1 To the generation of Fibonacci numbers.
Java Week 3:Q2 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. Complete the code segment given below. Use Math.sqrt( ) to calculate the square root.
Java Week 3:Q3 A class Shape is defined with two overloading constructors in it. Another class Test1 is partially defined which inherits the class Shape. The class Test1 should include two overloading constructors as appropriate for some object instantiation shown in main( ) method. You should define the constructors using the super class constructors. Also, override the method calculate( ) in Test1 to calculate the volume of a Shape.
Java Week 3:Q4 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 have to call these methods to find the sum and product of two numbers.
Java Week 3:Q5 To swap two numbers using call by object reference.
Java Week 4:Q1 To execute the following program successfully. You should import the correct package(s) and/or class(s) to complete the code.
Java Week 4:Q2 To print the current year.
Java Week 4:Q3 The program in this assignment is attempted to print the following output:
-----------------OUTPUT-------------------
This is large
This is medium
This is small
This is extra-large
-----------------OUTPUT-------------------
Java Week 4:Q4 To call the default method in the interface First and Second.
Java Week 4:Q5 To print the following output.
-----------------OUTPUT-------------------
Circle: This is Shape1
Circle: This is Shape2
-----------------OUTPUT--------------------
Java Week 5:Q1 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.
Java Week 5:Q2 This program is to find the GCD (greatest common divisor) of two integers writing a recursive function findGCD(n1,n2). Your function should return -1, if the argument(s) is(are) other than positive number(s).
Java Week 5:Q3 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.
Java Week 5:Q4 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 exception. On the occurrence of such an exception, your program should print “You entered bad data.” If there is no such exception it will print the total sum of the array.
Java Week 5:Q5 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.
For example, if user’s input is 1, then it will throw and catch “java.lang.NullPointerException“.
Java Week 6:Q1 Complete the code segment to print the following using the concept of extending the Thread class in Java:
-----------------OUTPUT-------------------
Thread is Running.
Java Week 6:Q2 In the following program, a thread class ThreadRun is created using the Runnable interface which prints "Thread using Runnable interface". Complete the main class to create a thread object of the class ThreadRun and run the thread,
Java Week 6:Q3 A part of the Java program is given, which can be completed in many ways, for example using the concept of thread, etc. Follow the given code and complete the program so that your program prints the message "NPTEL Java". Your program should utilize the given interface/ class.
Java Week 6:Q4 Execution of two or more threads occurs in a random order. The keyword 'synchronized' in Java is used to control the execution of thread in a strict sequence. In the following, the program is expected to print some numbers. Do the necessary use of 'synchronized' keyword, so that, the program prints the output in the following order:
-----------------OUTPUT-------------------
5
10
15
20
25
100
200
300
400
500
Java Week 6:Q5 Add necessary codes to print the following:
-----------------OUTPUT-------------------
Name of thread 't':Thread-0
New name of thread 't':NPTEL
Thread is running.