Java MCQs: Beginner and Advance Java MCQs

Java MCQs | Online Java MCQs 

Here you find all types of JAVA MCQs. From beginner to intermediate and advanced levels. Mixed Java multiple-choice questions for exams and job interviews. Basic Java MCQs. Experienced Java MCQ questions. Java CS exam MCQ.



1- Who developed/invented the Java language ??

(A) M. P Java

(B) Charel Babbage

(C) Blais Pascal

(D) James Gosling


2- Which one of these is not a feature in the Java language ??

(A) Exception Handling

(B) Binding between objects

(C) Bytecode is executed by JVM

(D) Applet


3- What does multiple inheritance in Java mean ??

(A) When many classes inherit from one super class

(B) When one class inherits from more super classes

(C) More classes inherit from more super classes

(D) None of the above


4- Which one of these is not a keyword in Java ??

(A) int

(B) then

(C) break

(D) instanceof


5- The operator ‘&’ returns what ??

(A) Float

(B) Double 

(C) Boolean

(D) Character


6- In which year Java was first released ??

(A) 1995

(B) 1996

(C) 1992

(D) 1990


7- Which method returns the name of the class as a string ??

(A) toString()

(B) Show()

(C) getClass()

(D) getName()


8- Among these which has the highest precedence ?? 

(A) *

(B) —

(C) ()

(D) ++


9- What is bytecode in Java ??

(A) code generated by a JVM

(B) It is the name of the Source File of Java

(C) code written in instance methods

(D) code that a Java Compiler generates


10- A random Java class found in which package ??

(A) java.util package

(B) java.awt package

(C) package

(D) java.lang package


     Java MCQs 


11- Initially the name of the Java language was ??

(A) JW

(B) Pine 

(C) Oak

(D) Sumatra


12- Which one among these is a subclass of the Panel class ??

(A) Fragment class

(B) Applet class

(C) Dialog class

(D) Name Class


13- In Java what does “chained exception” mean ??

(A) Exception caused by a mathematical error

(B) Series of runtime exceptions

(C) Exception caused by other exceptions

(D) None of the above. 


14- What does the intern() method do ??

(A) returns the existing string from memory

(B) modifies the string in memory

(C) creates a new string

(D) None of the above 


15- Which one of these used to create objects ??

(A) interface

(B) abstract class

(C) array

(D) class


16- How many bits does the “short” data type occupy in memory ??

(A) 4 bits

(B) 8 bits

(C) 16 bits 

(D) 32 bits


17- Short data type has the range of ??

(A) -32768 to 32767

(B) -128 to 127

(C) -2147483648 to 2147483647

(D) None of these


18- The range of data type “byte” is ??

(A)-2147483648 to 2147483647

(B) -32768 to 32767

(C) -128 to 127

(D) None of the above


19- An expression involving literal numbers, byte, int is promoted to which one of these ??

(A) float

(B) boolean

(C) byte

(D) int


20- Among these which can be contained in float data type?

(A) 3.4e-038

(B) 3.4e-050

(C) 3.4e-038

(D) 1.7e-308


Java MCQs 


21- All Transcendental math functions return the value of which data type ??

(A) Long

(B) Byte

(C) Float

(D) Double


22- Which type of programming language Java is ??

(A) Theoretical

(B) Functional

(C) Object-Oriented

(D) None of the above


23- In Java programming, we place code inside what ??

(A) Methods

(B) Blocks

(C) Classes/Interfaces

(D) All of these


24- What type of language Java is among these ??

(A) Strongly typed

(B) Moderate typed

(C) Weakly typed

(D) None of the above


25- How many primitive data types are available in the Java programming language ??

(A) 6

(B) 8

(C) 9

(D) 11


26- In Java, properties are implemented using ??

(A) Shortcuts

(B) Breaks

(C) Variables

(D) All of these


27- What suits the “Java class” best among these options ??

(A) Blueprint

(B) Instruction sheet

