D286 ITSW 3172
Java Fundamentals
Comprehensive Objective
Assessment
2024
,1. Multiple Choice: What is the output of the following Java code snippet?
```java
int x = 5;
int y = ++x;
System.out.println(y);
```
A) The code will not compile
B) 5
C) 6
D) 10
Correct Answer: C) 6
Rationale: The increment operator `++x` first increments the value of x by
1, and then assigns the result to y. Therefore, y will be 6.
2. Fill in the Blank: In Java, an abstract class cannot be _______ directly.
Correct Answer: instantiated
Rationale: Abstract classes are meant to be subclassed, and you cannot
create an instance of an abstract class.
, 3. True/False: The `equals()` method in Java compares the memory
addresses of two objects.
Correct Answer: False
Rationale: The `equals()` method in Java is used to compare the actual
contents of two objects, not their memory addresses.
4. Multiple Choice: Which keyword is used to implement multiple
inheritances in Java?
A) abstract
B) extends
C) implements
D) super
Correct Answer: C) implements
Rationale: In Java, a class can implement multiple interfaces to achieve
multiple inheritance.
5. Fill in the Blank: The `super` keyword in Java is used to access the
_______ of the superclass.
Correct Answer: members
Java Fundamentals
Comprehensive Objective
Assessment
2024
,1. Multiple Choice: What is the output of the following Java code snippet?
```java
int x = 5;
int y = ++x;
System.out.println(y);
```
A) The code will not compile
B) 5
C) 6
D) 10
Correct Answer: C) 6
Rationale: The increment operator `++x` first increments the value of x by
1, and then assigns the result to y. Therefore, y will be 6.
2. Fill in the Blank: In Java, an abstract class cannot be _______ directly.
Correct Answer: instantiated
Rationale: Abstract classes are meant to be subclassed, and you cannot
create an instance of an abstract class.
, 3. True/False: The `equals()` method in Java compares the memory
addresses of two objects.
Correct Answer: False
Rationale: The `equals()` method in Java is used to compare the actual
contents of two objects, not their memory addresses.
4. Multiple Choice: Which keyword is used to implement multiple
inheritances in Java?
A) abstract
B) extends
C) implements
D) super
Correct Answer: C) implements
Rationale: In Java, a class can implement multiple interfaces to achieve
multiple inheritance.
5. Fill in the Blank: The `super` keyword in Java is used to access the
_______ of the superclass.
Correct Answer: members