PREGUNTAS 31 A 60

abril 15, 2008 at 9:52 pm Deja un comentario

Question 31
Which two code fragments correctly create and initialize a static array
of int elements? (Choose two.)

A. static final int[] a = { 100,200 };

B. static final int[] a;
static { a=new int[2]; a[0]=100; a[1]=200; }

C. static final int[] a = new int[2] { 100,200 };

D. static final int[] a;
static void init() { a = new int[3]; a[0]=100; a[1]=200; }

Question 32
Given:
11. public class Ball {
12. public enum Color { RED, GREEN, BLUE };
13. public void foo() {
14. // insert code here
15. { System.out.println(c); }
16. }
17. }

Which code inserted at line 14 causes the foo method to print RED,
GREEN, and BLUE?
A. for( Color c : Color.values())
B. for( Color c = RED; c <= BLUE; c++)
C. for( Color c; c.hasNext() ; c.next())
D. for( Color c = Color[0]; c <= Color[2]; c++)

E. for( Color c = Color.RED; c <= Color.BLUE; c++)

Question 33
Given:
10. public class Fabric
11. public enum Color {
12. RED(0xff0000), GREEN(0x00ff00), BLUE(0x0000ff);
13. private final int rgb;
14. Color( int rgb) { this.rgb = rgb; }
15. public int getRGB() { return rgb; }
16. };
17. public static void main( String[] argv) {
18. // insert code here
19. }
20. }
Which two code fragments, inserted independently at line 18, allow the
Fabric class to compile? (Choose two.)
A. Color skyColor = BLUE;
B. Color treeColor = Color.GREEN;
C. Color purple = new Color( 0xff00ff);
D. if( RED.getRGB() < BLUE.getRGB() ) {}
E. Color purple = Color.BLUE + Color.RED;
F. if( Color.RED.ordinal() 3) {
13. System.out.print(”pi is bigger than 3. “);
14. }
15. else {
16. System.out.print(”pi is not bigger than 3. “);
17. }
18. finally {
19. System.out.println(”Have a nice day.”);
20. }
‘What is the result?
A. Compilation fails.
B. pi is bigger than 3.
C. An exception occurs at runtime.
D. pi is bigger than 3. Have a nice day.
E. pi is not bigger than 3. Have a nice day.

Question 58
Given:
10.int x=0;
11.int y 10;
12. do {
l3. y–;
14. ++x;
15. } while (x < 5);
16. System.out.print(x + “,“ + y);
What is the result?
A. 5,6
B. 5,5
C. 6,5

D. 6,6

Question 59
Given:
25.intx=12;
26. while (x < 10) {
27. x–;
28. }
29. System.out.print(x);
What is the result?
A. 0
B. 10
C. 12
D. Line 29 will never be reached.

Question 60
Given:
35. int x= 10;
36. do {
37. x–;
38. } while(x< 10);
How many times will line 37 be executed?
A. ten times
B. zero times
C. one to me times
D. more than ten times

Entrada archivada en:Codigo General de SAID. Etiquetas:.

Cuidado con los constructores sin parametro Resumen Parte 1

Deja un comentario

Fill in your details below or click an icon to log in:

Logo de WordPress.com

You are commenting using your WordPress.com account. Log Out / Cambiar )

Twitter picture

You are commenting using your Twitter account. Log Out / Cambiar )

Facebook photo

You are commenting using your Facebook account. Log Out / Cambiar )

Connecting to %s

Trackback este articulo  |  Suscríbete a los comentarios vía RSS Feed


Lo más reciente

Blog Stats

  • 964 hits

Posts Más Vistos

  • Ninguna

Seguir

Get every new post delivered to your Inbox.