Name: 
 

SG MC



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

mc003-1.jpg

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?

mc004-1.jpg


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?

mc005-1.jpg
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?

mc007-1.jpg
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 ?
a.
120
b.
220
c.
200
d.
100
 

 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?

mc012-1.jpg

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 ?
a.
220
b.
200
c.
100
d.
120
 

 15. 

In the following call, what is the x-coordinate of the line’s ending point?

drawLine(10, 20, 100, 200)
a.
10
b.
20
c.
100
d.
200
 

 16. 

For the following rectangle  g.drawRect(120, 220, 200, 100);

The width is ?
a.
220
b.
100
c.
200
d.
120
 

 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

mc018-1.jpg

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;
a.
20
b.
–30
c.
–20
d.
–6
e.
30
 
 
nar002-1.jpg
 

 20. 

Which of the following line numbers contains a variable declaration and initialization?
a.
31
b.
13
c.
14
d.
28
 

 21. 

Which of the following line numbers contains a variable declaration only?
a.
13
b.
31
c.
14
d.
19
 

 22. 

Which of the following line numbers should NOT be changed when adding IDOC to a program?
a.
35
b.
2
c.
4
d.
6
 

 23. 

Which of the following line numbers decrements a variable by 1?
a.
30
b.
32
c.
33
d.
31
 

 24. 

Which of the following line numbers increments a variable by 1?
a.
33
b.
31
c.
32
d.
30
 

 25. 

For the following rectangle  g.drawRect(220, 120, 200, 100);

The y coordinate is ?
a.
220
b.
200
c.
100
d.
120
 

 26. 

For the following code
mc026-1.jpg

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?

mc028-1.jpg
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?

mc029-1.jpg
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:

mc031-1.jpg


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

mc032-1.jpg

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?
a.

mc033-2.jpg
b.


mc033-3.jpg
c.

mc033-4.jpg
d.

mc033-5.jpg
 

 34. 

What is the output?

mc034-1.jpg
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 ?
a.
200
b.
220
c.
100
d.
120
 

 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?

mc038-1.jpg
a.
3
b.
5
c.
6
d.
4
e.
none of these
 

 39. 

In the following loop

mc039-1.jpg

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?

mc044-1.jpg
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?
a.


mc045-3.jpg
b.

mc045-4.jpg
c.

mc045-5.jpg
d.

mc045-6.jpg
 

 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?

mc047-1.jpg
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 ?
a.
220
b.
320
c.
200
d.
120
 

 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
a.
5
b.
2
c.
1
d.
3
e.
4
 

 51. 

What is the output?

mc051-1.jpg

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

mc053-1.jpg

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:
 
mc054-1.jpg

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

mc055-1.jpg

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
mc057-1.jpg
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?

mc058-1.jpg
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 ?
a.
200
b.
100
c.
120
d.
220
 

 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?
a.
2
b.
4
c.
6
d.
8
 

 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?

mc068-1.jpg
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:
mc069-1.jpg

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:

mc073-1.jpg


How many graphic objects are generated?
a.
2
b.
3
c.
5
d.
4
 

 74. 

Given the following code, where x = 0, what is the resulting value of x after the for-loop terminates?

mc074-1.jpg
a.
4
b.
15
c.
0
d.
5
e.
10
 

 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

mc076-1.jpg

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?

mc077-1.jpg
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?

mc079-1.jpg

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.
 
 
nar001-1.jpg
 

 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?
a.

mc083-2.jpg
b.

mc083-3.jpg
c.

mc083-4.jpg
d.


mc083-5.jpg
 

 84. 

For the following code

mc084-1.jpg

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?

mc085-1.jpg
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?
a.
256
b.
512
c.
16
d.
64
 

 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

mc091-1.jpg

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?

mc092-1.jpg
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:

mc094-1.jpg

How many graphic objects are generated?
a.
2
b.
4
c.
3
d.
5
 

 95. 

For the following code:
   
mc095-1.jpg

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

mc096-1.jpg

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:

mc099-1.jpg  


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 ?
a.
100
b.
200
c.
220
d.
120
 

 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?

mc104-1.jpg
a.
3
b.
5
c.
4
d.
6
e.
none of these
 

 105. 

When the while loop exits, what will the variable c contain?

mc105-1.jpg
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?

mc107-1.jpg
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?
a.
1
b.
2
c.
5
d.
3
e.
4
 

 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



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:
   
mc113-1.jpg

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?

mc114-1.jpg
a.
1
2
3
4
5

b.
0
1
2
3
4



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?

mc117-1.jpg
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?
a.
1
b.
2
c.
3
d.
4
 

 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?

mc121-1.jpg

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?

mc122-1.jpg
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.
 



 
Check Your Work     Start Over