Home Programming Kids Programming Hardware & Software Hardware & Networking APP security Software Education Kids Study MCQS Download OTHERS Login

Java Basic Multiple Choice Question MCQ

Categories: Java

Ques. 1) Which option is false about the final keyword?


a) A final method cannot be overridden in its subclasses.

b) A final class cannot be extended.

c) A final class cannot extend other classes.

d) A final method can be inherited.

Answer: (c) A final class cannot extend other classes.


Ques. 2) Which of these classes are the direct subclasses of the Throwable class?


a) RuntimeException and Error class

b) Exception and VirtualMachineError class

c) Error and Exception class

d) IOException and VirtualMachineError class

Answer: (c) Error and Exception class


Ques. 3) What do you mean by chained exceptions in Java?


a) Exceptions occurred by the VirtualMachineError

b) An exception caused by other exceptions

c) Exceptions occur in chains with discarding the debugging information

d) None of the above

Answer: (b) An exception caused by other exceptions.


Ques. 4) In which memory a String is stored, when we create a string using new operator?


a) Stack

b) String memory

c) Heap memory

d) Random storage space

Answer: (c) Heap memory


Ques. 5) What is the use of the intern() method?


a) It returns the existing string from memory

b) It creates a new string in the database

c) It modifies the existing string in the database

d) None of the above

Answer: (a) It returns the existing string from the memory


Ques. 6) Which of the following is a marker interface?


a) Runnable interface

b) Remote interface

c) Readable interface

d) Result interface

Answer: (b) Remote interface


Ques. 7) Which of the following is a reserved keyword in Java?


a) object

b) strictfp

c) main

d) system

Answer: (b) strictfp


Ques. 8) Which keyword is used for accessing the features of a package?


a) package

b) import

c) extends

d) export

Answer: (b) import


Ques. 9) In java, jar stands for_____.


a) Java Archive Runner

b) Java Application Resource

c) Java Application Runner

d) None of the above

Answer: (d) None of the above


Ques. 10) What will be the output of the following program?


public class Test2 {  

    public static void main(String[] args) {  

        StringBuffer s1 = new StringBuffer("Complete");  

        s1.setCharAt(1,'i');  

        s1.setCharAt(7,'d');  

        System.out.println(s1);  

     }  

 }  


a) Complete

b) Iomplede

c) Cimpletd

d) Coipletd

Answer: (c) Cimpletd


Ques. 11) Which of the following is false?


a) The rt.jar stands for the runtime jar

b) It is an optional jar file

c) It contains all the compiled class files

d) All the classes available in rt.jar is known to the JVM

Answer: (b) It is an optional jar file.


Ques. 12) What is the use of \w in regex?


a) Used for a whitespace character

b) Used for a non-whitespace character

c) Used for a word character

d) Used for a non-word character

Answer: (c) Used for a word character


Ques. 13) Which of the given methods are of Object class?


a) notify(), wait( long msecs ), and synchronized()

b) wait( long msecs ), interrupt(), and notifyAll()

c) notify(), notifyAll(), and wait()

d) sleep( long msecs ), wait(), and notify()

Answer: (c) notify(), notifyAll(), and wait()


Ques. 14) Given that Student is a class, how many reference variables and objects are created by the following code?


Student studentName, studentId;  

studentName = new Student();  

Student stud_class = new Student();   


a) Three reference variables and two objects are created.

b) Two reference variables and two objects are created.

c) One reference variable and two objects are created.

d) Three reference variables and three objects are created.

Answer: (a) Three reference variables and two objects are created.


Ques. 15) Which of the following is a valid syntax to synchronize the HashMap?


a) Map m = hashMap.synchronizeMap();

b) HashMap map =hashMap.synchronizeMap();

c) Map m1 = Collections.synchronizedMap(hashMap);

d) Map m2 = Collection.synchronizeMap(hashMap);

Answer: (c) Map m1 = Collections.synchronizedMap(hashMap);


Ques. 16) Given,


ArrayList list = new ArrayList();  

What is the initial quantity of the ArrayList list?

a) 5

b) 10

c) 0

d) 100

Answer: (b) 10


Ques. 17) Which of the following is a mutable class in java?

a) java.lang.String

b) java.lang.Byte

c) java.lang.Short

d) java.lang.StringBuilder

Answer: (d) java.lang.StringBuilder

Java Basic Multiple Choice Question MCQ