Question: QUESTION 1 The first character in a String has an index of 1 . True False 4 points QUESTION 2 The Scanner class provides methods

QUESTION 1
The first character in a String has an index of 1.
True
False
4 points
QUESTION 2
The Scanner class provides methods for reading various data types from a file.
True
False
4 points
QUESTION 3
If the indexOf method in the String class is unable to find an occurance of a character or String, it will return the value 0 to signify that it was unable to find anything.
True
False
4 points
QUESTION 4
The + operator is used for String concatenation, among other uses.
True
False
4 points
QUESTION 5
If a class is not in the java.lang package, you can use the import keyword to tell the compiler where to find the class definition.
True
False
4 points
QUESTION 6
To read in an entire line of input from the user, it is necessary to use the next method of the Scanner class.
True
False
4 points
QUESTION 7
Which of the following (select all correct answers) are identifiers for a method of the String class?
indexOf
charAt
length
substring
6 points
QUESTION 8
Which of the following (select all correct Answers) will allow you to use the DecimalFormat class in your own program:
import java.text.DecimalFormat;
use DecimalFormat;
import java.lang.*;
import java.text.*;
6 points
QUESTION 9
What will be the value of the variable letter after the following code is executed:
String name = "Richard";
char letter = name.toLowerCase().charAt(0);
'r'
'R'
"r"
"R"
12 points
QUESTION 10
What is the value of the variable position after the following code has been executed:
String name = "Lola";
int position = name.toLowerCase().indexOf('l')// The argument of the indexOf method is the char literal lowecase l
3
2
1
0
12 points
QUESTION 11
What will be the output of the following Java code:
System.out.println("The sum of 1 and 7 is "+1+7);
The sum of 1 and 7 is 8
The sum of 1 and 7 is 1+7
The sum of 1 and 7 is 17
The sum of 1 and 7 is +1+7
12 points
QUESTION 12
What will be the output of the following Java code:
System.out.println("The sum of 8 and 5 is "+(8+5));
The sum of 8 and 5 is 85
The sum of 8 and 5 is 13
The sum of 8 and 5 is 8+5
The sum of 8 and 5 is +8+5
12 points
QUESTION 13
Which of the following methods returns the the index of the first occrance of a specified character in a String:
substring
length
indexOf
charAt
12 points
QUESTION 14
What will be the output of the following Java code:
String s = "Hello World";
System.out.println(s.indexOf('h'));
Hello World
-1
1
0
12 points
QUESTION 15
What is the value of the variable result after the following code has been executed:
String name = "James Joyce";
String result = name.toUpperCase().substring(name.indexOf("")+1).toLowerCase();
James
JAMES
JAMES JOYCE
joyce
JOYCE
james joyce
This code will not actually compile or will produce an error.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!