Java Programming
Java OOP, collections, multithreading
476 Questions 10 Topics Take Test
Advertisement
Showing 471–476 of 476 questions
Q.471 Medium Basics & Syntax
What is the output of: System.out.println(5 > 3 ? 'A' : 'B');
A A
B B
C true
D Compilation error
Correct Answer:  A. A
EXPLANATION

The ternary operator (?:) evaluates the condition (5 > 3, which is true) and returns the first value 'A'.

Take Test
Q.472 Medium Basics & Syntax
Which operator has the highest precedence in Java?
A * / %
B + -
C () []
D == !=
Correct Answer:  C. () []
EXPLANATION

Parentheses () and array access [] have the highest precedence in Java. Multiplication, division, and modulo come next, followed by addition and subtraction.

Take Test
Q.473 Medium Basics & Syntax
What is the output of: System.out.println(10 / 3);
A 3.33
B 3
C 3.0
D 3.333333
Correct Answer:  B. 3
EXPLANATION

When both operands are integers, the division result is an integer. 10 / 3 = 3 (integer division, not floating-point).

Take Test
Q.474 Medium Basics & Syntax
Which of the following will compile without error? public static void main(String args[]) { int x = 10; final int y = 20; y = 30; }
A Yes, it will compile
B No, compilation error on y = 30
C No, compilation error on final declaration
D No, compilation error on main method
Correct Answer:  B. No, compilation error on y = 30
EXPLANATION

Once a final variable is assigned, it cannot be reassigned. The line 'y = 30;' will cause a compilation error.

Take Test
Q.475 Medium Basics & Syntax
What is the size of 'char' data type in Java?
A 1 byte
B 2 bytes
C 4 bytes
D 8 bytes
Correct Answer:  B. 2 bytes
EXPLANATION

The 'char' data type in Java is 2 bytes (16 bits) because it uses Unicode character encoding.

Take Test
Advertisement
Q.476 Medium Basics & Syntax
Which of the following is NOT a primitive data type in Java?
A int
B boolean
C String
D double
Correct Answer:  C. String
EXPLANATION

String is a non-primitive (reference) data type in Java. Primitive types include int, boolean, double, float, char, long, short, byte.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips