Java - Language Fundamentals Questions and Answers
Practice ModeShowing 10 of 39 questions
Q11
Which one is a valid declaration of a boolean?
Answer: Option C
Q12
Which three are valid declarations of a float?
float f1 = -343;
float f2 = 3.14;
float f3 = 0x12345;
float f4 = 42e7;
float f5 = 2001.0D;
float f6 = 2.81F;
Answer: Option C
Q13
Which is a valid declarations of a String?
Answer: Option A
Q14
What is the numerical range of a char?
Answer: Option D
Q15
Which of the following is a valid Java identifier?
Answer: Option B
Explanation: Java identifiers can start with a letter, underscore, or dollar sign and cannot contain special characters like - or #.
Q16
Which keyword is used to define a class in Java?
Answer: Option B
Explanation: The class keyword is used to define a class in Java.
Q17
Which data type is used to store a single character in Java?
Answer: Option A
Explanation: The char data type stores a single Unicode character.
Q18
What is the size of the int data type in Java?
Answer: Option B
Explanation: The int data type is always 32-bit in Java.
Q19
Which of the following is NOT a Java primitive data type?
Answer: Option C
Explanation: String is a class, not a primitive data type.
Q20
Which symbol is used to terminate a Java statement?
Answer: Option C
Explanation: A semicolon marks the end of a Java statement.