Java - Language Fundamentals Questions and Answers
Java Language Fundamentals questions with answers are essential for mastering the building blocks of Java programming. This includes topics like data types, operators, arrays, and control structures. Practicing programming questions and answers with explanations enables students to improve coding accuracy and logical reasoning. These Java MCQs are widely asked in technical interviews and online coding assessments conducted by companies like Infosys, TCS, and Capgemini. Reviewing Java aptitude questions with solutions PDF helps solidify your understanding of syntax and execution flow for placement and certification exams.
Java - Language Fundamentals
Showing 10 of
39 questions
11. Which one is a valid declaration of a boolean?
- boolean b1 = 0;
- boolean b2 = 'false';
- boolean b3 = false;
- boolean b4 = Boolean.false();
12. 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;
- 1, 2, 4
- 2, 3, 5
- 1, 3, 6
- 2, 4, 6
13. Which is a valid declarations of a String?
- String s1 = null;
- String s2 = 'null';
- String s3 = (String) 'abc';
- String s4 = (String) '\ufeed';
14. What is the numerical range of a char?
- -128 to 127
- -(215) to (215) - 1
- 0 to 32767
- 0 to 65535
15. Which of the following is a valid Java identifier?
- 2number
- Explanation: Java identifiers can start with a letter, underscore, or dollar sign and cannot contain special characters like - or #.
- number-2
- number#2
16. Which keyword is used to define a class in Java?
- define
- Explanation: The class keyword is used to define a class in Java.
- struct
- object
17. Which data type is used to store a single character in Java?
- Explanation: The char data type stores a single Unicode character.
- string
- Character
- text
18. What is the size of the int data type in Java?
- 16-bit
- Explanation: The int data type is always 32-bit in Java.
- 64-bit
- Depends on the system
19. Which of the following is NOT a Java primitive data type?
- int
- float
- Explanation: String is a class, not a primitive data type.
- char
20. Which symbol is used to terminate a Java statement?
- :
- ,
- Explanation: A semicolon marks the end of a Java statement.
- .