johnrclark12
Test por , creado hace más de 1 año

C2 Java Programming Test sobre Java (Multimedia Approach) Ch 1-4, creado por johnrclark12 el 18/09/2014.

33
1
0
johnrclark12
Creado por johnrclark12 hace más de 9 años
Cerrar

Java (Multimedia Approach) Ch 1-4

Pregunta 1 de 48

1

Machine language is a binary language composed of only zeros and ones

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 2 de 48

1

A Java source file must have the following extension:

Selecciona una de las siguientes respuestas posibles:

  • .class

  • .c

  • .txt

  • .java

Explicación

Pregunta 3 de 48

1

Java bytecode varies according to the type of processor used in the computer.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 4 de 48

1

Machine language is specific to the processor in a computer.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 5 de 48

1

The software development method is a framework used to:

Selecciona una de las siguientes respuestas posibles:

  • design an algorithm

  • develop a software product

  • maintain code

  • test code

Explicación

Pregunta 6 de 48

1

Every program contains a particular sequence of operations referred to as

Selecciona una de las siguientes respuestas posibles:

  • the software development method.

  • a statement.

  • machine language.

  • an algorithm.

Explicación

Pregunta 7 de 48

1

True or False? A processor can execute Java bytecode directly.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 8 de 48

1

Java is case-sensitive.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 9 de 48

1

Which of the following is a correct way to start a Java comment?