(C) Prototype

(D) All of the above


28- Int, byte, short and long, all these are _____ in Java ??

(A) Unsigned

(B) Signed

(C) both (a) and (b)

(D) None of the above


29- What is the size of “int” in the Java language ??

(A) 8 bit

(B) 16 bit 

(C) 32 bit

(D) Depends when executed in the runtime environment


30- For a public Java class what is the file extension used ??

(A) .ja

(B) .j

(C) .java

(D) .jvt


Java MCQs


31- For a compiled Java class what is the file extension used ??

(A) .class

(B) .compiled

(C) .cls


(D) None of the above


32- In Java the smallest integer type is ??

(A) byte

(B) short

(C) boolean

(D) int


33- The size of “byte” in Java is ??

(A) 8 bits

(B) 16 bits

(C) 32 bits 

(D) 64 bits


34- The source-code of an “Abstract-Class” or “Interface” is kept inside a .java file ??

(A) True 

(B) False

(C) –

(D) –


35- In Java programming, an Interface or Abstract Class is kept in which file after compilation ??

(A) .java

(B) .j

(C) .ja

(D) .class


36- A public class or an abstract class or interface must be kept in a separate .java file ??

(A) True

(B) False

(C) –

(D) –


37- In a .java file, how many numbers of public types namely class or interface or abstract can be managed ??

(A) 3

(B) 2

(C) 1 

(D) Any number


38- In Java, the size of a float is ??

(A) 32 bits

(B) 16 bits

(C) 64 bits

(D) 8 bits


39- What is the size of double in Java ??

(A) 16 bits

(B) 8 bits

(C) 64 bits

(D) 32 bits


40- When an automatic type conversion takes place in Java ??

(A) Both types are compatible and the size of the destination type is larger than the source type

(B) Both types are compatible and the size of the destination type is shorter than the source type

(C) Both types are compatible and the size of the destination type is equal to the source type

(D) All of the above


Java MCQs


41- What keyword do we use to declare a “class” in Java programming ??

(A) Java

(B) class

(C) Class

(D) java


42- What a Java class can contain ??

(A) Inner classes

(B) Variables

(C) Constructors, Methods

(D) All of the above


43- Which among the following automatic type conversion is possible in Java ??

(A) int to long

(B) long to int

(C) short to int

(D) byte to int


44- The word “true” in Java is ?

(A) Has a value equal to zero

(B) Has a value equal to one

(C) a Java keyword

(D) a Boolean literal


45- The “new” keyword is used to create an object at ?

(A) Depends on the code written

(B) compile time

(C) run time

(D) None of these


46- A Java “package” is a collection of ?

(A) Tools

(B) Only Interfaces

(C) Classes and interfaces

(D) Only classes


47- How many objects can we create from a single Java class ??

(A) 64

(B) 128 

(C) 256

(D) No limit


48- When we create an object from a Java class its called ??

(A) Interfacing

(B) Instantiating

(C) Initializing

(D) None of the above


49- What keyword is used to create a new Object in Java programming ??

(A) object

(B) new

(C) obj 

(D) create


50- Which of these is a correct statement for naming a class in Java ??

(A) The class name does not start with a number

(B) The name of the class does not contain any numbers 

(C) The class name can start with a dollar sign or an underscore or a letter

(D) All of these mentioned




51- The “object” in Java is created at ??

(A) Assembling time

(B) Run time

(C) Compile time

(D) None of these


52- Which keyword makes a variable belong to a class rather than being defined for each instance of the class ?

(A) Native

(B) Volatile

(C) Static

(D) Final


53- toString() method in Java is defined in ?

(A) java.lang.Object

(B) java.lang.util

(C) java.lang.String

(D) None of the above


54- What does compareTo() method return ?

(A) int value

(B) 1

(C) true

(D) -1


55- What is true about Java’s main method ?

(A) The main method in a Java class is called directly by Java Virtual Machine

(B) The Main method is not a required method

