🌙 DARK

JAVA MCQ (Multiple Choice Questions)

 

JAVA MCQ TEST : 2

@MrProgrammer89 - Follow

 

Q1)  Which programming language doesn't support multiple inheritance?

A. C++ and Java

B. C and C++

C. Java and SmallTalk

D. Java 

ANS :-  D  

 

Q2) Which member super class are not intended to sub class? 

A. Public members

B. Protected members

C. Private members

D. Private or Protected members

ANS :-  C  

 

Q3) If a sub class object is created, which constructor is called first? 

A. Super class constructor

B. Sub class constructor

C. Depends on how we call the object

D. Not possible

ANS :-  A  

 

Q4)  Which among the following is true?

A. Java supports all types of inheritance

B. Java supports multiple inheritance

C. Java doesn’t support multiple inheritance

D. Java doesn’t support inheritance

ANS :-  C  

 

Q5)  How many types of inheritance should be used for hybrid

A. Only 1

B. At east 2

C. At most two

D. Always more than 2

ANS :-  B  

 

Q6)  What is upcasting?

A. Casting subtype to supertype

B. Casting super type to subtype

C. Casting subtype to super type and vice versa

D. Casting anytype to any other type

ANS :-  A  

 

Q7)  Which of these keywords is used to define interfaces in Java?

A. Interface

B. implements

C. Intf

D. Intf

ANS :-   A 

@MrProgrammer89

 

Q8)  Which of these keywords are used to define an abstract class?

A. abst

B. abstract

C. Abstract

D. abstract class

ANS :-  B  

 

Q9)  Predict the output of following Java programs:

public abstract class Demo implements Runnable

{

public void sum(int x,int y)

{

}

}

A. The program will not compile because it does not implement the run() method

B. The program will not compile because it does not contain abstract methods.

C. The program compiles fine.

D. None of the above

ANS :- D   

 

Q10)  What will be the output of the following Java code?

class Demo

{

public static void main(String args[])

{

Thread t = Thread.currentThread();

t.setName("New Thread");

System.out.println(t);

  }

}

A. Thread[5,main]

B. Thread[New Thread,5]

C. Thread[main,5,main]

D. Thread[New Thread,5,main]

ANS :-  C  

 

Q11)  What Happen in case of multiple catch blocks

A. Either super or subclass can be caught first.

B. The superclass exception must be caught first.

C. The superclass exception cannot caught first.

D. None of these

ANS :-  C 

 

Q12)  Thread priority in Java is represented as?

A. int

B. Float

C. double

D. long

ANS :-  A  

 

Q13)  Which of these methods is used to begin the execution of a thread?

A. run()

B. start()

C. runThread()

D. startThread()

ANS :-  B  

 

Q14)  Which method in Thread class is used to check weather a thread is still running?

A. isAlive()

B. Join()

C. isRunning()

D. Alive()

ANS :-  A  

 

Q15)  Which of these method waits for the thread to treminate?

A. sleep()

B. isAlive()

C. join()

D. stop()

ANS :-  C  

 

 

Prev

Next 

 

 

@MrProgrammer89



Post a Comment

Thanks for reading the blog. We hope it was useful to you and that you learned something new. Will always be writing on new and interesting topics, so you can visit our website to know the latest updates of our blogs. Thank You!

Previous Post Next Post

Contact Form