Q1 If an object reference does not currently reference an ob

Q1. If an object reference does not currently reference an object, it has a null value. (T or F)

Q2. Given the following code, the output will be: hamburger comes before pizza.

(T or F)

Q3. When using the multiple-branch statement, only one of the branches will be executed. (T or F)

Q4. The equals method works correctly with objects only if the creator of the class included it in the classes methods. (T or F)

Q5. Comparing two objects with the == tests if the object variables refer to the same object. (T or F)

Q6. When using decision structures, if you declare a variable in the body/block of an if or else, is visible to the outside of the body/block. (T or F)

Q7. To test if two strings are the same, you use the == operator. (T or F)

Q8. To use the multiple-branch statement (not nesting), you will need to use else if. (T or F)

String food1 = \"pizza\";
String food2 = \"hamburger\";
if(food1.compareTo(food2) < 0)
{
System.out.printf(\"%s comes before %s.\",food1,food2);
}
else
{
System.out.printf(\"%s comes before %s.\",food2,food1);
}

Solution

Q3 Yes when using multi branch statement only one of the branch will execute like if else ladder where only one of the condition will be true at a time.

Q6 No, the variable declares inside a block or body would be visible only inside that block not outside it.

Q8 Yes to use multi branch statement we need to have if else ladder where you can have if.. else if...else if........else

Q1. If an object reference does not currently reference an object, it has a null value. (T or F) Q2. Given the following code, the output will be: hamburger com

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site