NPTEL Programming in Java Week 6 Assignment Answers 2024

Sanket
By Sanket

NPTEL Programming in Java Week 6 Assignment Answers 2024

1. What is the output of the following program?

image 184

a. “Hello World”
b. “Cannot divide by 0”
c. Compilation Error
d. Runtime Error (the code compiles successfully)

Answer :- For Answers Click Here 

2. What will be the output of the following program?

image 185

a. 20
b. 21
c. 19
d. 22

Answer :- For Answers Click Here 

3. What is the output of the following program?

image 186

a. 1
b. 2
c. 0
d. Compilation Error

Answer :- For Answers Click Here 

4. Which exception is thrown when an array element is accessed beyond the array size?

a. ArrayElementOutOfBounds
b. ArrayIndexOutOfBoundsException
c. ArrayIndexOutOfBounds
d. None of these

Answer :- 

5. What is the output of the following program?

image 187

a. java
b. java
course
c. nptel
course
d. Compilation Error

Answer :- 

6. Fill in the blank in the program so that the output is “Java”.

image 188

a. public void
b. void
c. private void
d. static void

Answer :- For Answers Click Here 

7. How many times will “Java” be printed if the following code is executed?

image 189

a. 0
b. 1
c. 2
d. 3

Answer :- 

8. The following is a simple program using the concept of thread. What is the output of the following program?

image 190

a. 1 3 5 7
b. 2 4 6 8
c. 1 3 5 7 9
d. 2 4 6

Answer :- 

9. For the program given below, what will be the output after its execution?

image 191

a. 1
b. 2
c. 0
d. 01

Answer :- 

10. Which of the following method returns a reference to the currently executing thread object?

a. public static boolean interrupted();
b. public static Thread currentThread();
c. public final boolean isAlive();
d. public final void suspend();

Answer :- For Answers Click Here 
Share This Article
Leave a comment