Java MCQ

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Q. Who is known as father of Java Programming Language?

A.James Gosling
B.M. P Java
C.Charel Babbage
D.Blais Pascal
Answer : James Gosling [Option : A]

Q. In java control statements break, continue, return, try-catch-finally and assert


belongs to?
A.Selection statements
B.Loop Statements
C.Transfer statements
D.Pause Statement
Answer : Transfer statements [Option : C]

Q. Which provides runtime environment for java byte code to be executed?


A.JDK
B.JVM
C.JRE
D.JAVAC
Answer : JVM [Option : B]

Q. What is byte code in Java?


A.Code generated by a Java compiler
B.Code generated by a Java Virtual Machine
C.Name of Java source code file
D.Block of code written inside a class
Answer : Code generated by a Java compiler [Option : A]

Q. Which of the following are not Java keywords ?


A.double
B.switch
C.then
D.instanceof
Answer : then [Option : C]
Q. Which of these have highest precedence?
A.()
B.++
C.*
D.>>
Answer : () [Option : A]

Q. Which of these is returned by operator '&' ?


A.Integer
B.Character
C.Boolean
D.Float
Answer : Character [Option : B]

Q. Data type long literals are appended by _____


A.Uppercase L
B.Lowercase L
C.Long
D.Both A and B
Answer : Both A and B [Option : D]

Q. Which variables are created when an object is created with the use of the
keyword 'new' and destroyed when the object is destroyed?
A.Local variables
B.Instance variables
C.Class Variables
D.Static variables
Answer : Instance variables [Option : B]

Q. Java language was initially called as ________


A.Sumatra
B.J++
C.Oak
D.Pine
Answer : Oak [Option : C]
Q. What is garbage collection in the context of Java?
A.Java deletes all unused java files on the system.
B.Memory used by the object with no reference is automatically reclaimed.
C.The JVM cleans output of Java program with error.
D.Any unused package in a program automatically gets deleted.
Answer : Memory used by the object with no reference is automatically reclaimed. [Option : B]

Q. Which one is a template for creating different objects ?


A.An Array
B.A class
C.Interface
D.Method
Answer : A class [Option : B]

Q. Which symbol is used to contain the values of automatically initialized arrays?


A.Brackets
B.Braces
C.Parentheses
D.Comma
Answer : Braces [Option : B]

Q. Which one is true about a constructor ?


A.A constructor must have the same name as the class it is declared within.
B.A constructor is used to create objects.
C.A constructor may be declared private
D.All of the above
Answer : All of the above [Option : D]

Q. Which of these operators is used to allocate memory to array variable in Java?


A.alloc
B.malloc
C.new malloc
D.new
Answer : new [Option : D]
Q. Which of these is not a bitwise operator?
A.
&' Operator
B.
&=' Operator

C.
|=' Operator
D.
<=' Operator

Answer : <=' Operator [Option : D]

Show Answer

Q. Which of these is returned by Greater Than, Less Than and Equal To (i.e
Relational) operator ?
A.
Fload
B.
Integer

C.
Boolean
D.
Double

Answer : Boolean [Option : C]

Show Answer

Q. Which statement transfer execution to different parts of your code based on the
value of an expression?
A.
If
B.
Switch

C.
Nested-if
D.
if-else-if

Answer : Switch [Option : B]

Show Answer

Q. Modulus operator (%) can be applied to which of these?


A.
Integers
B.
Floating - point numbers

C.
Both A and B
D.
None of These

Answer : Both A and B [Option : C]

Show Answer

Q. What feature of OOP has a super-class sub-class concept?


A.
Hierarchical inheritance
B.
Single inheritance

C.
Multiple inheritances
D.
Multilevel inheritance
Answer : Hierarchical inheritance [Option : A]

Show Answer

You might also like