Multiple Choice Identify the
choice that best completes the statement or answers the question.
|
|
1.
|
public class Smith1 extends
JPanel implements ActionListener { Timer tm = new Timer(55,this);
int x1=20,y1=20,w1=100,h1=25; int velX = 1 ; int p2Vel =12
; int p1=10 ,p2=150; public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.BLACK);
g.drawLine(p1,p1,50,100);
g.setColor(Color.BLUE); g.fillOval(x1,y1,w1,h1);
int[] xcord =
{p1,p2,100,30}; int[] ycord = {p1,40,100,300};
g.fillPolygon(xcord,ycord,4);
g.setColor(Color.RED);
g.fillOval(x1,y1,w1,h1);
g.setColor(Color.GREEN); g.drawLine(p1,p1,50,100); tm.start();
//ANIMATION }//end paint
public void
actionPerformed(ActionEvent e) { if(p1<0 || p1>500) velX =
-velX ; if(p2<0 || p2>500) p2Vel= -p2Vel ;
if(x1<0|| x1>100) velX = -velX ;
if(y1<0||y1>100) velX = -velX ; y1 = y1 + velX ; x1 =
x1 + velX; p1 = p1 + velX ; p2 = p2 + p2Vel; repaint(); }//END
METHOD public static void main() { JFrame frame
= new JFrame("Created by L Kedigh"); frame.setSize(600, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new
Smith1(); panel.setBackground(Color.BLACK); frame.getContentPane().add(panel,
BorderLayout.CENTER); frame.setVisible(true); }//end main }//end
class
Which point is drawn in the polygon ?
a. | (p1,40) | b. | (100,300) | c. | (100,100) | d. | (100,400) | e. | None of
these | f. | Two of the four points listed above are in the
polygon. |
|
|
2.
|
For g.fillOval(x,y,w,h) and the method public void actionPerformed(ActionEvent
e) { w+=rnd.nextInt(3); repaint(); }//END METHOD
will cause
the graphic object to
a. | move up. | b. | move down. | c. | move
left. | d. | grow downward. | e. | grow upwards. | f. | grow to the
left. | g. | grow to the right. | h. | move right. |
|
|
3.
|
In the following loop  The
increment statement
a. | executes during every iteration at the bottom of the loop. | b. | executes one time at
the bottom of the loop. | c. | executes only in the first iteration at the top
of the loop. | d. | executes during every iteration at the top of the loop. | e. | None of
these. |
|
|
4.
|
What is the output? 
a. | 0 1 2 3 4 5
| b. | 1 3 5
| c. | 1 3 5 6
| d. | 1 2 3 4 5 6
| e. | Contains a syntax error, will not compile. | f. | None of the above. |
|
|
5.
|
What is the output? 
a. | 0 1 2 3 4 5
| b. | 1 2 3 4 5 6
| c. | 1 3 5
| d. | 1 3 5 6
| e. | Contains a syntax
error, will not compile. | f. | None of the
above. |
|
|
6.
|
What will printed out by the following
statement?
System.out.println(“Use a
\”\\\””);
a. | Use a
“\\” | b. | Use a “\” | c. | Use a
“\”” | d. | Use a \”\”” | e. | Use a
\”\\\” |
|
|
7.
|
If x is an int where x = 0, what will x be after
the following loop terminates? 
a. | 64 | b. | 100 | c. | 2 | d. | 128 | e. | None of the above,
this is an infinite loop |
|
|
8.
|
public class Questions { public static void
main(String[ ] args) { System.out.print("Here");
System.out.println("There " + "Everywhere");
System.out.println("But not" + "in Texas"); }//end main }//end
class
A reasonable comment for this program might be
a. | // a program that has three output
statements in it | b. | // a program that outputs the message // “Here There Everywhere But
not in Texas” | c. | // a program that demonstrates nothing at
all | d. | // a program that demonstrates the differences between print, // println
and how + works | e. | // a program that outputs a message about
Texas |
|
|
9.
|
For the following rectangle g.drawRect(120, 220, 200, 100);
The x coordinate is ?
|
|
10.
|
Given the following assignment statement, which of the following answers is true
regarding the order that the operators will be applied based on operator precedence?
a = (b + c) * d / e – f;
a. | +, -, *,
/ | b. | +, /, *,
- | c. | +, *, /,
- | d. | *, /, +,
- | e. | *, +, /,
- |
|
|
11.
|
What is output with the statement System.out.println(x+y);
if x and y are int values where x=10 and
y=5?
a. | x+y | b. | 15 | c. | 10
5 | d. | 105 | e. | An error since neither x nor y is a
String |
|
|
12.
|
What is the output?

a. | 0 1 2 3 4 5
| b. | 1 2 3 4 5
| c. | 1 2 3 4 5 6
| d. | 123456
| e. | Contains a syntax
error, will not compile. | f. | None of the
above. |
|
|
13.
|
Consider having three String variables a, b and c. The statement
c = a + b;
can also be achieved by doing
a. | c = a.plus(b); | b. | c = b.concat(a); | c. | c = (int) a + (int)
b; | d. | c = a.length( ) + b.length( ); | e. | c = a.concat(b); |
|
|
14.
|
For the following rectangle g.drawRect(220, 120, 200, 100);
The x coordinate is ?
|
|
15.
|
In the following call, what is the x-coordinate of
the line’s ending point?
drawLine(10, 20, 100,
200)
|
|
16.
|
For the following rectangle g.drawRect(120, 220, 200, 100);
The width is ?
|
|
17.
|
rectangle 1 : g.drawRect(20, 20, 200, 100); rectangle 2 : g.drawRect(150, 400, 200, 100);
Which is larger or takes up more space
(area)?
a. | both are the same size | b. | rectangle 1 | c. | you can not tell
from the information given. | d. | rectangle
2 |
|
|
18.
|
For the following code

What color is
the background?
a. | Red | b. | Blue | c. | Black | d. | White | e. | None of
these |
|
|
19.
|
What will be the result of the following assignment statement? Assume b =
5 and c = 10.
int a = b * (-c + 2) / 2;
|
|
|
|
|
20.
|
Which of the following line numbers contains a
variable declaration and initialization?
|
|
21.
|
Which of the following line numbers contains a
variable declaration only?
|
|
22.
|
Which of the following line numbers should NOT be
changed when adding IDOC to a program?
|
|
23.
|
Which of the following line numbers decrements a
variable by 1?
|
|
24.
|
Which of the following line numbers increments a
variable by 1?
|
|
25.
|
For the following rectangle g.drawRect(220, 120, 200, 100);
The y coordinate is ?
|
|
26.
|
For the following code

Which graphic
object is the largest?
a. | Rectangle | b. | String | c. | Oval | d. | Can’t be
determined. |
|
|
27.
|
What value will z have if we execute the following assignment
statement?
double z = 5 / 10;
a. | z will equal 0.0 | b. | z will equal 5.0 | c. | z will equal
0.05 | d. | z will equal 0.5 | e. | none of the above, a run-time error arises
because z is a double and 5 / 10 is an int |
|
|
28.
|
When the while loop exits, what will the variable a contain? 
a. | The count of all multple of 3. | b. | The sum of all multiples of
3. | c. | The sum of all the numbers entered. | d. | The sum of all multples of
5. | e. | The count of all numbers entered. | f. | The count of all multiples of
5. | g. | The number the user enters. |
|
|
29.
|
When the while loop exits, what will the variable b contain? 
a. | The sum of all the numbers entered. | b. | The sum of all multples of
5. | c. | The number the user enters. | d. | The count of all multple of
3. | e. | The sum of all multiples of 3. | f. | The count of all numbers
entered. | g. | The count of all multiples of 5. |
|
|
30.
|
public class Smith1 extends
JPanel implements ActionListener { Timer tm = new Timer(55,this);
int x1=20,y1=20,w1=100,h1=25; int velX = 1 ; int p2Vel =12
; int p1=10 ,p2=150; public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.BLACK);
g.drawLine(p1,p1,50,100);
g.setColor(Color.BLUE); g.fillOval(x1,y1,w1,h1);
int[] xcord =
{p1,p2,100,30}; int[] ycord = {p1,40,100,300};
g.fillPolygon(xcord,ycord,4);
g.setColor(Color.RED);
g.fillOval(x1,y1,w1,h1);
g.setColor(Color.GREEN); g.drawLine(p1,p1,50,100); tm.start();
//ANIMATION }//end paint
public void
actionPerformed(ActionEvent e) { if(p1<0 || p1>500) velX = -velX ;
if(p2<0 || p2>500) p2Vel= -p2Vel ; if(x1<0|| x1>100)
velX = -velX ; if(y1<0||y1>100) velX = -velX ; y1 = y1 + velX ; x1
= x1 + velX; p1 = p1 + velX ; p2 = p2 + p2Vel; repaint(); }//END METHOD
public static void main() { JFrame frame = new
JFrame("Created by L Kedigh"); frame.setSize(600, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new
Smith1(); panel.setBackground(Color.BLACK);
frame.getContentPane().add(panel, BorderLayout.CENTER); frame.setVisible(true);
}//end main }//end class
What is the third point in the
polygon?
a. | (p2,40) | b. | (100,100) | c. | (p1,p1) | d. | (30,300) | e. | None of
these | f. | Two of the four points listed above are in the
polygon. |
|
|
31.
|
For the following code:

Which graphic object is closest to the
bottom right hand corner of the output window?
a. | oval | b. | rectangle | c. | String | d. | None of
these |
|
|
32.
|
For the following code

What color is
the background?
a. | White | b. | Black | c. | Blue | d. | Red | e. | None of
these |
|
|
33.
|
Given the statement g.drawLine(0,500, 400, 20);
Which most closely represents shape and
direction of the line?
|
|
34.
|
What is the output? 
a. | 1 23 45
| b. | 12 34 56
| c. | 123456
| d. | 12 34 5
| e. | Contains a syntax error, will not compile. | f. | None of the above. |
|
|
35.
|
For the following rectangle g.drawRect(120, 200, 220, 100);
The width is ?
|
|
36.
|
For g.fillOval(x,y,w,h) and the method public void actionPerformed(ActionEvent
e) { y+=rnd.nextInt(3)+1; repaint(); }//END METHOD
will
cause the graphic object to
a. | grow to the left. | b. | grow downward. | c. | move
left. | d. | move up. | e. | grow right. | f. | move
right. | g. | grow upwards. | h. | move down. |
|
|
37.
|
Points in a two-dimensional system have ________
coordinates.
a. | x and y | b. | y and z | c. | a and
b | d. | x, y, and z |
|
|
38.
|
How many times will the following for loop iterate? 
a. | 3 | b. | 5 | c. | 6 | d. | 4 | e. | none of
these |
|
|
39.
|
In the following loop  The
statement i++;
a. | executes one time at the bottom of the loop. | b. | executes only in the
first iteration at the top of the loop. | c. | executes during every iteration at the bottom
of the loop. | d. | executes during every iteration at the top of the loop. | e. | None of
these. |
|
|
40.
|
rectangle 1 : g.drawRect(20, 20, 200, 100); rectangle 2 : g.drawRect(150, 400, 300, 10);
Which is larger or takes up more space
(area)?
a. | rectangle 2 | b. | you can not tell from the information given. | c. | both are the same size | d. | rectangle
1 |
|
|
41.
|
What will printed out by the following
statement?
System.out.println(“Use a
\”\\\”\””);
a. | Use a
\”\\\” | b. | Use a “\” | c. | Use a
“\”” | d. | Use a “\\” | e. | Use a
\”\”” |
|
|
42.
|
rectangle 1 : g.drawRect(20, 20, 200, 100); rectangle 2 : g.drawRect(150, 400, 300, 100);
Which is larger or takes up more space
(area)?
a. | rectangle 1 | b. | you can not tell from the information given. | c. | both are the same size | d. | rectangle
2 |
|
|
43.
|
In the following statement, 200 is the
____.
drawRect(20, 100, 200, 10)
a. | height | b. | width | c. | x-coordinate of
the upper-left corner | d. | y-coordinate of
the upper-left corner |
|
|
44.
|
When the while loop exits, what will the variable d contain? 
a. | The count of all multple of 3. | b. | The sum of all multples of
5. | c. | The sum of all the numbers entered. | d. | The count of all numbers
entered. | e. | The sum of all multiples of 3. | f. | The number the user enters. | g. | The count of all
multiples of 5. |
|
|
45.
|
Given the statement
g.drawLine(0, 0, 400, 200); Which most closely represents shape and direction of the
line?
|
|
46.
|
What does RGB stand for?
a. | Red/Green/Black | b. | Red/Gray/Blue | c. | Red/Gray/Black | d. | Red/Green/Blue |
|
|
47.
|
How many times will the following loop
iterate? 
a. | 1 time | b. | 11 times | c. | 9
times | d. | 0 times | e. | 10 times |
|
|
48.
|
For the following rectangle g.drawRect(120, 320, 200, 220);
The height is ?
|
|
49.
|
public class Smith1 extends
JPanel implements ActionListener //ANIMATION { Timer tm = new
Timer(55,this); int
x1=20,y1=20,w1=100,h1=25; int velX = 1 ; int p2Vel =12 ; int p1=10
,p2=150; public void paintComponent(Graphics g) { super.paintComponent(g);
g.setColor(Color.BLACK); g.drawLine(p1,p1,50,100);
g.setColor(Color.BLUE); g.fillOval(x1,y1,w1,h1);
int[] xcord =
{p1,p2,50,30}; int[] ycord = {p1,40,100,300}; g.fillPolygon(xcord,ycord,4);
g.setColor(Color.RED); g.fillOval(x1,y1,w1,h1);
g.setColor(Color.GREEN); g.drawLine(p1,p1,50,100); //End
of all the objects you draw tm.start(); //ANIMATION
}//end paint
public void actionPerformed(ActionEvent e) { if(p1<0 ||
p1>500) velX = -velX ; if(p2<0 ||
p2>500) p2Vel= -p2Vel ; if(x1<0||
x1>100) velX = -velX ;
if(y1<0||y1>100) velX = -velX ; y1 = y1 + velX ; x1 =
x1 + velX; p1 = p1 + velX ; p2 = p2 + p2Vel; repaint(); }//END
METHOD public static void main() { JFrame frame = new
JFrame("Created by L Kedigh"); frame.setSize(600, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new
Smith1(); panel.setBackground(Color.BLACK);
frame.getContentPane().add(panel, BorderLayout.CENTER);
frame.setVisible(true); }//end main }//end class
What
color is the polygon in the animation?
a. | Green | b. | Blue | c. | None of
these | d. | Black | e. | changes from green to blue, |
|
|
50.
|
Consider the following statement:
System.out.println("1 big bad wolf\t8 the 3 little pigs\n4
dinner\t2night");
This statement will output ___ lines of text
|
|
51.
|
What is the output?

a. | 12 34 5
| b. | 12 34 56
| c. | 1 23 45
| d. | 123456
| e. | Contains a syntax
error, will not compile. | f. | None of the
above.
|
|
|
52.
|
public class Smith1 extends
JPanel implements ActionListener { Timer tm = new Timer(55,this);
int x1=20,y1=20,w1=100,h1=25; int velX = 1 ; int p2Vel =12
; int p1=10 ,p2=150; public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.BLACK);
g.drawLine(p1,p1,50,100);
g.setColor(Color.BLUE); g.fillOval(x1,y1,w1,h1);
int[] xcord =
{p1,p2,50,30}; int[] ycord = {p1,40,100,300};
g.fillPolygon(xcord,ycord,4);
g.setColor(Color.RED);
g.fillOval(x1,y1,w1,h1);
g.setColor(Color.GREEN); g.drawLine(p1,p1,50,100); tm.start();
//ANIMATION }//end paint
public void
actionPerformed(ActionEvent e) { if(p1<0 || p1>500) velX = -velX ;
if(p2<0 || p2>500) p2Vel= -p2Vel ; if(x1<0|| x1>100)
velX = -velX ; if(y1<0||y1>100) velX = -velX ; y1 = y1 + velX ; x1
= x1 + velX; p1 = p1 + velX ; p2 = p2 + p2Vel; repaint(); }//END METHOD
public static void main() { JFrame frame = new
JFrame("Created by L Kedigh"); frame.setSize(600, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new
Smith1(); panel.setBackground(Color.BLACK);
frame.getContentPane().add(panel, BorderLayout.CENTER); frame.setVisible(true); }//end
main }//end class
Which point is drawn in the polygon ?
a. | (50,100) | b. | (100,400) | c. | (100,300) | d. | (p1,40) | e. | None of
these | f. | Two of the four points listed above are in the
polygon. |
|
|
53.
|
In the following loop  The control
statement
a. | None of these. | b. | executes one time at the bottom of the loop. | c. | executes only in the first iteration at the top of the
loop. | d. | executes during every iteration at the top of the
loop. | e. | executes during every iteration at the bottom of the
loop. |
|
|
54.
|
For the following code:

Which graphic object is closest to the bottom
right hand corner of the output window?
a. | oval | b. | rectangle | c. | String | d. | None of
these |
|
|
55.
|
In the following loop  The
statement int i=0;
a. | executes during every iteration at the top of the loop. | b. | None of
these. | c. | executes one time at the bottom of the loop. | d. | executes during
every iteration at the bottom of the loop. | e. | executes only in the first iteration at the top
of the loop. |
|
|
56.
|
For g.fillOval(x,y,w,h) and the method public void actionPerformed(ActionEvent
e) { x+=rnd.nextInt(3); repaint(); }//END METHOD
This will cause the graphic object to
a. | grow right. | b. | grow upwards. | c. | move
left. | d. | grow downward. | e. | move down. | f. | grow to the
left. | g. | move right. | h. | move up. |
|
|
57.
|
For the following code
 What color is the
rectangle?
a. | Red | b. | Black | c. | Green | d. | Blue | e. | White | f. | None of
these |
|
|
58.
|
How many times will the following for loop iterate? 
a. | 3 | b. | 6 | c. | 4 | d. | 5 | e. | none of
these |
|
|
59.
|
What will printed out by the following
statement?
System.out.println(“Use a
\\\”\\\”\””);
a. | Use a
“\” | b. | Use a \”\”” | c. | Use a “\\” | d. | Use a
“\”” | e. | Use a \”\\\” |
|
|
60.
|
What is output with the statement System.out.println(""+x+y);
if x and y are int values where
x=10 and y=5?
a. | x+y | b. | 105 | c. | 10
5 | d. | 15 | e. | An error since neither x nor y is a
String |
|
|
61.
|
For g.fillOval(x,y,w,h) and the method public void actionPerformed(ActionEvent
e) { w+=rnd.nextInt(3); h+=rnd.nextInt(6); repaint(); }//END
METHOD
will cause the graphic object to
a. | grow to the left and grow
upward | b. | move up. | c. | grow downward and move to the left. | d. | move down and move up. | e. | grow
upwards. | f. | move left and move down. | g. | move right and grow to the right. | h. | grow to the right and grow downward. |
|
|
62.
|
For the following rectangle g.drawRect(120, 220, 200, 100);
The y coordinate is ?
|
|
63.
|
The first two arguments of drawPolygon() are
____.
a. | floats | b. | doubles | c. | booleans | d. | integer
arrays |
|
|
64.
|
public class Questions { public static void
main(String[ ] args) {
System.out.print("Here"); System.out.println("There "
+ "Everywhere"); System.out.println("But not" +
"in Texas"); }//end main }//end class
The final println
command will output -
a. | "But notin
Texas" | b. | "But not
in Texas" | c. | "But
not+in Texas" | d. | "But not"
on one line and "in Texas" on the next line | e. | "But not + in
Texas" |
|
|
65.
|
For g.fillOval(x,y,w,h) and the method public void actionPerformed(ActionEvent
e) { y+= -(rnd.nextInt(3)); repaint(); }//END METHOD
will
cause the graphic object to
a. | grow downward. | b. | grow right. | c. | move
left. | d. | grow upwards. | e. | move right. | f. | move
up. | g. | move down. | h. | grow to the left. |
|
|
66.
|
How many arguments does drawRoundRect( )
take?
|
|
67.
|
What value will z have if we execute the following assignment
statement?
int z = 50 / 10.00;
a. | 50 | b. | 10 | c. | 5.0 | d. | 5 | e. | none of the above, a
error arises because z is an int and 50 / 10.00 is not |
|
|
68.
|
When the while loop exits, what will the variable d contain? 
a. | The sum of all the numbers entered. | b. | The count of all numbers
entered. | c. | The count of all multple of 3. | d. | The sum of all multples of
5. | e. | The count of all multiples of 5. | f. | The sum of all multiples of
3. | g. | The number the user enters. |
|
|
69.
|
For the following code:

Which is true about the green and blue graphic object?
a. | The green object is to the left of the blue
object. | b. | The green object is to the right of the blue
object. | c. | The green object covers the blue
object. | d. | The blue object covers the green
object. |
|
|
70.
|
public class Smith1 extends
JPanel implements ActionListener { Timer tm = new Timer(55,this);
int
x1=20,y1=20,w1=100,h1=25; int velX = 1 ; int p2Vel =12 ; int p1=10 ,p2=150; public
void paintComponent(Graphics g) { super.paintComponent(g);
g.setColor(Color.BLACK); g.drawLine(p1,p1,50,100);
g.setColor(Color.BLUE); g.fillOval(x1,y1,w1,h1);
int[] xcord =
{p1,p2,50,30}; int[] ycord = {p1,40,100,300}; g.fillPolygon(xcord,ycord,4);
g.setColor(Color.RED); g.fillOval(x1,y1,w1,h1);
g.setColor(Color.GREEN); g.drawLine(p1,p1,50,100);
tm.start(); //ANIMATION }//end paint
public void
actionPerformed(ActionEvent e) { if(p1<0 || p1>500) velX = -velX ;
if(p2<0 || p2>500) p2Vel= -p2Vel ; if(x1<0|| x1>100)
velX = -velX ; if(y1<0||y1>100) velX = -velX ; y1 = y1 + velX ; x1
= x1 + velX; p1 = p1 + velX ; p2 = p2 + p2Vel; repaint(); }//END METHOD
public static void main() { JFrame frame = new
JFrame("Created by L Kedigh"); frame.setSize(600, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new
Smith1(); panel.setBackground(Color.BLACK); frame.getContentPane().add(panel,
BorderLayout.CENTER); frame.setVisible(true); }//end main }//end
class
One of
the points in the polygon is ?
a. | (p1,p1) | b. | (100,50) | c. | (50,40) | d. | (p1,p2) | e. | None of
these | f. | Two of the four points listed above are in the
polygon. |
|
|
71.
|
Of the following types, which one cannot store a numeric value?
a. | int | b. | char | c. | double | d. | all of these can store numeric
values | e. | none of these can store numeric values |
|
|
72.
|
If g.fillOval(50,50,200,200) was changed to
g.fillOval(50,50,100,200)
the area of the oval would ______.
a. | get larger. | b. | not change. | c. | get
smaller. | d. | can’t be
determined. |
|
|
73.
|
For the following code:

How many graphic objects are generated?
|
|
74.
|
Given the following code, where x = 0, what is
the resulting value of x after the for-loop terminates? 
|
|
75.
|
In the statement g.drawLine(10, 10, 400, 200);
Which numbers represent the x coordinates
the two points?
a. | 400 and 200 | b. | 10 and 10 | c. | 10 and
400 | d. | 10 and 200 |
|
|
76.
|
In the following loop  The
statement i<19;
a. | executes during every iteration at the bottom of the loop. | b. | executes one time at
the bottom of the loop. | c. | executes only in the first iteration at the top
of the loop. | d. | executes during every iteration at the top of the loop. | e. | None of
these. |
|
|
77.
|
When the while loop exits, what will the variable c contain? 
a. | The sum of all multples of 5. | b. | The number the user enters. | c. | The sum of all the
numbers entered. | d. | The count of all multple of 3. | e. | The count of all multiples of
5. | f. | The sum of all multiples of 3. | g. | The count of all numbers
entered. |
|
|
78.
|
If you want to output the text "hi there", including the quote marks,
which of the following could do that?
a. | System.out.println(""hi
there""); | b. | none, it is not possible to output a quote mark
because it is used to mark the beginning and ending of the String to be output. | c. | System.out.println("\"hi there"); | d. | System.out.println("\"hi there\""); | e. | System.out.println("hi there"); |
|
|
79.
|
What is the output? 
a. | 1 2 3 4 5 6
| b. | 1 3 5
| c. | 0 1 2 3 4 5
| d. | 1 3 5 6
| e. | Contains a syntax error, will not compile. | f. | None of the above. |
|
|
|
|
|
80.
|
Which line number contains the statement that determines if the loop body is
executed?
a. | 7 | b. | 3 | c. | 5 | d. | 6 | e. | 10 | f. | None of these. |
|
|
81.
|
public class Questions { public static void
main(String[ ] args) {
System.out.print("Here"); System.out.println("There " +
"Everywhere"); System.out.println("But not" + "in
Texas"); }//end main }//end class
The program will print the word
"Here" and then print
a. | "There Everywhere" on the
same line as "Here" | b. | "ThereEverywhere" on the same line as
"Here" | c. | "There" on the line after "Here" and "Everywhere"
on the line after "There" | d. | "ThereEverywhere" on the line after
"Here" | e. | "There Everywhere" on the line after
"Here" |
|
|
82.
|
If you need to draw a solid rectangle, you use
____.
a. | fillRect() | b. | drawRectangle() | c. | drawRect() | d. | solidRect() |
|
|
83.
|
Given the statement g.drawLine(0,250, 400, 200);
Which most closely represents shape and
direction of the line?
|
|
84.
|
For the following code

What color is the
oval?
a. | Black | b. | White | c. | Red | d. | Blue | e. | Green | f. | None of
these |
|
|
85.
|
How many times will the following for loop iterate? 
a. | 4 | b. | 6 | c. | 5 | d. | 3 | e. | infinite
loop | f. | none of these |
|
|
86.
|
For g.fillOval(x,y,w,h) and the method public void actionPerformed(ActionEvent
e) { x+= -(rnd.nextInt(3)); repaint(); }//END METHOD
will
cause the graphic object to
a. | grow downward. | b. | grow to the left. | c. | move
right. | d. | grow right. | e. | move up. | f. | grow
upwards. | g. | move left. | h. | move down. |
|
|
87.
|
What will printed out by the following
statement?
System.out.println(“Use a
\\\”\\\\\\\””);
a. | Use a
\”\”” | b. | Use a \”\\\” | c. | Use a “\” | d. | Use a
“\”” | e. | Use a “\\” |
|
|
88.
|
Assume that x is a double that stores 0.362491. To output this value as
36%, you could use the NumberFormat class with
NumberFormat nf =
NumberFormat.getPercentInstance( );
Which of
the following statements then would output x as 36%?
a. | System.out.println(format(x)); | b. | System.out.println(nf.x); | c. | System.out.println(nf.format(x)); | d. | System.out.println(x); | e. | System.out.println(nf); |
|
|
89.
|
How many shades of red are there in the RGB color
scheme?
|
|
90.
|
If you want to store into the String name the value "George Bush", you
would use which statement?
a. | String name = new
String("George" + " " + "Bush"); | b. | String name = "George" + " " +
"Bush"; | c. | String name = new String("George
Bush"); | d. | String name = "George Bush"; | e. | Any of the above
would work |
|
|
91.
|
For the following code

What
color is the String?
a. | Blue | b. | Black | c. | White | d. | Red | e. | Green | f. | None of
these |
|
|
92.
|
How many times will the following for loop iterate? 
a. | 4 | b. | 5 | c. | 3 | d. | 6 | e. | none of
these |
|
|
93.
|
In the statement String major =
"Computer Science",
what is returned by major.charAt(1)?
a. | 'm' | b. | 'o' | c. | 'C' | d. | "Computer" | e. | "C" |
|
|
94.
|
For the following code:

How many graphic objects are
generated?
|
|
95.
|
For the following code:

Which graphic object is closest to the upper
left hand corner of the output window?
a. | rectangle | b. | String | c. | oval | d. | None of
these |
|
|
96.
|
In the following loop  The
initialization statement
a. | executes during every iteration at the top of the loop. | b. | executes during
every iteration at the bottom of the loop. | c. | executes only in the first iteration at the top
of the loop. | d. | executes one time at the bottom of the loop. | e. | None of
these. |
|
|
97.
|
Which of the following would return the last character of the String
x?
a. | x.charAt(x.length( )); | b. | x.charAt(length(x)); | c. | x.charAt(last); | d. | x.charAt(0); | e. | x.charAt(x.length(
)-1); |
|
|
98.
|
What will printed out by the following
statement?
System.out.println(“Use a
\”\\\\\””);
a. | Use a
“\”” | b. | Use a \”\”” | c. | Use a “\” | d. | Use a “\\” | e. | Use a
\”\\\” |
|
|
99.
|
For the following code:
Which is true about the green and blue graphic object?
a. | The green object is to the right of the blue
object. | b. | The green object is to the left of the blue
object. | c. | The green object covers the blue
object. | d. | The blue object covers the green
object. |
|
|
100.
|
_________ summarize how we combine two logical
conditions based on AND, OR, and NOT.
a. | DeMorgan’s Law | b. | Truth tables | c. | Logical
Operators | d. | Logic References |
|
|
101.
|
For the following rectangle
g.drawRect(120, 220, 200, 100);
The height is ?
|
|
102.
|
If x is an int and y is a double, all of the following are legal except which
assignment statement?
a. | y = (double) x; | b. | x = y; | c. | x = (int)
y; | d. | y = x; | e. | all of the above are legal | f. | all of the above are illegal. |
|
|
103.
|
Which library package would you import to use the class Random?
a. | java.text | b. | java.beans | c. | java.io | d. | java.lang | e. | java.util |
|
|
104.
|
How many times will the following for loop iterate? 
a. | 3 | b. | 5 | c. | 4 | d. | 6 | e. | none of
these |
|
|
105.
|
When the while loop exits, what will the variable c contain? 
a. | The sum of all multples of 5. | b. | The count of all multple of
3. | c. | The sum of all multiples of 3. | d. | The sum of all the numbers
entered. | e. | The count of all multiples of 5. | f. | The number the user enters. | g. | The count of all
numbers entered. |
|
|
106.
|
Assume that x, y and z are all ints equal to 50, 20 and 6 respectively.
What is the result of x / y / z?
a. | 16 | b. | 12 | c. | 0 | d. | A syntax error as this is syntactically
invalid | e. | A run-time error because this is a division by 0 |
|
|
107.
|
How many times will the following for loop iterate? 
a. | 3 | b. | 4 | c. | 5 | d. | 6 | e. | none of
these |
|
|
108.
|
For g.fillOval(x,y,w,h) and the method public void actionPerformed(ActionEvent
e) { h+=rnd.nextInt(3); repaint(); }//END METHOD
will cause
the graphic object to
a. | move right. | b. | grow downward. | c. | grow
right. | d. | move down. | e. | move up. | f. | move
left. | g. | grow to the left. | h. | grow upwards. |
|
|
109.
|
public class
Questions { public static void main(String[ ] args)
{ int x, y, z; double average; Keyboard input = new
Keyboard(); System.out.print("Enter an integer value:"); x
= Keyboard.readInt( ); System.out.print("Enter another integer
value:"); y = Keyboard.readInt( ); System.out.print("Enter
a third integer value:"); z =Keyboard.readInt( ); average = (x +
y + z) / 3; System.out.println("The result
of my calculation is " + average); }//end
main }//end class
What is output if x = 0, y = 1 and z = 1?
a. | 0 | b. | 0.67 | c. | 0.6666666666666666 | d. | 0.6666666666666667 | e. | 0.0 |
|
|
110.
|
If g.fillOval(50,50,100,200) was changed to g.fillOval(50,50,200,200)
the area of the oval would
a. | get smaller. | b. | not change. | c. | get
larger. | d. | can’t be
determined. |
|
|
111.
|
public class Questions { public static void
main(String[ ] args) {
System.out.print("Here"); System.out.println("There " +
"Everywhere"); System.out.println("But not" + "in
Texas"); }//end main }//end class
How many lines of output are provided by
this program?
|
|
112.
|
What is the output?
for(int i=2; i<6; i=i+2) {
System.out.println(i); }//end for
a. | 0 1 2 3 4 5
| b. | 1 3 5
| c. | 1 2 3 4 5 6
| d. | 1 3 5 6
| e. | Contains a syntax error, will not compile. | f. | None of the above. |
|
|
113.
|
For the following code:

Which graphic object is closest to the upper
left hand corner of the output window?
a. | oval | b. | rectangle | c. | String | d. | None of
these |
|
|
114.
|
What is the output? 
a. | 1 2 3 4 5
| b. | 0 1 2 3 4 5
| c. | 123456
| d. | 1 2 3 4 5 6
| e. | Contains a syntax error, will not compile. | f. | None of the above. |
|
|
115.
|
public class Questions { public static void main(String[ ]
args) { int x, y, z; double average; Keyboard
input = new Keyboard(); System.out.print("Enter an integer
value:"); x = Keyboard.readInt( ); System.out.print("Enter
another integer value:"); y = Keyboard.readInt( );
System.out.print("Enter a third integer value:"); z =Keyboard.readInt(
); average = (x + y + z) / 3; System.out.println("The result of my calculation is " +
average); }//end
main }//end class
Questions computes
a. | the remainder of the sum of x, y and z divided by 3 | b. | The correct average
of x, y and z as a double | c. | The correct average of x, y and z as an
int | d. | the sum of x, y and z | e. | The average of x, y and z as a double, but the
result may not be accurate |
|
|
116.
|
Logic tells us that if two things must be true in
order to proceed then both condition_1 AND condition_2 must be _______.
a. | true | b. | one true and one false | c. | false | d. | either true of
false |
|
|
117.
|
What is the output? 
a. | 12345
| b. | 1 2 3 4 5 6
| c. | 1 2 3 4 5
| d. | 0 1 2 3 4 5
| e. | Contains a syntax error, will not compile. | f. | None of the above. |
|
|
118.
|
How many arguments does the drawString() method
take?
|
|
119.
|
In the statement
g.drawLine(40, 10, 20, 20);]
Which numbers represent the x coordinates the two
points?
a. | 10 and 10 | b. | 10 and 40 | c. | 10 and
20 | d. | 40 and 20 |
|
|
120.
|
A cast is required in which of the following situations?
a. | storing a double in an int | b. | using charAt to take an element of a String and
store it in a char | c. | storing a double in a
double | d. | storing an int in a double | e. | all of the above require
casts |
|
|
121.
|
What is the output?

a. | 1 2 3 4 5 6
| b. | 123456
| c. | 1 2 3 4 5
| d. | 0 1 2 3 4 5
| e. | Contains a syntax error, will not compile. | f. | None of the above. |
|
|
122.
|
What is the output?

a. | 123456
| b. | 12 34 5
| c. | 12 34 56
| d. | 1 23 45
| e. | Contains a syntax error, will not compile. | f. | None of the above. |
|