Java Programming
Java OOP, collections, multithreading
958 Questions 10 Topics Take Test
Advertisement
Showing 911–920 of 958 questions
Q.911 Easy Basics & Syntax
What does the 'super' keyword do in Java?
A Refers to the current object
B Refers to the parent class
C Creates a new instance
D Marks a method as superior
Correct Answer:  B. Refers to the parent class
EXPLANATION

The 'super' keyword is used to refer to parent class members and invoke parent class constructors.

Take Test
Q.912 Medium Basics & Syntax
Which of the following cannot be inherited in Java?
A Public methods
B Protected methods
C Private methods
D Static methods can be inherited
Correct Answer:  C. Private methods
EXPLANATION

Private members are not inherited. They remain accessible only within the class they are declared in.

Take Test
Q.913 Hard Basics & Syntax
What is the result of: int x = 5; System.out.println(x++ + ++x);?
A 10
B 11
C 12
D 13
Correct Answer:  B. 11
EXPLANATION

x++ returns 5 (then increments to 6), ++x increments to 7 and returns 7. Sum = 5+7 = 12. Note: Actual result may vary due to JVM optimization but typically 11 or 12.

Take Test
Q.914 Medium Basics & Syntax
Which of the following about static variables is incorrect?
A Static variables are shared among all instances
B Static variables are initialized when class loads
C Each object has its own copy of static variables
D Static variables can be accessed using class name
Correct Answer:  C. Each object has its own copy of static variables
EXPLANATION

Static variables are shared among ALL instances of a class, not individual copies per object.

Take Test
Q.915 Medium Basics & Syntax
What is the output of: System.out.println(5 % 2 + 3 * 2 - 1);?
A 6
B 7
C 8
D 10
Correct Answer:  A. 6
EXPLANATION

Following operator precedence: 5%2=1, 3*2=6, then 1+6-1=6

Take Test
Advertisement
Q.916 Easy Basics & Syntax
Which of the following is a valid variable declaration?
A int 2num;
B int num-2;
C int num$2;
D int num.2;
Correct Answer:  C. int num$2;
EXPLANATION

Variable names can contain letters, digits, underscores, and dollar signs, but cannot start with a digit or contain hyphens or dots.

Take Test
Q.917 Medium Basics & Syntax
Which statement about constructor overloading is true?
A Constructors cannot be overloaded
B Constructors can be overloaded with different parameter types and counts
C Only one constructor is allowed per class
D Constructor return type must differ for overloading
Correct Answer:  B. Constructors can be overloaded with different parameter types and counts
EXPLANATION

Constructors can be overloaded based on parameter count and types, but not on return type.

Take Test
Q.918 Easy Basics & Syntax
What is the correct way to declare a constant in Java?
A const int MAX = 100;
B static int MAX = 100;
C public static final int MAX = 100;
D final static int MAX = 100;
Correct Answer:  C. public static final int MAX = 100;
EXPLANATION

'const' is not a Java keyword. The correct convention for constants is public static final. Option D also works but C follows the standard convention.

Take Test
Q.919 Medium Basics & Syntax
Which access modifier allows access within the same package and subclasses?
A public
B private
C protected
D default
Correct Answer:  C. protected
EXPLANATION

protected allows access within the same package and to subclasses even outside the package.

Take Test
Q.920 Medium Basics & Syntax
What is the difference between == and .equals() for String comparison?
A Both check string content
B == checks reference, .equals() checks content
C == checks content, .equals() checks reference
D They are identical in functionality
Correct Answer:  B. == checks reference, .equals() checks content
EXPLANATION

== compares object references (memory location), while .equals() compares the actual string content.

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