Selecciona una de las siguientes respuestas posibles:

  • */

  • "

  • /*

  • comment:

  • **

Explicación

Pregunta 10 de 48

1

An object:

Selecciona una de las siguientes respuestas posibles:

  • is created using a constructor in a class.

  • has specific values assigned to its fields.

  • exists only while the program is running.

  • all of these answers are correct

Explicación

Pregunta 11 de 48

1

An object of a class is also called an instance of that class.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 12 de 48

1

A class has values assigned to its fields whereas an object does not.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 13 de 48

1

An object reference variable:

Selecciona una de las siguientes respuestas posibles:

  • is an object.

  • holds the reference to an object.

  • references a primitive type.

  • is the name of a class.

Explicación

Pregunta 14 de 48

1

A class:

Selecciona una de las siguientes respuestas posibles:

  • must contain at least one field.

  • is used to create an object.

  • has specific values assigned to its fields.

  • all of these are correct.

Explicación

Pregunta 15 de 48

1

A constructor is a special method used to create an object.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 16 de 48

1

A string literal can span multiple lines.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 17 de 48

1

Suppose that you have a Golfer object sally. What is the proper way of calling the swing() method for sally? The declaration is: Golfer sally = new Golfer();

Selecciona una de las siguientes respuestas posibles:

  • sally.Golfer(swing);

  • none of these

  • swing().sally;

  • sally.swing();

  • Golfer.swing(sally);

Explicación

Pregunta 18 de 48

1

Which of the following is a valid identifier?

Selecciona una de las siguientes respuestas posibles:

  • 1alpha

  • x1_123

  • $fifteen

  • num is

Explicación

Pregunta 19 de 48

1

A variable can be initialized when it is declared.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 20 de 48

1

A widening conversion, in which a narrower type is converted to a wider type, takes place automatically.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 21 de 48

1

Which of the following is NOT a legal identifier for a variable?

Selecciona una de las siguientes respuestas posibles:

  • _gamma3

  • all of these are legal names

  • static

  • beta_2

  • alpha1

Explicación

Pregunta 22 de 48

1

The drawString method in class Graphics2D is declared as follows:
void drawString(String str, int x, int y)
Assuming that some variables are declared as shown below, which calls to this method are valid?
String s1 = " "; char c = 'x';
int x1 = 10, y1 = 20;
double x2 = 20.5;

Selecciona una de las siguientes respuestas posibles:

  • drawString(c, x1, y1);

  • drawString(x2, s1, y1);

  • drawString(s1, x2, y1);

  • drawString(s1, x1, y1);

Explicación

Pregunta 23 de 48

1

It is not necessary for a method to return a value.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 24 de 48

1

Before using a class in the java.lang package, it is necessary to import this class into the program.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 25 de 48

1

In order to read from the keyboard it is necessary to:

Selecciona una de las siguientes respuestas posibles:

  • use the System.in.readln() method

  • construct an object of the Keyboard class

  • use the System.our.println() method

  • none of these

  • construct an object of the Scanner class.

Explicación

Pregunta 26 de 48

1

Which operation occurs first when the computer executes the statement below:

int length = a - b * c % d--;

Selecciona una de las siguientes respuestas posibles:

  • c % d

  • a - b

  • d--

  • impossible to determine unless parentheses are used

  • b * c

Explicación

Pregunta 27 de 48

1

True or False? If someInt is an integer and someFloat is a float the following statement is a correct assignment operation.

someInt = someFloat;

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 28 de 48

1

int GetHeight() is a method that returns the number of pixels in the column of an image.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 29 de 48

1

Which operation occurs first when the computer executes the statement below:

int length = a % b - c * --d;

Selecciona una de las siguientes respuestas posibles:

  • c * --d

  • a % b

  • impossible to determine unless parentheses are used

  • --d

  • b - c

Explicación

Pregunta 30 de 48

1

Color myColor = new Color(255, 0, 0); will create a Color object that is

Selecciona una de las siguientes respuestas posibles:

  • red

  • blue

  • green

  • something else

  • yellow

Explicación

Pregunta 31 de 48

1

The Scanner class is part of the java.util package.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 32 de 48

1

Every "if" must match up with a corresponding "else".

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 33 de 48

1

Which of the following is NOT a legal statement as written? Assume: double someDouble; int someInt; float someFloat; byte someByte; long someLong;

Selecciona una de las siguientes respuestas posibles:

  • all of these are legal

  • someLong = someFloat;

  • someLong = someByte;

  • someDouble = someInt;

  • someInt = someFloat;

Explicación

Pregunta 34 de 48

1

What is the output of the following code segment for an input of 45?
Scanner scanner = new Scanner(System.in);
int x = scanner.nextInt();

if (x > 50)
System.out.print("x is greater than 50.");
else if (x > 30)
System.out.print("x is greater than 30.");
else if (x > 40)
System.out.print("x is greater than 40.");

Selecciona una de las siguientes respuestas posibles:

  • x is greater than 40.

  • x is greater than 30.

  • x is greater than 30. x is greater than 40.

  • x is greater than 50.

Explicación

Pregunta 35 de 48

1

The code below is designed so that ONLY one shape will be displayed (assume the rest of the program has been developed):

if (magicShape == 0) {
// magicShape is 0, draw and color a rectangle
Rectangle2D.Float shape = new Rectangle2D.Float(x, y, w1, h1);
dk.fill(shape);
} else if (magicShape == 1) {
// magicShape is 1, draw and color an ellipse
Ellipse2D.Float shape1 = new Ellipse2D.Float(x, y, w1, h1);
dk.fill(shape1);
} else if (magicShape == 2) {
// magicShape is 2, draw and color a circle
Ellipse2D.Float shape2 = new Ellipse2D.Float(x, y, w2, h2);
dk.fill(shape2);
} else {
// magicShape is 3, draw a square
Rectangle2D.Float shape3 = new Rectangle2D.Float(x, y, w2, h2);
dk.draw(shape3);
}

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 36 de 48

1

It is reasonable to use the switch statement to check the value of a String object.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 37 de 48

1

What is the output of the following code segment for an input of 2?
System.out.print("Enter x:");
Scanner scanner = new Scanner(System.in);
int x = scanner.nextInt();

switch(x) {
case 1: System.out.print("1");

case 2: System.out.print("2");

case 3: System.out.print("3");
}

Selecciona una de las siguientes respuestas posibles:

  • 23

  • 3

  • 2

  • 12

Explicación

Pregunta 38 de 48

1

How many times will the loop below go through the body of the loop (assume all variables are declared appropriately)?

int numTimes = 5;

while (numTimes >= 0) {

{

// do something in the loop

numTimes++;

}

Selecciona una de las siguientes respuestas posibles:

  • 6

  • 5

  • it will go through the loop forever

  • 0

Explicación

Pregunta 39 de 48

1

The do - while loop will always go through at least one iteration (as long as there is no break; statement)

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 40 de 48

1

True or False? Logical operators can only have boolean operands.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 41 de 48

1

In the boolean expression a > b && c < d || e == f which operation will be evaluated first?

Selecciona una de las siguientes respuestas posibles:

  • <

  • &&

  • >

  • ||

  • ==

Explicación

Pregunta 42 de 48

1

Every while loop must execute (iterate) at least one time.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 43 de 48

1

The continue; statement will make execution skip to the bottom of the loop and exit the loop entirely.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 44 de 48

1

What will be printed by the following loop?

for (int i = 0; i < 6; i++) {

if (i % 3 == 0) {

System.out.print(i);

}

}

Selecciona una de las siguientes respuestas posibles:

  • none of these

  • 36

  • 012345

  • 03

  • 036

Explicación

Pregunta 45 de 48

1

Which of the following is used to express the logical operation "OR"?

Selecciona una de las siguientes respuestas posibles:

  • !!

  • none of these

  • ||

  • ??

  • &&

Explicación

Pregunta 46 de 48

1

True or False? Evaluate the following boolean condition:

num1 = 2;

num2 = 1;

bool = !(num1--==num2);

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 47 de 48

1

The break; statement is only used with the switch - case statement.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 48 de 48

1

I want to print the message "uncomfortable" when the temperature is outside of the range of 60 to 80 degrees. Which condition will properly test for this situation?

Selecciona una de las siguientes respuestas posibles:

  • (60 < temperature || >80)

  • (60 > temperature > 80)

  • (60 > temperature && temperature > 80)

  • none of these

  • (60 > temperature || temperature > 80)

Explicación