Tercer Set de Preguntas Java OCA Exam (1z0-803)

Question 1 of 15

Medal-premium 1

Given the following code segment, what would be the output?

int a = 0;
int b = 0;
int c = 0;
System.out.println(a++ + " " + --b + " " + c++ + " " + a + " " + b);

Select one of the following:

  • 1 0 1 0 0

  • 0 0 0 0 0

  • 1 0 1 1 -1

  • 0 -1 0 1 -1

Question 2 of 15

Medal-premium 1

Which of the following string classes create mutable strings? (Choose all that apply.)

Select one or more of the following:

  • String

  • StringBuffer

  • StringBuilder

Question 3 of 15

Medal-premium 1

Choose the simplest data structure to use to store multiple like variables that could then be accessed by an index.

Select one of the following:

  • Primitive

  • Object

  • Array

  • Enumeration

Question 4 of 15

Medal-premium 1

Which of the statements are correct? (Choose all that apply.)

Select one or more of the following:

  • 3.0 is a valid literal for an int.

  • 3.0 is a valid literal for a float.

  • 3 is a valid literal for an int.

  • 3 is a valid literal for a float.

  • 3f is a valid literal for an int.

  • 3f is a valid literal for a float.

Question 5 of 15

Medal-premium 1

What literal values are acceptable to use with the boolean primitive?

Select one of the following:

  • true and false

  • true, false, and null

  • true, false, TRUE, and FALSE

  • TRUE and FALSE

Question 6 of 15

Medal-premium 1

Which code segments related to enumerations will result in a compiler error? (Choose all that apply.)

Select one of the following:

  • enum Coin {PENNY, NICKEL, DIME, QUARTER}
    Coin coin = Coin.NICKEL;

  • enum Coin {PENNY, NICKEL, DIME, QUARTER}
    Coin coin;
    coin = Coin.NICKEL;

  • enum Coin {PENNY, NICKEL, DIME, QUARTER}
    Coin coin = NICKEL;

  • enum Coin {penny, nickel, dime, quarter}
    Coin coin = Coin.NICKEL;

Question 7 of 15

Medal-premium 1

Consider the following declarations. Which declaration has an element name that does not conform to standard naming conventions?

Select one of the following:

  • static final int varName;

  • Integer IntName;

  • void getName () {…}

  • public class Name {…}

Question 8 of 15

Medal-premium 1

Java 7 added the allowance of a special character to indentify places. Which declaration is correct?

Select one of the following:

  • int investment = 1x000x000;

  • int investment = 1_000_000;

  • int investment = 1^000^000;

  • int investment = 1-000-000;

Question 9 of 15

Medal-premium 1

What are the wrapper classes for the primitives boolean, char, short, int, and double?

Select one of the following:

  • Boolean, Char, Short , Int , Double

  • Boolean, Char, Short, Integer, Double

  • Boolean, Character, Short, Int, Double

  • Boolean, Character, Short, Integer, Double

Question 10 of 15

Medal-premium 1

Which of the following statements contain literal values?

Select one or more of the following:

  • int maxHorsePower = 170;

  • float currentHorsePower = (float) maxHorsePower;

  • float idleHorsePower = ((float) currentHorsePower) / 10);

  • System.out.println("Current HP: " + currentHorsePower);

Question 11 of 15

Medal-premium 1

What is the correct way to initialize a variable declared as a Penguin as a new Penguin object?

Select one of the following:

  • Penguin p;

  • Penguin p = new Penguin();

  • Penguin p = new Penguin[];

  • Penguin p = Penguin();

Question 12 of 15

Medal-premium 1

Which of the following are primitive data types? (Choose all that apply.)

Select one or more of the following:

  • int

  • boolean

  • char

  • Float

  • String

Question 13 of 15

Medal-premium 1

Which code example makes use of arrays without producing a compiler or runtime error?

Select one of the following:

  • public class Actor {
    String[] characterName = new String[3];
    {
    characterName[0] = "Captain Video";
    characterName[1] = "Quizmaster";
    characterName[2] = "J.C. Money";
    characterName[3] = "Jersey Joe";
    }
    }

  • public class Actor {
    String[] characterName = new String[1..4]
    {
    characterName[0] = "Captain Video";
    characterName[1] = "Quizmaster";
    characterName[2] = "J.C. Money";
    characterName[3] = "Jersey Joe";
    }
    }

  • public class Actor {
    String characterName = new String[4];
    {
    characterName[0] = "Captain Video";
    characterName[1] = "Quizmaster";
    characterName[2] = "J.C. Money";
    characterName[3] = "Jersey Joe";
    }
    }

  • public class Actor {
    String [] characterName = new String[4];
    {
    characterName[0] = "Captain Video";
    characterName[1] = "Quizmaster";
    characterName[2] = "J.C. Money";
    characterName[3] = "Jersey Joe";
    }
    }

Question 14 of 15

Medal-premium 1

Class variables, also known as static fields, have only one instance in existence. Following standing naming conventions, which answer represents a class variable?

Select one of the following:

  • variableName

  • VariableName

  • ClassName:variableName

  • ClassName.variableName

Question 15 of 15

Medal-premium 1

What statement about local variables is true?

Select one of the following:

  • Local variables are declared outside of methods and are initialized with a default value.

  • Local variables are declared inside of methods and are initialized with a default value.

  • Local variables are declared outside of methods and are not initialized with a default value.

  • Local variables are declared inside of methods and are not initialized with a default value.

Icon_fullscreen

Tercer Set de Preguntas Java OCA Exam (1z0-803)

webmasterMyJavaZone
Quiz by , created over 2 years ago

Quiz on Tercer Set de Preguntas Java OCA Exam (1z0-803), created by webmasterMyJavaZone on 23/06/2014.

Eye 13930
Pin 2
Balloon-left 0
Tags No tags specified
webmasterMyJavaZone
Created by webmasterMyJavaZone over 2 years ago
Close