CodingJavaMoreSemester ExamsSemester Exams

20 Most asked questions in viva or interview from Multi-thread Programming and Exception Handling

famous interview and viva questions

Here are the questions first try to answer it yourself then check it from the answer (given below)

1. When does Exception in java arises in code sequence?

A) Runtime

B) Compilation Time

C)Can Occur Any time

D) None of the mentioned

2. Which of these keywords is not a part of exception handling?

A) try

B) finally

C) thrown

D) catch

3. Which of these keywords must be used to monitor for exceptions?

A) try

B) finally

C) throw

D) catch

4. Which of these keywords must be used to handle the exception thrown by try block in some rational manner?

A) try

B) finally

C) throw

D) catch

5. Which of these keywords is used to manually throw an ex exception?

A) try

B) finally

C) throw

D) catch

6. What is the output of the given program?

class expectation_handling{

public static void main(String args[]){

try{

System.out.print(“Hello”+” “+1/0);

}

catch(ArithmeticException e) {

Syatem.out.print(“World”);

}

}
}

A) Hello

B) World

C) HelloWorld

D) Hello World

7. What is the output of this program?

class exception_handling {

public static void main(String args[]) {

try {

int a, b:

b=0;

a=5/b;

System.out.ptrint(“A”);

}

catch (ArithmaticException e) {

System.out.print(“B”);

}

}

}

A) A

B) B

C) Compilation Error

D) Runtime Error

8, What is the output of the given program?

class exception_handling {

public static void main(String args []) {

try {

int i, sum;

sum= 10;

for (i = -1; i<3; ++i) {

sum = (sum/i);

System.out.print(“0”);

}

}

}

A) -1

B) 0

C) -10

D) -101

9. What is multithreaded programming?

A) It’s processed in which two different processes run simultaneously

B) It’s a process in which two or more parts of the same processes run simultaneously

C) It’s a process in which many different processes are able to access the same information

D) It’s a process in which a single process can access information from many sources

10. Which of these are types of multitasking?

A) process based

B) Thread-based

C) Process and Thread based

D) None of the mentions

11. Which of these packages contain all the Java’s built-in exceptions?

A) java.io

B) java.util

C) java.lang

D) java.net

12. Thread priority in Java is?

A) Integer

B) float

C) double

D) long

13. What will happen if two of the same priority are called to be prtocessed simultaneously?

A) Anyone will be executed first lexographically

B) Both of them will be executed simultaneously

C) None of them will be executed

D) It is dependent on the operating system

14. Which of these statements is incorrect?

A) BY multithreading CPU’s idle time is minimized, and we can take maximul use of it

B) By multitasking CPU’s idle time is minimized, and we can take maximum use of it

C) Two thread in java can have same priority

D) A thread can exist only in two states, running and blocked

15. What is the output of the given program?

class multithreaded_programming {

public static void main(String args []) {

Thread t = Thread.currentThread();

System.out.println(t);

}

}

A) Thread[5,main]

B) Thread[main,5]

C) Thread[main,0]

D) Thread[main,5,main]

16. What is the priority of the thread in the output of this program?

class multithreaded_programing {

public static void main(String args[]) {

Thread t = Thread.currentThread();

System.out.println(t);

}

}

A) 4

B) 5

C) 0

D) 1

17. What is the name of the thread in output of this program?

class multithreaded_programming {

public static void main (String args []) {

Thread t = Thread.CurrentThread();

System.out.println(t);

}

}

A) main

B) Thread

C) System

D) None of the mention

18. What is the name of the thread in output of this program?

class multithreaded_programming {

public static void main (String args []) [

thread t = Thread.currentThread();

System.out.println(t.isAlive());

}

}

A) 0

B) 1

C) true

D) false

19. Which of the following are examples of runtime exception?

A) NullPointException

B) ClassCastException

C) FileNotFoundException

D) Arithmetic exception

20. If a parent class throws an exception say “A”, the child has to throw that exception “A” or it’s sub type.

A) true

B) false

Answers:

  1.  A
  2. C
  3. A
  4. D
  5. C
  6. B
  7. B
  8. C
  9. B
  10. C
  11. C
  12. A
  13. D
  14. D
  15. D
  16. B
  17. A
  18. A
  19. A & B
  20. A

 

 

Tags

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Close