Question 1
Which statement is true about primitive variables?
- They can be compared with the == operator.
- They can be compared with the equals method only.
- They cannot be compared.
- They can be compared with the compareTo method only.
Question 2
Given the code fragment: What is the result?
- 2
- 4
- The program executes an infinite number of times.
- 3
Question 3
Identify two Java reserved words.
- array
- true
- this
- exception
- string
Question 4
Which statement is true about a Java method?
- It must be declared with an access modifier.
- It cannot be defined within another method.
- It must accept a parameter and return a value.
- It cannot be defined as static final.
Question 5
Given: And the code fragment: Which code fragment can be inserted at line n1 to enable the code to print All the best?
- void writeMsg();
- Messenger.writeMsg();
- writeMsg();
- m.writeMsg();