Semester Final Review
By Mickey Arnold
starstarstarstarstarstarstarstarstarstar
Last updated 10 months ago
130 Questions
1 point
1
Question 1
1.
What is the output by the code below? System.out.println( 3 + " " + 3 );
What is the output by the code below?
System.out.println( 3 + " " + 3 );
1 point
1
Question 2
2.
What is the ASCII value of a space?
What is the ASCII value of a space?
1 point
1
Question 3
3.
Which of the following would print one backslash on the screen if used in a print( ) or println( )?
Which of the following would print one backslash on the screen if used in a print( ) or println( )?
1 point
1
Question 4
4.
What is output by the following code? System.out.println(""+3+4+5);
What is output by the following code?
System.out.println(""+3+4+5);
1 point
1
Question 5
5.
What is the output by the code below?System.out.println("Hello ");System.out.print("people ");System.out.println("everywhere ");
What is the output by the code below?
System.out.println("Hello ");
System.out.print("people ");
System.out.println("everywhere ");
1 point
1
Question 6
6.
What is output by the following code? System.out.println(3+4+""+5*3);
What is output by the following code?
System.out.println(3+4+""+5*3);
1 point
1
Question 7
7.
What is the output by the code below?int num = 5;System.out.println("num");
What is the output by the code below?
int num = 5;
System.out.println("num");
1 point
1
Question 8
8.
What is the output by the code below?System.out.println( "\"9" );
What is the output by the code below?
System.out.println( "\"9" );
1 point
1
Question 9
9.
What is the output by the code below?char c = 65;System.out.println(c);
What is the output by the code below?
char c = 65;
System.out.println(c);
1 point
1
Question 10
10.
Which of the following lines correctly defines a char variable?
Which of the following lines correctly defines a char variable?
1 point
1
Question 11
11.
Which of the following can be used to comment code in Java?
Which of the following can be used to comment code in Java?
1 point
1
Question 12
12.
Which of the following is the tab character?
Which of the following is the tab character?
1 point
1
Question 13
13.
Which of the following lines correctly defines a String variable?
Which of the following lines correctly defines a String variable?
1 point
1
Question 14
14.
What of the following is not a legal reserved word for a java data type?
What of the following is not a legal reserved word for a java data type?
1 point
1
Question 15
15.
What is the output by the code below?int cost = 2.65;System.out.println("Price: " + cost);
What is the output by the code below?
int cost = 2.65;
System.out.println("Price: " + cost);
1 point
1
Question 16
16.
What is the output by the code below?String s = "aplus";System.out.println( s );
What is the output by the code below?
String s = "aplus";
System.out.println( s );
1 point
1
Question 17
17.
In Java, every program statement ends with a what ?
In Java, every program statement ends with a what ?
1 point
1
Question 18
18.
Every method must have an open and close what?
Every method must have an open and close what?
1 point
1
Question 19
19.
What is the output by the code below? System.out.print( "ap\\lus" );
What is the output by the code below?
System.out.print( "ap\\lus" );
1 point
1
Question 20
20.
Which of the following is a 32 bit data type?
Which of the following is a 32 bit data type?
4 points
4
Question 21
21.
Which of the following Scanner methods can be used to read in 65535 ?
Which of the following Scanner methods can be used to read in 65535 ?
4 points
4
Question 22
22.
Which of the following Scanner methods can be used to read in a line of words?
Which of the following Scanner methods can be used to read in a line of words?
4 points
4
Question 23
23.
Which of the following Scanner methods can be used to read in the value “apluscompsciisthebest” ?
Which of the following Scanner methods can be used to read in the value “apluscompsciisthebest” ?
4 points
4
Question 24
24.
Given the following statement, var must be defined as which of the following types?var=keyboard.nextFloat();
Given the following statement, var must be defined as which of the following types?
var=keyboard.nextFloat();
4 points
4
Question 25
25.
Given the following statement, var must be defined as which of the following types?var=keyboard.nextLine();
Given the following statement, var must be defined as which of the following types?
var=keyboard.nextLine();
4 points
4
Question 26
26.
Which of the following Scanner methods can be used to read in a double?
Which of the following Scanner methods can be used to read in a double?
4 points
4
Question 27
27.
Given the following statement, var must be defined as which of the following types?var=keyboard.nextLong();
Given the following statement, var must be defined as which of the following types?
var=keyboard.nextLong();
4 points
4
Question 28
28.
Which of the following Scanner methods can be used to read in a short?
Which of the following Scanner methods can be used to read in a short?
4 points
4
Question 29
29.
Which of the following is the Java class used for input?
Which of the following is the Java class used for input?
4 points
4
Question 30
30.
Which of the following is used in the Scanner constructor to connect to the keyboard?
Which of the following is used in the Scanner constructor to connect to the keyboard?
4 points
4
Question 31
31.
Which of the following Scanner methods can be used to read in a String?
Which of the following Scanner methods can be used to read in a String?
4 points
4
Question 32
32.
Which of the following Scanner methods can be used to read in an integer?
Which of the following Scanner methods can be used to read in an integer?
4 points
4
Question 33
33.
Which of the following Scanner methods can be used to read in a byte?
Which of the following Scanner methods can be used to read in a byte?
4 points
4
Question 34
34.
Which of the following Scanner methods can be used to read in the value”apluscompsci is the best” ?
Which of the following Scanner methods can be used to read in the value
”apluscompsci is the best” ?
4 points
4
Question 35
35.
Which of the following would correctly define and instantiate a Scanner?
Which of the following would correctly define and instantiate a Scanner?
4 points
4
Question 36
36.
Which of the following Scanner methods can be used to read in a long?
Which of the following Scanner methods can be used to read in a long?
4 points
4
Question 37
37.
Given the following statement, var must be defined as which of the following types?var=keyboard.next();
Given the following statement, var must be defined as which of the following types?
var=keyboard.next();
4 points
4
Question 38
38.
Which of the following Scanner methods can be used to read in 511.278 ?
Which of the following Scanner methods can be used to read in 511.278 ?
4 points
4
Question 39
39.
Given the following statement, var must be defined as which of the following types?var=keyboard.nextByte();
Given the following statement, var must be defined as which of the following types?
var=keyboard.nextByte();
4 points
4
Question 40
40.
Given the following statement, var must be defined as which of the following types?var=keyboard.nextDouble();
Given the following statement, var must be defined as which of the following types?
var=keyboard.nextDouble();
1 point
1
Question 41
41.
What is output by the code below?double x = .5 + .5;System.out.print(x);
What is output by the code below?
double x = .5 + .5;
System.out.print(x);
1 point
1
Question 42
42.
What is output by the code below?int x = 1;x *= 5;System.out.print(x);
What is output by the code below?
int x = 1;
x *= 5;
System.out.print(x);
1 point
1
Question 43
43.
What is output by the code below?System.out.print( 4 - 3 );
What is output by the code below?
System.out.print( 4 - 3 );
1 point
1
Question 44
44.
What is output by the code below?System.out.print(4 % 3);
What is output by the code below?
System.out.print(4 % 3);
1 point
1
Question 45
45.
What is output by the code below?System.out.print( (int)9.6 );
What is output by the code below?
System.out.print( (int)9.6 );
1 point
1
Question 46
46.
What is output by the code below?int x = 12,y = 20;int z = x + y;double a = z;System.out.print(a);
What is output by the code below?
int x = 12,
y = 20;
int z = x + y;
double a = z;
System.out.print(a);
1 point
1
Question 47
47.
What is output by the code below?System.out.println( 7 / 0);
What is output by the code below?
System.out.println( 7 / 0);
4 points
4
Question 48
48.
What is output by the code below?
System.out.println( Math.floor(9.567) );
What is output by the code below?
System.out.println( Math.floor(9.567) );
4 points
4
Question 49
49.
What is output by the code below?
System.out.println( Math.ceil(7.23) );
What is output by the code below?
System.out.println( Math.ceil(7.23) );
4 points
4
Question 50
50.
What is output by the code below?System.out.println( Math.pow(6,2) );
What is output by the code below?
System.out.println( Math.pow(6,2) );
4 points
4
Question 51
51.
What is output by the code below?
System.out.println( (int)Math.pow( Math.sqrt(60),2) );
What is output by the code below?
System.out.println( (int)Math.pow( Math.sqrt(60),2) );
4 points
4
Question 52
52.
What is output by the code below?System.out.println( Math.pow( Math.sqrt(25),2) );
What is output by the code below?
System.out.println( Math.pow( Math.sqrt(25),2) );
4 points
4
Question 53
53.
What is output by the code below?System.out.println( Math.floor(6.7) );
What is output by the code below?
System.out.println( Math.floor(6.7) );
4 points
4
Question 54
54.
What is output by the code below?System.out.println( Math.max(26,18) );
What is output by the code below?
System.out.println( Math.max(26,18) );
4 points
4
Question 55
55.
What is output by the code below?System.out.println( Math.min(36,8) );
What is output by the code below?
System.out.println( Math.min(36,8) );
4 points
4
Question 56
56.
What is output by the code below?System.out.println( Math.sqrt(64) );
What is output by the code below?
System.out.println( Math.sqrt(64) );
4 points
4
Question 57
57.
What is output by the code below?public class Fun{ public int times(int num1, int num2) { return num1 * num2; }}Fun aplus = new Fun();System.out.println( aplus.times( 8, 6 ) );
What is output by the code below?
public class Fun
{
public int times(int num1, int num2)
{
return num1 * num2;
}
}
Fun aplus = new Fun();
System.out.println( aplus.times( 8, 6 ) );
4 points
4
Question 58
58.
What is output by the code below?public class Fun{ public int times(int num1, int num2) { return num1 + num2; }}Fun aplus = new Fun();System.out.println( aplus.times( 23, 13 ) );
What is output by the code below?
public class Fun
{
public int times(int num1, int num2)
{
return num1 + num2;
}
}
Fun aplus = new Fun();
System.out.println( aplus.times( 23, 13 ) );
4 points
4
Question 59
59.
What is output by the code below?public class Fun2{ public static int times(int num1, int num2) { return num1 * num2; }}System.out.println( Fun2.times(6 , 7) );
What is output by the code below?
public class Fun2
{
public static int times(int num1, int num2)
{
return num1 * num2;
}
}
System.out.println( Fun2.times(6 , 7) );
4 points
4
Question 60
60.
What is output by the code below?public class Fun2{ public static int times(int num1, int num2) { return num1 + num2; }}System.out.println( Fun2.times(5 , 5) );
What is output by the code below?
public class Fun2
{
public static int times(int num1, int num2)
{
return num1 + num2;
}
}
System.out.println( Fun2.times(5 , 5) );
4 points
4
Question 61
61.
How many methods does Bird contain?public class Bird{ public void speak() { out.println("chirp-chirp"); } public void sayName() { out.println("baby bird"); }}
How many methods does Bird contain?
public class Bird
{
public void speak()
{
out.println("chirp-chirp");
}
public void sayName()
{
out.println("baby bird");
}
}
4 points
4
Question 62
62.
How many return methods does Bird contain?public class Bird{ public void speak() { out.println("chirp-chirp"); } public void sayName() { out.println("baby bird"); }}
How many return methods does Bird contain?
public class Bird
{
public void speak()
{
out.println("chirp-chirp");
}
public void sayName()
{
out.println("baby bird");
}
}
4 points
4
Question 63
63.
What is output by the code below?public class Test{ public void go() { out.print("A"); } public void fun() { out.print("B"); }}Test x = new Test();x.go();
What is output by the code below?
public class Test
{
public void go()
{
out.print("A");
}
public void fun()
{
out.print("B");
}
}
Test x = new Test();
x.go();
4 points
4
Question 64
64.
What is output by the code below?public class Test{ public void go() { out.print("A"); } public void fun() { out.print("B"); }}Test x = new Test();x.go();x.go();x.go();
What is output by the code below?
public class Test
{
public void go()
{
out.print("A");
}
public void fun()
{
out.print("B");
}
}
Test x = new Test();
x.go();
x.go();
x.go();
4 points
4
Question 65
65.
What is output by the code below?public class Test{ public void go() { out.print("A"); fun(); } public void fun() { out.print("B"); }}Test x = new Test();x.fun();x.go();
What is output by the code below?
public class Test
{
public void go()
{
out.print("A");
fun();
}
public void fun()
{
out.print("B");
}
}
Test x = new Test();
x.fun();
x.go();
4 points
4
Question 66
66.
What is output by the code below?public class Test{ public void go() { out.print("A"); } public void fun() { out.print("B"); go(); }}Test x = new Test();x.go();x.fun();x.fun();
What is output by the code below?
public class Test
{
public void go()
{
out.print("A");
}
public void fun()
{
out.print("B");
go();
}
}
Test x = new Test();
x.go();
x.fun();
x.fun();
4 points
4
Question 67
67.
What is output by the code below?public class Test{ public void go() { out.print("A"); stop(); } public void fun() { out.print("B"); go(); } public void stop() { out.print("C"); }}Test x = new Test();x.fun();
What is output by the code below?
public class Test
{
public void go()
{
out.print("A");
stop();
}
public void fun()
{
out.print("B");
go();
}
public void stop()
{
out.print("C");
}
}
Test x = new Test();
x.fun();
2.5 points
2.5
Question 68
68.
What is output by the code below?
String s = "apluscompsci";System.out.println( s.substring(4,5) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring(4,5) );
2.5 points
2.5
Question 69
69.
What is output by the code below?
String s = "apluscompsci";System.out.println( s.substring( s.length()-1 ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring( s.length()-1 ) );
2.5 points
2.5
Question 70
70.
What is output by the code below?
String s = "apluscompsci";System.out.println( s.charAt( s.length()-3 ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.charAt( s.length()-3 ) );
2.5 points
2.5
Question 71
71.
What is output by the code below?
String s = "apluscompsci";System.out.println( s.charAt(0) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.charAt(0) );
2.5 points
2.5
Question 72
72.
What is output by the code below?
String s = "apluscompsci";System.out.println( s.charAt(5) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.charAt(5) );
2.5 points
2.5
Question 73
73.
What is output by the code below?
String s = "apluscompsci";System.out.println( s.indexOf( "s" ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.indexOf( "s" ) );
2.5 points
2.5
Question 74
74.
What is output by the code below?
String s = "apluscompsci";System.out.println( s.indexOf( "apluscomp" ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.indexOf( "apluscomp" ) );
2.5 points
2.5
Question 75
75.
What is output by the code below?
String s = "ishouldofstudied";System.out.println( s.length() );
What is output by the code below?
String s = "ishouldofstudied";
System.out.println( s.length() );
2.5 points
2.5
Question 76
76.
What is output by the code below?
String s = "apluscompsci";System.out.println( s.substring( 6 ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring( 6 ) );
2.5 points
2.5
Question 77
77.
What is output by the code below?
String s = "apluscompsci";System.out.println( s.indexOf( "b" ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.indexOf( "b" ) );
2.5 points
2.5
Question 78
78.
What is output by the code below?
String s = "apluscompsci";int x = s.indexOf( "c" );System.out.println( s.substring( x ) );
What is output by the code below?
String s = "apluscompsci";
int x = s.indexOf( "c" );
System.out.println( s.substring( x ) );
2.5 points
2.5
Question 79
79.
What is output by the code below?
int x = "alligator".length() - "crocodile".length();System.out.println( x );
What is output by the code below?
int x = "alligator".length() - "crocodile".length();
System.out.println( x );
2.5 points
2.5
Question 80
80.
What is output by the code below?
int x = "crocodile".length() - "croc".length();System.out.println( x );
What is output by the code below?
int x = "crocodile".length() - "croc".length();
System.out.println( x );
2.5 points
2.5
Question 81
81.
What is output by the code below?
String s = "apluscompsci";System.out.println( s.substring(0,2) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring(0,2) );
2.5 points
2.5
Question 82
82.
What is output by the code below?
String s = "apluscompsci";int x = 3;System.out.println( s.substring(x,x+1) );
What is output by the code below?
String s = "apluscompsci";
int x = 3;
System.out.println( s.substring(x,x+1) );
2.5 points
2.5
Question 83
83.
What is output by the code below?
String s = "dog";String r = "dog ";System.out.println( s.equals( r ) );
What is output by the code below?
String s = "dog";
String r = "dog ";
System.out.println( s.equals( r ) );
2.5 points
2.5
Question 84
84.
What is output by the code below?
String s = "dog ";String r = new String("dog");System.out.println( s.equals( r ) );
What is output by the code below?
String s = "dog ";
String r = new String("dog");
System.out.println( s.equals( r ) );
2.5 points
2.5
Question 85
85.
What is output by the code below?
String s = "dog";String r = new String("dog");System.out.println( s != r );
What is output by the code below?
String s = "dog";
String r = new String("dog");
System.out.println( s != r );
2.5 points
2.5
Question 86
86.
What is output by the code below?
String s = "dog";String r = "dog";r = s;s = null;System.out.println( r );
What is output by the code below?
String s = "dog";
String r = "dog";
r = s;
s = null;
System.out.println( r );
2.5 points
2.5
Question 87
87.
What is output by the code below?
String s = "dog";String r = s;s = null;System.out.println( s );
What is output by the code below?
String s = "dog";
String r = s;
s = null;
System.out.println( s );
2.5 points
2.5
Question 88
88.
What is output by the code below?
String s = "Big dog";String r = "A dog";System.out.println( s.compareTo(r) );
What is output by the code below?
String s = "Big dog";
String r = "A dog";
System.out.println( s.compareTo(r) );
2.5 points
2.5
Question 89
89.
What is output by the code below?
String s = "dog";String r = "cog";System.out.println( r.compareTo(s) );
What is output by the code below?
String s = "dog";
String r = "cog";
System.out.println( r.compareTo(s) );
2.5 points
2.5
Question 90
90.
What is output by the code below?
String s = "dodge";String r = "cloths";System.out.println( s.compareTo(r) );
What is output by the code below?
String s = "dodge";
String r = "cloths";
System.out.println( s.compareTo(r) );
2.5 points
2.5
Question 91
91.
What is output by the code below?
String s = "bob";String r = "bod";System.out.println( s.compareTo(r) );
What is output by the code below?
String s = "bob";
String r = "bod";
System.out.println( s.compareTo(r) );
2.5 points
2.5
Question 92
92.
What is output by the code below?
String s = 12;int x = Integer.parseInt( s );System.out.println( x + 3 );
What is output by the code below?
String s = 12;
int x = Integer.parseInt( s );
System.out.println( x + 3 );
2.5 points
2.5
Question 93
93.
What is output by the code below?
String s = "12.7";Double x = Double.parseDouble( s );System.out.println( x + 3 );
What is output by the code below?
String s = "12.7";
Double x = Double.parseDouble( s );
System.out.println( x + 3 );
2.5 points
2.5
Question 94
94.
What is output by the code below?
String s = "12.7";double x = Double.parseDouble( s );System.out.println( x + 3 );
What is output by the code below?
String s = "12.7";
double x = Double.parseDouble( s );
System.out.println( x + 3 );
2.5 points
2.5
Question 95
95.
What is output by the code below?
String s = "12";int x = Integer.parseInt( s );System.out.println( s + x + 3 );
What is output by the code below?
String s = "12";
int x = Integer.parseInt( s );
System.out.println( s + x + 3 );
2.5 points
2.5
Question 96
96.
What is output by the code below?
System.out.println( "12" + 9 + 3 );
What is output by the code below?
System.out.println( "12" + 9 + 3 );
2.5 points
2.5
Question 97
97.
What is returned by the call myst("aplus","aplus")?public boolean myst(String a, String b){ return a.equals( b );}
What is returned by the call myst("aplus","aplus")?
public boolean myst(String a, String b)
{
return a.equals( b );
}
2.5 points
2.5
Question 98
98.
What is returned by the call myst("aplus","aplus")?public boolean myst(String a, String b){ return a == b;}
What is returned by the call myst("aplus","aplus")?
public boolean myst(String a, String b)
{
return a == b;
}
2.5 points
2.5
Question 99
99.
What is returned by the call myst("ana","banana")?public boolean myst(String a, String b){ return b.lastIndexOf(a)!=b.indexOf(a);}
What is returned by the call myst("ana","banana")?
public boolean myst(String a, String b)
{
return b.lastIndexOf(a)!=b.indexOf(a);
}
2.5 points
2.5
Question 100
100.
What is the purpose of myst?public boolean myst(String a, String b){ return b.lastIndexOf(a)!=b.indexOf(a);}
What is the purpose of myst?
public boolean myst(String a, String b)
{
return b.lastIndexOf(a)!=b.indexOf(a);
}
8.75 points
8.75
Question 101
101.
What is returned by the call go(60,78)?public static String go(int x, int z){ String s = "xyz"; if(z > 60) { s += "def"; } if(x <= 60) s += "ghi"; return s;}
What is returned by the call go(60,78)?
public static String go(int x, int z)
{
String s = "xyz";
if(z > 60)
{
s += "def";
}
if(x <= 60)
s += "ghi";
return s;
}
8.75 points
8.75
Question 102
102.
Consider the following code segment.
String s = "red ball";if(s.indexOf("a")>0) s = s + " zed";if(s.indexOf("z")>0) s = "alpha " + s;out.println(s);
What will be printed as a result of executing the code segment?
Consider the following code segment.
String s = "red ball";
if(s.indexOf("a")>0)
s = s + " zed";
if(s.indexOf("z")>0)
s = "alpha " + s;
out.println(s);
What will be printed as a result of executing the code segment?
8.75 points
8.75
Question 103
103.
Consider the following code segment.
String s = "abac-adae-bfbg-bhbi";int index = s.indexOf("b");if(index > 0) out.println(s.substring(index));
What will be printed as a result of executing the code segment?
Consider the following code segment.
String s = "abac-adae-bfbg-bhbi";
int index = s.indexOf("b");
if(index > 0)
out.println(s.substring(index));
What will be printed as a result of executing the code segment?
8.75 points
8.75
Question 104
104.
What is returned by the call go(7) ?public static int go( int a ){ int ans = 0; if(a>=7) { ans += 1; } ans += 2; return ans;}
What is returned by the call go(7) ?
public static int go( int a )
{
int ans = 0;
if(a>=7)
{
ans += 1;
}
ans += 2;
return ans;
}
8.75 points
8.75
Question 105
105.
What is output by the code below?String a = "1";String b = new String("1");if( a == b ){ System.out.print( "up" );}if( a.equals(b) ){ System.out.print( "on" );}System.out.print( "at" );
What is output by the code below?
String a = "1";
String b = new String("1");
if( a == b )
{
System.out.print( "up" );
}
if( a.equals(b) )
{
System.out.print( "on" );
}
System.out.print( "at" );
8.75 points
8.75
Question 106
106.
Consider the following code segment.double x = 19.8;int y = 0;if( x > 5 ) y += 5;if( x > 10 ) y += 10;if( x > 15 ) y += 15;out.print( y );What will be printed as a result of executing the code segment?
Consider the following code segment.
double x = 19.8;
int y = 0;
if( x > 5 )
y += 5;
if( x > 10 )
y += 10;
if( x > 15 )
y += 15;
out.print( y );
What will be printed as a result of executing the code segment?
8.75 points
8.75
Question 107
107.
Consider the following code segment.String s = "even";if(s.indexOf("a")>0) s = s + " zed";if(s.indexOf("v")>0) s = "alpha " + s;out.println(s);What will be printed as a result of executing the code segment?
Consider the following code segment.
String s = "even";
if(s.indexOf("a")>0)
s = s + " zed";
if(s.indexOf("v")>0)
s = "alpha " + s;
out.println(s);
What will be printed as a result of executing the code segment?
8.75 points
8.75
Question 108
108.
Consider the following code segment.String s = "apple";if(s.indexOf("a")>0) s = s + " zed";if(s.indexOf("l")>0) s = "alpha " + s;out.println(s);
Consider the following code segment.
String s = "apple";
if(s.indexOf("a")>0)
s = s + " zed";
if(s.indexOf("l")>0)
s = "alpha " + s;
out.println(s);
1 point
1
Question 109
109.
What is output by the code below?int b = 100;if( b > 100) out.print("go");else if( b > 90) out.print("it");else out.print("up");out.print("on");
What is output by the code below?
int b = 100;
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 110
110.
What is output by the code below?int a = 75, b = 100;if( a > 90) if( b > 100) out.print("go"); else if( b > 90) out.print("it"); else out.print("up");out.print("on");
What is output by the code below?
int a = 75, b = 100;
if( a > 90)
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 111
111.
What is output by the code below?int a = 105, b = 120;if( a > 90) if( b > 100) out.print("go"); else if( b > 90) out.print("it"); else out.print("up");out.print("on");
What is output by the code below?
int a = 105, b = 120;
if( a > 90)
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 112
112.
What is output by the code below?int a = 105, b = 40;if( a > 90) if( b > 100) out.print("go"); else if( b > 90) out.print("it"); else out.print("up");out.print("on");
What is output by the code below?
int a = 105, b = 40;
if( a > 90)
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 113
113.
What values will be stored in c and d after execution of the following program segment?int c = 5, d = 10;if(d>c){ if(c > 50) c /= 2; else c = d-c; d = d/5;}else{ c = c/2; d = d/2+3;}
What values will be stored in c and d after execution of the following program segment?
int c = 5, d = 10;
if(d>c){
if(c > 50)
c /= 2;
else
c = d-c;
d = d/5;
}
else{
c = c/2;
d = d/2+3;
}
1 point
1
Question 114
114.
What values will be stored in c and d after execution of the following program segment?int c = 12, d = 3;if(d>c){ if(c > 50) c /= 2; else c = d-c; d = d/5;}else{ c = c/2; d = d/2+3;}
What values will be stored in c and d after execution of the following program segment?
int c = 12, d = 3;
if(d>c){
if(c > 50)
c /= 2;
else
c = d-c;
d = d/5;
}
else{
c = c/2;
d = d/2+3;
}
1 point
1
Question 115
115.
What is output by the code below?
int j = 11/2;switch(j){ case 5:j++;break; case 6:j++;break; case 7:j++;break;}System.out.println(j);
What is output by the code below?
int j = 11/2;
switch(j)
{
case 5:j++;break;
case 6:j++;break;
case 7:j++;break;
}
System.out.println(j);
1 point
1
Question 116
116.
What is output by the code below?int x= 11;switch( x ){ case 11 : System.out.print("it"); case 21 : System.out.print("go"); case 98 : System.out.print("up"); break;}
What is output by the code below?
int x= 11;
switch( x )
{
case 11 : System.out.print("it");
case 21 : System.out.print("go");
case 98 : System.out.print("up"); break;
}
1 point
1
Question 117
117.
What is output by the code below?
int b = 110;if( b > 100) out.print("go");else if( b > 90) out.print("it");else out.print("up");out.print("on");
What is output by the code below?
int b = 110;
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 118
118.
What is output by the code below?int b = -5;if( b > 100) out.print("go");else if( b > 90) out.print("it");else out.print("up");out.print("on");
What is output by the code below?
int b = -5;
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 119
119.
What is output by the code below?
for(int i=0; i<=10; i=i+2) out.print(i);
What is output by the code below?
for(int i=0; i<=10; i=i+2)
out.print(i);
1 point
1
Question 120
120.
What is output by the code below?for(int i=5; i<20; i=i+3) out.print(i);
What is output by the code below?
for(int i=5; i<20; i=i+3)
out.print(i);
1 point
1
Question 121
121.
What is output by the code below?for(int i=15; i>2; i=i-2) System.out.print(i);
What is output by the code below?
for(int i=15; i>2; i=i-2)
System.out.print(i);
1 point
1
Question 122
122.
What is output by the code below?int ans = 0;for(int i=10; i>-1; i=i-2) ans += i;System.out.print( ans );
What is output by the code below?
int ans = 0;
for(int i=10; i>-1; i=i-2)
ans += i;
System.out.print( ans );
1 point
1
Question 123
123.
What is output by the code below?int ans = 0;for(int i=0; i<12; i=i+3) ans += i;System.out.print( ans );
What is output by the code below?
int ans = 0;
for(int i=0; i<12; i=i+3)
ans += i;
System.out.print( ans );
1 point
1
Question 124
124.
What is output by the code below?int ans = 0;for(int i=0; i<20; i=i+3) if( i % 2 == 0 ) ans += i;System.out.print( ans );
What is output by the code below?
int ans = 0;
for(int i=0; i<20; i=i+3)
if( i % 2 == 0 )
ans += i;
System.out.print( ans );
1 point
1
Question 125
125.
What is returned by the call go( 7 ) ?public static String go( int x){ String s = ""; for(int n = x; n > 0; n = n - 2) s = s + n + " "; return s;}
What is returned by the call go( 7 ) ?
public static String go( int x)
{
String s = "";
for(int n = x; n > 0; n = n - 2)
s = s + n + " ";
return s;
}
1 point
1
Question 126
126.
What is returned by the call go( 17 ) ?public static int go( int x){ int val = 0; for(int n = 1; n < x; n = n + 4) val = val + n; return val;}
What is returned by the call go( 17 ) ?
public static int go( int x)
{
int val = 0;
for(int n = 1; n < x; n = n + 4)
val = val + n;
return val;
}
1 point
1
Question 127
127.
What is returned by the call go( 7, 12 ) ?public static int go( int x, int y){ int cnt = 0; for(int n = x; n < y; n = n + 1) if(n % 2 != 0 ) cnt++; return cnt;}
What is returned by the call go( 7, 12 ) ?
public static int go( int x, int y)
{
int cnt = 0;
for(int n = x; n < y; n = n + 1)
if(n % 2 != 0 )
cnt++;
return cnt;
}
1 point
1
Question 128
128.
int tot = 0;for( int i=2; i<17; i++ ) { tot = tot + i;}out.println( tot );
int tot = 0;
for( int i=2; i<17; i++ ) {
tot = tot + i;
}
out.println( tot );
1 point
1
Question 129
129.
int count=0;for(int j=4; j<23; j++) { if(j%2==1) count++;}out.println( count );
int count=0;
for(int j=4; j<23; j++) {
if(j%2==1)
count++;
}
out.println( count );
1 point
1
Question 130
130.
int sum=0;for(int m=5; m<18; m++) { if(m%2!=1) sum=sum+m;}out.println(sum);
int sum=0;
for(int m=5; m<18; m++) {
if(m%2!=1)
sum=sum+m;
}
out.println(sum);