Java Programming
Java OOP, collections, multithreading
958 Questions 10 Topics Take Test
Advertisement
Showing 951–958 of 958 questions
Q.951 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.952 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.953 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.954 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
Q.955 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
Advertisement
Q.956 Easy Basics & Syntax
What will be the output of the following code? int x = 5; x += 3; System.out.println(x);
A 3
B 5
C 8
D 53
Correct Answer:  C. 8
EXPLANATION

The += operator adds the right operand to the left operand. x += 3 is equivalent to x = x + 3, so 5 + 3 = 8.

Take Test
Q.957 Easy Basics & Syntax
Which keyword is used to create a constant variable in Java?
A const
B constant
C final
D immutable
Correct Answer:  C. final
EXPLANATION

The 'final' keyword is used to declare constants in Java. Once assigned, the value cannot be changed.

Take Test
Q.958 Easy Basics & Syntax
Which of the following is the correct syntax to declare a variable in Java?
A int x = 10;
B int x: 10;
C x int = 10;
D int: x = 10;
Correct Answer:  A. int x = 10;
EXPLANATION

Java uses the syntax 'datatype variableName = value;' for variable declaration.

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