(C) The main method must start with public static void keywords

(D) All of these


56- To which package the class “string” belong ?

(A) java.applet

(B) java.lang

(C) java.string

(D) java.awt


57- In Java how many constructors does a String class have ?

(A) 11

(B) 13

(C) 9

(D) 15


58- After which programing language did Java come ?

(A) C++

(B) C

(C) C#

(D) None of these


59- What are “Arrays” in Java ?

(A) Primitive data types

(B) Object references

(C) Keyword

(D) Objects



(A) False

(B) True

(C) –

(D) –


Java MCQs


61- What was the original name of the programming language Java ??

(A) Java +

(B) Oak

(C) J+

(D) Vista


62- The laboratory where Java invented was “Bell Labortary” ?

(A) False

(B) True

(C) –

(D) –


63- When an array is passed to a method then the method receives what ?

(A) Index in the memory

(B) Size of the array

(C) Reference of the array

(D) Copy of the array


64- int smallList [] = {42, 13, 97}; Is this a legal array declaration and assignment in Java programming ? 

(A) False 

(B) True

(C) –

(D) –


65- Inside a Java-supported web browser, what kinds of Java programs can run ?


(B) Struts

(C) Applets

(D) Standalone


66- Which of these currently owns JAVA language and has its copyrights ?

(A) Microsoft


(C) Oracle 

(D) Nokia


67- Which of the following character escape code is not available in Java language ?

(A) \r

(B) \t

(C) \a

(D) \\


68- If a method does not return any value what would be the return type of that method ?

(A) int

(B) null

(C) void

(D) None of these


69- A person wants to generate a random integer either 0 or 1 then which of the following would be the best option ?

(A) (int)(Math.random() + 0.2)

(B) (int)Math.random()

(C) (int)Math.random() + 1

(D) (int)(Math.random() + 0.5)


70- What reason was behind the huge success of the Java language all over the world ?

(A) Smart home automation

(B) Smart TV Evolution

(C) Similarity to C++

(D) World Wide Web (WWW)


Java MCQs


71- What is the file name extension of a Java source program ?


(B) .jx

(C) .ja

(D) .java 


72- Java files are human-readable and contain classes with methods and variables ?

(A) True 

(B) False

(C) –

(D) –


73- Byte code is the result of ?

(A) Compiling a Class file

(B) Compiling a Java file

(C) Interpreting a Java file 

(D) Interpreting a Class file


74- What would be the output of Math.floor(3.6) ?

(A) 3.6

(B) 3.5

(C) 3.0

(D) 6.3


75- Where in memory the system stores parameters and local variables whenever a method is invoked ?

(A) Storage area

(B) Memory tree

(C) Heap

(D) Stack



76- Which one of these is not a correct modifier to use for a constructor in Java ?

(A) private 

(B) static

(C) public

(D) protected


77- Every Java program is compiled by which software ?






78- What is the full form of JVM ?

(A) Java Virtual Machine

(B) Java Virtual Mechanism

(C) Java Variable Machine

(D) None of these


79- What is/are the role of JVM ?

(A) It provides security to the computer by giving controlled access to files and memory on a computer

(B) Java Virtual Machine is a confined memory area

(C) All Java programs run inside JVM memory

(D) All of the above


80- What is the implicit return type of a constructor ?

(A) No return type

(B)  void

(C) a class object in which it is defined

(D) None of these mentioned


Java MCQs 


81- The method finalize() is called when ??

(A) Before garbage collection

(B) a variable goes out of scope

(C) an object, variable, or method goes out of scope

(D) None of the above mentioned


82- The main method in Java should be static because of the reason ?

(A) It can be accessed by every method or variable without any hindrance

(B) It can be accessed easily by the class loader

(C) It can be executed without creating any instance of the class

(D) Option (a) and (b)


83- What portability does the Java language offer ?

(A) Ability to run the Byte on different machines producing the same behavior and output

(B) Java does not actually provide portability

(C) Generating suitable Byte Code for each machine by the Compiler

(D) Small code size easy to carry occupying less disk space


84- What can only test for equality in Java ?

(A) match

(B) break

(C) switch

(D) equal


85- In Java, what can evaluate any type of Boolean expression ??

(A) continue

(B) if

(C) else

(D) None of these


86- What does JIT stand for ?

(A) Just In Time Runnable

(B) Just In Time Compiler

(C) Java In Timer

(D) Java In Time Thread


87- About Java language which of this statement is correct ?

(A) JIT Compiler assists the actual JAVAC compiler to compile fast

(B) JIT Compiler produces Byte Code from Java file

(C) Both (a) and (b)

(D) JIT Compiler takes chunks of Byte Code as input and produces Executable code on that particular machine


88- Select which one of these loops will be an infinite for loop ?

(A) for(a=0 ; a<1; a–)

(B) for( ; ; )

(C) for(i=0; ; i++)

(D) All of the above


89- If the JIT compiler is not present in JAVA what would happen ?

(A) Executable Code is produced slowly because of the line by line Interpreting

(B) Executable Code is produced without portability

(C) Executable Code is produced slowly because of the line by line Interpreting

(D) None of these


90- In Java which method cannot be overridden ?

(A) static 

(B) private

(C) final

(D) super


Java MCQs


91- What comes at the end of every Java statement ??

(A) Period

(B) Colon

(C) Semicolon

(D) Comma


92- A Java language method is like a function in C language ??

(A) False 

(B) True

(C) –

(D) –


93- The purpose to put “static” keyword before the main method is ??

(A) To make the main method as class method common to all instances

(B) To call the main method without creating an object of class

(C) Both (a) and (b)

(D) None of the above


94- For standalone Java applications, what is the necessary method ??

(A) print() method

(B) println() method

(C) display method

(D) Main method


95- Which of the following is the correct way to declare an abstract method in an abstract Java class ??

(A) public abstract void method();

(B) public abstract void method() {}

(C) public void method() {}

(D) public void abstract Method();


96- Which one of the following is a legal abstract class ??

(A) class A { abstract void unfinished(); }

(B) abstract class A { abstract void unfinished(); }

(C) class A { abstract void unfinished() { } }

(D) abstract class A { abstract void unfinished(); }


97- Define the use of “public” access modifier in Java ??

(A) To protect the main method

(B) To hide the main method from misuse

(C) To call the main method outside of Class or Package by JVM

(D) None of these


98- The correct way to make a single-line comment is ??

(A) Single Line Comment//

(B) //Single Line Comment

(C) / Single Line Comment/

(D) ** Single Line Comment **


99- For a multi-line comment in Java the correct way is ??

(A) /* Multi-Line comments */

(B) */ Multi-Line comments /*

(C) // Multi-Line comments //

(D) */* Multi-Line comments */*


100- Why String args[] in the main method used for ??

(A) Counting number of words

(B) Passing arguments at compile time

(C) Passing arguments at run time

(D) Option (a) and (b)


Java MCQs


101- By default, what is the return type of a method in the Java language ??

(A) short

(B) int 

(C) void

(D) None of the above 


102- For an abstract class in Java what is true ??

(A) An abstract class can be used as a data type

(B) A subclass of a non-abstract superclass can be abstract

(C) An abstract class can be extended

(D) All mentioned above


103- Among these which one is a correct interface ??






104- In the Java language when it is useful to declare a class as abstract ??

(A) When it makes sense to have objects of that class

(B) When it doesn’t make sense to have objects of that class

(C) To force developers to extend the class not to use its capabilities.

(D) To prevent developers from further extending the class


105- Name of variable, interface, method or class in Java is known as ??

(A) Name

(B) Parameter

(C) Value 

(D) Identifier 


106- For a valid identifier it must contain which characters ??

(A) $, _ (Underscore)

(B) 0-9

(C) A-Z, a-z

(D) All of the above


107- What is “Runnable” in the Java language ?

(A) class

(B) interface

(C) field

(D) argument


108- For a valid identifier in Java language it must start with ??

(A) 0-9

(B) $, _

(C) a-z, A-Z

(D) both (b) and (c)


109- The valid “White Spaces”  available in Java is/are ??

(A) Tab

(B) Space

(C) Enter

(D) All of these 


110- The class at the top of the exception class hierarchy is ??

(A) Exception

(B) Except

(C) Throwable

(D) ArithmeticException


Java MCQs


111- In Java, in which package the exception class is present ??



(C) java.lang

(D) java.file


112- Which one of these is a correct version of “Java Documentation Comment” ??

(A) /** Java Comments */

