CS 1101 Programming 1 JAVA All Self | Questions
And Answers | Updated Study Solutions
Student hint: Use an online compiler such as https://www.tutorialspoint.com/compile_java_online.php for testing most of the
code required output. Change class to public class.
Self Quiz 1
Question 1
Correct
Mark 1.00 out of 1.00
Question text
Which of the following should be used to compare the contents of two String objects in Java?
Select one:
a. =
b. ==
c. cmp
d. equals
e. ?
Feedback
Your answer is correct.
"=" is for assignment. "==" compares the memory locations of String objects, not their contents.
"cmp" is a command from Python, not Java. "?" Is the conditional operator. Use "s1.equals(s2)" to
compare the contents of String "s1" and "s2". See Section 2.3.3 of Eck (2014).
The correct answer is: equals
Question 2
Correct
Mark 1.00 out of 1.00
Question text
Consider the following line of Java code.
System.out.println("Hello, World!");
"System" is which of the following?
Select one:
,a. a class
b. a method (subroutine)
c. an object
d. a parameter
e. a statement
Feedback
Your answer is correct.
"System" is a built-in Java class with static member objects, like "out". See Section 2.3.1 of Eck
(2014).
The correct answer is: a class
Question 3
Correct
Mark 1.00 out of 1.00
Question text
Consider the following line of Java code.
System.out.println("Hello, World!");
The full line of code is which of the following?
Select one:
a. a class
b. a method (subroutine)
c. an object
d. a parameter
e. a statement
Feedback
Your answer is correct.
See Section 2.1 of Eck (2014).
The correct answer is: a statement
Question 4
Correct
Mark 1.00 out of 1.00
Question text
,What does a Java compiler do?
Select one:
a. Runs Java programs
b. Translates byte code in ".class" files into machine language
c. Translates source code in ".class" files into machine language
d. Translates source code in ".java" files into Java byte code in ".class" files
e. Translates source code in ".java" files into machine language
Feedback
Your answer is correct.
The correct answer is: Translates source code in ".java" files into Java byte code in ".class" files
Question 5
Incorrect
Mark 0.00 out of 1.00
Question text
Which of the following is NOT a valid identifier in Java?
Select one:
a. p
b. Public
c. public
d. public23
e. PuBlIc_tWeNtY_3
Feedback
Your answer is incorrect.
"public" is a reserved word in Java and cannot be used as an identifier. See Section 2.2 of Eck
(2014).
The correct answer is: public
Self Quiz 2
Question 1
Correct
Mark 1.00 out of 1.00
Question text
, Assume "test" is a boolean variable. Which of the following expressions is equivalent to "test
== true"?
Select one:
a. test
b. !test
c. test = true
d. test.equals(true)
Feedback
Your answer is correct.
See Section 3.3.2 of Eck (2014).
The correct answer is: test
Question 2
Correct
Mark 1.00 out of 1.00
Question text
Which of the following keywords is useful for getting out of an infinite loop?
Select one:
a. break
b. continue
c. do
d. switch
e. while
Feedback
Your answer is correct.
See Section 3.3.3 of Eck (2014).
The correct answer is: break
Question 3
Correct
Mark 1.00 out of 1.00
Question text
Which of the following keywords is useful for processing lists of menu options?
And Answers | Updated Study Solutions
Student hint: Use an online compiler such as https://www.tutorialspoint.com/compile_java_online.php for testing most of the
code required output. Change class to public class.
Self Quiz 1
Question 1
Correct
Mark 1.00 out of 1.00
Question text
Which of the following should be used to compare the contents of two String objects in Java?
Select one:
a. =
b. ==
c. cmp
d. equals
e. ?
Feedback
Your answer is correct.
"=" is for assignment. "==" compares the memory locations of String objects, not their contents.
"cmp" is a command from Python, not Java. "?" Is the conditional operator. Use "s1.equals(s2)" to
compare the contents of String "s1" and "s2". See Section 2.3.3 of Eck (2014).
The correct answer is: equals
Question 2
Correct
Mark 1.00 out of 1.00
Question text
Consider the following line of Java code.
System.out.println("Hello, World!");
"System" is which of the following?
Select one:
,a. a class
b. a method (subroutine)
c. an object
d. a parameter
e. a statement
Feedback
Your answer is correct.
"System" is a built-in Java class with static member objects, like "out". See Section 2.3.1 of Eck
(2014).
The correct answer is: a class
Question 3
Correct
Mark 1.00 out of 1.00
Question text
Consider the following line of Java code.
System.out.println("Hello, World!");
The full line of code is which of the following?
Select one:
a. a class
b. a method (subroutine)
c. an object
d. a parameter
e. a statement
Feedback
Your answer is correct.
See Section 2.1 of Eck (2014).
The correct answer is: a statement
Question 4
Correct
Mark 1.00 out of 1.00
Question text
,What does a Java compiler do?
Select one:
a. Runs Java programs
b. Translates byte code in ".class" files into machine language
c. Translates source code in ".class" files into machine language
d. Translates source code in ".java" files into Java byte code in ".class" files
e. Translates source code in ".java" files into machine language
Feedback
Your answer is correct.
The correct answer is: Translates source code in ".java" files into Java byte code in ".class" files
Question 5
Incorrect
Mark 0.00 out of 1.00
Question text
Which of the following is NOT a valid identifier in Java?
Select one:
a. p
b. Public
c. public
d. public23
e. PuBlIc_tWeNtY_3
Feedback
Your answer is incorrect.
"public" is a reserved word in Java and cannot be used as an identifier. See Section 2.2 of Eck
(2014).
The correct answer is: public
Self Quiz 2
Question 1
Correct
Mark 1.00 out of 1.00
Question text
, Assume "test" is a boolean variable. Which of the following expressions is equivalent to "test
== true"?
Select one:
a. test
b. !test
c. test = true
d. test.equals(true)
Feedback
Your answer is correct.
See Section 3.3.2 of Eck (2014).
The correct answer is: test
Question 2
Correct
Mark 1.00 out of 1.00
Question text
Which of the following keywords is useful for getting out of an infinite loop?
Select one:
a. break
b. continue
c. do
d. switch
e. while
Feedback
Your answer is correct.
See Section 3.3.3 of Eck (2014).
The correct answer is: break
Question 3
Correct
Mark 1.00 out of 1.00
Question text
Which of the following keywords is useful for processing lists of menu options?