Which statement is true about Java?
a) Java is a sequence-dependent programming language
b) Java is a code dependent programming language
c) Java is a platform-dependent programming language
d) Java is a platform-independent programming language
Ans: D
Which component is used to compile, debug and execute the java programs?
a) JRE
b) JIT
c) JDK
d) JVM
Ans: d
What is the stored in the object obj in following lines of Java code?
box obj;
a) Memory address of allocated memory of object
b) NULL
c) Any arbitrary pointer
d) Garbage
Ans: b
Which of the following is a valid declaration of an object of class Box?
a) Box obj = new Box();
b) Box obj = new Box;
c) obj = new Box();
d) new Box obj;
Ans: a
Which of this method is given parameter via command line arguments?
a) main()
b) recursive() method
c) Any method
d) System defined methods
Ans: a
Which of these data types is used to store command line arguments?
a) Array
b) Stack
c) String
d) Integer
Ans: C
How many arguments can be passed to main()?
a) Infinite
b) Only 1
c) System Dependent
d) None of the mentioned
Ans: a
Which of these is a correct statement about args in the following line of code?
public static void main(String args[])
a) args is a String
b) args is a Character
c) args is an array of String
d) args in an array of Character
Ans: c
What should be expression1 evaluate to in using ternary operator as in this line?
expression1 ? expression2 : expression3
a) Integer
b) Floating – point numbers
c) Boolean
d) None of the mentioned
Ans: C
Which of these is an incorrect array declaration?
a) int arr[] = new int[5]
b) int [] arr = new int[5]
c) int arr[] = new int[5]
d) int arr[] = int [5] new
Ans: a
Which of the following is not a valid flow control statement?
A. continue
B. Break
C. Return
D. Exit()
E. None of these
Ans: D
From where break statement causes an exit?
A. Only from innermost switch
B. From innermost loops or switches
C. Terminates a program
D. Only from innermost loop
Ans: B
9. Which of the following loops will execute the body of loop even when condition controlling the
loop is initially false?
A. While B. for C. if D. do-while
Ans:D
Which of these can be returned by the operator &?
a) Integer
b) Boolean
c) Character
d) Integer or Boolean
Ans: d
Literal can be of which of these data types?
a) integer
b) float
c) boolean
d) all of the mentioned
Ans:d
Which class does all the Enums extend?
a) Object
b) Enums
c) Enum
d) EnumClass
Ans: c
This Section of our 1000+ Java MCQs focuses on Character and Boolean Datatypes of Java
Programming Language.
1. What is the numerical range of a char data type in Java?
a) -128 to 127
b) 0 to 256
c) 0 to 32767
d) 0 to 65535
Ans: d
Which of these coding types is used for data type characters in Java?
a) ASCII
b) ISO-LATIN-1
c) UNICODE
d) None of the mentioned
Ans: C
Which of these values can a boolean variable contain?
a) True & False
b) 0 & 1
c) Any integer value
d) true
Ans: A
Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?
a) ASCII
b) ISO-LATIN-1
c) None of the mentioned
d) ASCII and ISO-LATIN1
Ans: d
Which of the following is not OOPS concept in Java?
a) Inheritance
b) Encapsulation
c) Polymorphism
d) Compilation
Ans: d
Which concept of Java is achieved by combining methods and attribute into a class?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Abstraction
Ans: a
What is it called where child object gets killed if parent object is killed?
a) Aggregation
b) Composition
c) Encapsulation
d) Association
Ans: B
What is it called where object has its own lifecycle and child object cannot belong to another
parent object?
a) Aggregation
b) Composition
c) Encapsulation
d) Association
Ans: A
Which of these selection statements test only for equality?
a) if
b) switch
c) if & switch
d) none of the mentioned
Ans: b
Which of these are selection statements in Java?
a) if()
b) for()
c) continue
d) break
Ans; A