Prog 3112
Prog 3112
Question 1
Correct
System.out.println("too cold");
else
System.out.println("just right");
a. just right
c. too cold
d. too hot
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 1/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 2
Correct
switch(q) {
case 1:
System.out.println("apple");
break;
case 2:
System.out.println("orange");
break;
case 3:
System.out.println("banana");
break;
case 4:
System.out.println("pear");
case 5:
System.out.println("grapes");
default:
System.out.println("kiwi");
Which of the following values for q will result in kiwi being included in the output?
b. 3.
c. 1.
d. 2.
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 2/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 3
Correct
int y = x = x + 1;
a. y is 0.
b. The program has a compile error since x is redeclared in the statement int y = x = x + 1.
Question 4
Correct
What is the result value of c at the end of the following code segment?
int c = 8;
c++;
++c;
c %= 5;
b. 0.
c. 3.
d. 1.
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 3/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 5
Correct
b. if (grade != sentinelValue)
d. ! if (grade == sentinelValue)
Question 6
Correct
Which of the following languages is used primarily for scientific and engineering applications?
a. Basic.
b. COBOL.
c. Fortran.
d. Pascal.
Question 7
Correct
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 4/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 8
Correct
Which of the following statements does not alter the value stored in a memory location?
a. int a;
b. width = Integer.parseInt(input);
c. number = 12;
d. y = y + 2;
Question 9
Correct
a. c = 3;
b. val += 3;
c. val = val + 1;
val = val + 1;
val = val + 1;
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 5/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 10
Incorrect
if (temp == 80) {
Question 11
Correct
To exit out of a loop completely, and resume the flow of control at the next statement after the loop, use a _______.
a. continue statement.
b. break statement.
c. return statement.
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 6/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 12
Correct
Which of the following is not one of the three general types of computer languages?
a. Machine languages.
b. Spoken languages.
c. High-Level languages.
d. Assembly languages.
Question 13
Correct
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 7/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 14
Correct
if (even) {
System.out.println("It is even!");
a. The code is wrong. You should replace if (even) with if (even = true).
d. The code is wrong. You should replace if (even) with if (even == true).
Question 15
Correct
a. /
b. =
c. %=
d. ?:
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 8/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 16
Correct
A key part of enabling the JVM to locate and call method main to begin the app’s execution is the ________ keyword, which indicates
that main can be called without first creating an object of the class in which the method is declared.
a. private
b. public
c. stable
d. static
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 9/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 17
Incorrect
Segment A
int q = 5;
switch(q) {
case 1:
System.out.println(1);
case 2:
System.out.println(2);
case 3:
System.out.println(3);
case 4:
System.out.println(4);
case 5:
System.out.println(5);
default:
System.out.println("default");
Segment B
q = 4;
switch(q) {
case 1:
System.out.println(1);
case 2:
System.out.println(2);
case 3:
System.out.println(3);
case 4:
System.out.println(4);
case 5:
System.out.println(5);
default:
System.out.println("default");
default
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 10/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
5
default
45 default
Question 18
Correct
The format specifier ________ is used to output values of type float or double.
a. %r
b. %fd
c. %f
d. %d
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 11/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 19
Correct
a. Semicolon ;
b. Braces {}
c. Colon :
b. Parentheses ()
Question 20
Correct
a. const
b. constant
c. static
d. final
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 12/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 21
Correct
If a class does not define constructors, the compiler provides a default constructor with no parameters, and the class’s instance
variables are initialized to ________.
a. null
c. false
d. zero
Question 22
Correct
Question 23
Correct
a. true
b. false
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 13/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 24
Correct
counter = counter - 1;
a. 20.
b. 21.
c. 0.
d. 19.
Question 25
Correct
Types in Java are divided into two categories. The primitive types are boolean, byte, char, short, int, long, float and double. All other
types are ________ types.
a. source
b. static
c. reference
d. declared
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 14/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 26
Correct
// cool down
else {
// warm up
if (temp == 80) {
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 15/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 27
Correct
a. declared.
b. binary operators.
c. redundant.
d. implied.
Question 28
Correct
}
else if (income > 4000) {
c. no output
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 16/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 29
Correct
The software that contains the core components of the operating system is the ________.
a. core
c. kernel.
d. colonel.
Question 30
Correct
a. <
b. !=
c. =<
d. <<
e. <=
Question 31
Correct
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 17/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 32
Correct
a. ^=
b. <>
c. ==
d. !=
Question 33
Correct
a. method name
b. return type
d. number of parameters
Question 34
Correct
a. masked
b. private
c. secure
d. static
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 18/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 35
Correct
// cool down
}
else {
// warm up
temp = temp + (temp < 50 ? 30 : 20);
if (temp == 80) {
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 19/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 36
Correct
You must call most methods other than ________ explicitly to tell them to perform their tasks.
a. public methods
b. private methods
c. main
d. static methods
Question 37
Correct
a. Pseudocode is used to describe executable statements that will eventually be translated by the programmer into a program.
Question 38
Correct
To declare a method as static, place the keyword static before ________ in the method’s declaration.
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 20/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 39
Correct
a. has the same name and parameters, but a different return type as another method
b. has the same name and parameters as a method defined in another class
c. has the same name as another method, but different parameters (by number, types or order of the types)
d. has a different name than another method, but the same parameters
Question 40
Correct
a. %int
b. %s
c. %d
d. %n
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 21/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 41
Correct
int x = 3; int y = 4;
switch (x + 3) {
case 6: y = 0;
case 7: y = 1;
default: y += 1;
a. 0
b. 4
c. 1
d. 2
e. 3
Question 42
Correct
a. <=
b. =!
c. >
d. ==
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 22/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 43
Correct
a. same as value 0
b. a Boolean literal
c. same as value 1
d. a Java keyword
Question 44
Incorrect
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 23/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 45
Correct
What is the value of result after the following Java statements execute (assume all variables are of type int)?
a = 4;
b = 12;
c = 37;
d = 51;
result = d % a * c + a % b + a;
a. 119
b. 51
c. 127
d. 59
Question 46
Correct
a. Only within while or if statements within the method in which they were declared.
c. Only in that method between the line in which they were declared and the closing brace of that method.
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 24/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 47
Correct
Note that the Unicode for character A is 65. The expression "A" + 1 evaluates to ________.
a. A1
b. B
c. 66
d. Illegal expression
Question 48
Correct
a. parameterless
b. parameterized
c. constructor
d. destructor
Question 49
Correct
a. Variables.
b. Constants.
d. Expressions.
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 25/26
1/17/24, 10:54 AM SECOND QUARTER EXAM: Attempt review
Question 50
Correct
if (even = true) {
System.out.println("It is even");
Jump to...
https://shsexam.amaesonline.com/2312/mod/quiz/review.php?attempt=59474&cmid=268&showall=1 26/26