(B) /* Java Comments */

(C) -/- Java Comments -/-

(D) None of these


113- The exception generated by a try block Is caught in which block ??

(A) catch

(B) throw 

(C) finally

(D) throwall


114- Java Supports unsigned integers ??

(A) False 

(B) True

(C) –

(D) –


115- In Java among these which data type is an implementation of Objects or OOPs?

(A) char

(B) boolean

(C) int

(D) None of the above


116- To explicitly throw an exception the keyword used is ??

(A) throwing

(B) catch

(C) throw

(D) caught


117- The primitive data type is 

(A) Data Type which is implemented in a non-object-oriented way

(B) Data type, which is implemented in an Object-oriented way.

(C) Data Type which is implemented in a machine-dependent way

(D) None of these


118- Which of these is the wrong data type ?

(A) boolean

(B) long double

(C) short

(D) byte


119- Which is not a valid data type ?

(A) float

(B) bool

(C) boolean

(D) short


120- When divided by zero (0) what happens ??

(A) NullPointerException

(B) NumberFormatException

(C) ArithematicException

(D) None of these


Java MCQs


121- To handle “streams” and “buffers” which data type is mostly used in Java ??

(A) float

(B) short

(C) long

(D) byte


122- Which of these data types is not recommended for numeric applications in Java??

(A) boolean

(B) byte

(C) long

(D) short


123- The keyword that is used to specify the exception thrown by a method is ??

(A) finally

(B) volatile

(C) catch

(D) throws


124- In Java, which of the following blocks execute compulsorily whether an exception is caught or not ??

(A) throws 

(B) catch

(C) finally

(D) throw


125- If we use multiple catch blocks then what would happen ??

(A) None of these

(B) Either super or subclass can be caught first

(C) The superclass exception must be caught first



126- What exception comes when an array element is accessed beyond the array size ??

(A) ArithmeticException

(B) ArrayIndexOutOfBounds

(C) ArrayElementOutOfBounds

(D) ArrayIndexOutOfBoundsException


127- What is the range of byte data type in Java ??

(A) -128 to +127

(B) 0 to 255

(C) 0 to 256

(D) -127 to +128


128- Java short size ??

(A) 4 bytes

(B) 8 bytes

(C) 2 bytes

(D) 16 bytes


129- Floating point number in Java ??

(A) 16 bytes

(B) 4 bytes

(C) 32 bytes

(D) 64 bytes


130- Long int size ??

(A) 1 byte

(B) 2 bytes

(C) 4 bytes

(D) 8 bytes


Java MCQs


131- The size of the double floating-point number in Java is ??

(A) 4 bytes

(B) 8 bytes

(C) 16 bytes

(D) 32 bytes


132- We can create a thread in Java by ??

(A) Implementing Runnable interface

(B) Extending the thread class

(C) None of the above

(D) Both (a) and (b)


133- When a class extends the Thread class it overrides which method of “Thread” class to start that thread ??

(A) init()

(B) start()

(C) run()

(D) continue()


134- The valid constructors of class “Thread” is ??

(A) Thread(Runnable threadOb, String threadName)

(B) Thread(Runnable threadOb, int priority)

(C) Thread(String threadName, int priority)

