NEW
Font size
WorksheetsJava Quiz 3: Object-Oriented Programming Concepts
Total questions: 8
Worksheet time: 24mins
What will be displayed when the following statements are run:
int limit=20;
int Sum=20;
if(sum>limit)
System.out.print("Limit surpassed");
else
System.out.print("Limit not ");
System.out.print("reached.");
Limit surpassed
Limit surpassed reached.
Limit not
Limit not reached.
When comparing strings, which method can be used to see if two strings contain the same string?
length()
compareTo()
equals()
indexOf()
What will the following code display when run?
String str1="Melvin";
String str2="Melvin";
if(str1!=str2)
System.out.print("I didn't expect that.");
else
System.out.print("This one is tricky.");
I didn't expect that.
This one is tricky.
To compare if two string are the same we can use the == operator.
True
False
A setter methods gives a data field its value
True
False
A getter methods will retrieve values from a data field.
True
False
To use a Scanner we need to create a new Scanner object.
True
False
To get something other than a string from an input dialog box we need to parse the string into the appropriate data type.
True
False
