Top Java MCQs Questions And Answers

  • By Pooja Ghodekar
  • November 5, 2024
  • JAVA Programming
Top Java MCQs Questions And Answers

Top Java MCQs Questions And Answers

Explore the Top Java MCQs Questions And Answers to test your knowledge. Perfect for beginners and professionals preparing for Java exams and interviews.

 

Can we override final methods in Java? 

A.yes 

B.no 

Ans:B 

 

break keyword used only inside 

A.if statements 

B.class and loops 

C.switch case and loops 

D.loops and if statements 

Ans:C 

 

Which method is called internally when Thread start() method? A.execute() 

B.run() 

C.start() 

D.yeild() 

Ans:B 

 

What is the maximum thread priority in java? 

A.5 

B.9 

C.20 

D.10 

Ans:D

 

Which method should be implemented by Java thread? A.run() 

B.start() 

C.wait() 

D.sleep() 

Ans:A 

 

How many threads are created in the java program? public class ThreadExtended extends Thread { 

public void run() { 

System.out.println(“\nThread is running now\n”); 

public static void main(String[] args) { 

ThreadExtended t1= new ThreadExtended(); 

t1.start(); 

A.1 

B.0 

C.2 

D.3 

Ans:C 

 

By how many ways thread can be created in java multithreading

A.1 

B.0 

C.2 

D.3 

Ans:2 

 

Which statement is correct about the thread 

A. On calling the thread start method a new thread gets created
B. Thread start() method can call run() internally 

C. The thread run method can not be called directly to create a thread
D. All are correct 

Ans:D 

 

Which method is used to create the main thread to wait for all child threads A.Stop 

B.wait 

C.join 

D.sleep 

Ans:C 

 

The default thread priority of java thread is  

Ans:D 

 

Which method is used to check if the thread is alive? 

A.alive() 

B.isAlive()

C.run() 

D.start() 

Ans: B 

 

The task performed by the daemon thread is

A.to serve user thread 

B. Perform garbage collection 

C.both 1 and 2 

D.none of the above 

Ans: C 

 

Which method is used to create a daemon thread in java? A.setDaemon() 

B.createDaemon() 

C.Daemon() 

D.makeDaemon() 

Ans:A 

 

wait(),notify(),notifyAll() methods belong to which class? A.System 

B.String 

C.Thread 

D.Object 

Ans:D 

 

For Free, Demo classes Call: 020-71173125

Registration Link: Java Classes in Pune!

 

The life cycle of thread in java is controlled by A.JDK 

B.JRE 

C.JVM

D.None of the above 

Ans: C 

 

Thread synchronization is achieved by using which method A.wait() 

B.run() 

C.synchronized 

D.syn() 

Ans:C 

 

Which of these methods deletes all the elements from invoking collection?

A. Clear() 

B. delete() 

C. move() 

D. copy 

Ans:A 

 

Which of this interface contain a unique element? 

A.Map 

B.Comparable 

C.Set 

D.List 

Ans: C 

 

Which of the below packages consists of all the classes of the Collection framework Ajava.lang 

B.java.util

C.java.awt 

D.java.io 

Ans : B 

 

Which class does not override the equals() method,inheriting directly from class Object? 

A.java.String 

B.java.Integer 

C.java.StringBuffer 

D.java.Character 

Ans: C

 

scanner class comes under which package

A. java.sql 

B. java.lang 

C.java.util 

D.java.awt 

Ans : C 

 

JVM processes on which code 

A.source code 

B.Byte code 

C.machine code 

D.native code 

Ans: B 

 

Static method must be called by A.class name 

B.package name 

C.object name 

D.method name 

Ans:A

 

which class is the parent of all the exceptions in Java 

A.Scanner 

B.Thread 

C.Throwable 

D.Exception 

Ans:D 

 

Which is the unchecked exception in java 

A.ClassNotFoundException 

B.SQLException 

C.IOException 

D.ArithmeticException 

Ans:D 

 

____ method of String class is used to create exact copy of heap string object into scp area A.split 

B.intern 

C.trim 

D.substring 

Ans:B 

 

which concept in Java is used to wrap the data and provide security to the data A.Encapsulation 

B.Abstraction 

C.inheritance 

D.polymorphism 

Ans:A

 

Choose the correct set of wrapper classes in java 

A. Integer,Char,Byte,String 

B.Integer,Long,Boolean,Byte 

C.Integer,Float,String,Short 

D.Integer,Double,Byte,String 

Ans: B 

 

Which keyword should we used To override the property of one class into another class

A.static 

B.this 

C. final 

D.super 

Ans: D 

 

By using ________ keyword in Java, we can call one method inside another method of same class

A.static 

B.this 

C. final 

D.super 

Ans:B 

 

For Free, Demo classes Call: 020-71173125

Registration Link: Java Course in Pune!

 

Which statement is correct about the thread

A. On calling the thread start method a new thread gets created
B. Thread start() method can call run() internally
C. The thread run method can not be called directly to create a thread
D. All are correct 

Ans:D 

 

What is the valid declaration of float? 

A.float f=1.0; 

B.float f=”1.0”; 

C.float f=1; 

D. float f=1.0f; 

Ans: D 

 

Which of the iterators can traverse the collection in both directions? A.Enumerated Iterator 

B.List Iterator 

C.Map Iterator 

D.Set Iterator 

Ans:B

 

Which one of the following is Java’s reserved word?

A. main

B.run

C.implement 

D.import 

Ans:D 

 

The constructor must be the same as ______ name 

A.class

B.object  

C.method 

D.block 

Ans: A

 

Can we override private methods in Java?

A.yes 

B.no 

Ans:B 

 

break keyword used only inside 

A.if statements 

B.class and loops 

C.switch case and loops 

D.loops and if statements 

Ans:C 

 

How can we create our own immutable class

A. declaring that class as public 

B. making the constructor is private

C. by declaring that class as a final 

D. by creating only one constructor  

Ans:C

 

Do visit our channel to know more: Click Here

Author:-

Pooja Ghodekar

Call the Trainer and Book your free demo Class For Java Call now!!!
| SevenMentor Pvt Ltd.

© Copyright 2021 | SevenMentor Pvt Ltd.

Submit Comment

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

*
*