(D) Thread(int priority)


135- stop() and yield() are the methods of Thread class ??

(A) True

(B) False

(C) –

(D) –


136- What is the size of char variable ??

(A) 4 bytes

(B) 3 bytes

(C) 2 bytes

(D) 1 byte


137- Boolean data type constant has a size of ??

(A) 1 bit

(B) 2 bits

(C)4 bits

(D) Not documented well


138- What does notifyAll() method do ?? 

(A) Wakes up all threads that are not waiting on this object’s monitor

(B) Wakes up all threads that are waiting on this object’s monitor

(C) Wakes up one thread that is waiting on this object’s monitor

(D) All the above


139- The keyword that indicates that only one thread should execute the method at a time is ??

(A) volatile

(B) final

(C) synchronized

(D) new


140- The package that contains “System class” is ??

(A) java.lang package

(B) java.awt package

(C) java.util package

(D) package


Java MCQs 


141- Which of these class/classes is defined in and used for file handling and is an abstract class ??

(A) InputStream

(B) Reader


(D) Both (a) and (b)


142- The IEEE standard adopted to represent Java Floating-Point Numbers is ?

(A) IEEE 754

(B) IEEE 9000

(C) IEEE 800

(D) IEEE 750


143- The character encoding standard used in Java language is ??

(A) Hexacode


(C) Bytecode

(D) Unicode


144- % (Also called Modulus operator) can be applied to which of these ??

(A) Floating-Point numbers

(B) Integers

(C) Floating-Point numbers and integers

(D) None of these


145- ASCII stands for ??

(A) Australian Standard Code for Information Interchange

(B) American Standard Code for Information Interchange

(C) American Standard Characters for Information Interchange

(D) None of the above


146- Define Literal in Java ??

(A) Literal is a data type

(B) Literal is like String

(C) Literal is a value that is given or assigned to a variable

(D) None of these


147- Decrement operator in Java decreases the value of a variable by what number ??

(A) 4 

(B) 3 

(C) 2 

(D) 1


148- Automatically 8 byte long data type will be casted to a 4 byte float data type?

(A) False

(B) True

(C) Depends on the code

(D) None


149- What literals are available in the Java language ??

(A) Float

(B) Integer

(C) Boolean

(D) All of these


150- Which is a type of Integer literals in Java ??

(A) Binary Literals

(B) Decimal Literals

(C) Octal Literals

(D) All of the above


Java MCQs 


151- Which is the highest order precedence operator in the Java language ??

(A) { }

(B) ()

(C) Both (a) and (b)

(D) None 


152- long d = 128____824_8__76L; <– Is this a correct literal for Java code ?

(A) True

(B) False

(C) –

(D) –


153- The octal number in Java language is represented by a leading what ??

(A) A alphabet

(B) 0

(C) Ax

(D) 0x


154- What are ” || and && ” operators in Java ??

(A) Combine two boolean values

(B) Combine two Numeric Values

(C) Combine two Strings

(D) Combine two characters


155- Hexadecimal numbers in Java have what Prefix ??

(A) 0x

(B) Ax

(C) Both (a) and (b)

(D) None of the above


156- In which version of Java language Binary Literals were introduced ??

(A) JDK 8

(B) JDK 4

(C) JDK 6

(D) JDK 9


157- In which version of Java underscore symbols in literal numbers were introduced??

(A) JDK 7

(B) JDK 9

(C) JDK 8

(D) JDK 6


158- What is the output of relational operators ??

(A) Double

(B) Integer

(C) Characters

(D) Boolean


159- “Less than”, “Greater than”, and “equal to” operators return what ??

(A) Boolean

(B) Integer

(C) Float

(D) None of these


160- What error will be shown if (_) underscores are not correctly used in Literals ??

(A) IllegalUnderscoresException

(B) Underscores are out of range

(C) Too many Underscores

(D) Underscores have to be located within digits



         Read More

Leave a Comment

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

error: Content is protected !!