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

Description

Quiz on Tercer Set de Preguntas Java OCA Exam (1z0-803), created by webmasterMyJavaZone on 23/06/2014.
webmasterMyJavaZone
Quiz by webmasterMyJavaZone, updated more than 1 year ago
webmasterMyJavaZone
Created by webmasterMyJavaZone over 10 years ago
33616
2

Resource summary

Question 1

Question
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);
Answer
  • 1 0 1 0 0
  • 0 0 0 0 0
  • 1 0 1 1 -1
  • 0 -1 0 1 -1

Question 2

Question
Which of the following string classes create mutable strings? (Choose all that apply.)
Answer
  • String
  • StringBuffer
  • StringBuilder

Question 3

Question
Choose the simplest data structure to use to store multiple like variables that could then be accessed by an index.
Answer
  • Primitive
  • Object
  • Array
  • Enumeration

Question 4

Question
Which of the statements are correct? (Choose all that apply.)
Answer
  • 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

Question
What literal values are acceptable to use with the boolean primitive?
Answer
  • true and false
  • true, false, and null
  • true, false, TRUE, and FALSE
  • TRUE and FALSE

Question 6

Question
Which code segments related to enumerations will result in a compiler error? (Choose all that apply.)
Answer
  • 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

Question
Consider the following declarations. Which declaration has an element name that does not conform to standard naming conventions?
Answer
  • static final int varName;
  • Integer IntName;
  • void getName () {…}
  • public class Name {…}

Question 8

Question
Java 7 added the allowance of a special character to indentify places. Which declaration is correct?
Answer
  • int investment = 1x000x000;
  • int investment = 1_000_000;
  • int investment = 1^000^000;
  • int investment = 1-000-000;

Question 9

Question
What are the wrapper classes for the primitives boolean, char, short, int, and double?
Answer
  • Boolean, Char, Short , Int , Double
  • Boolean, Char, Short, Integer, Double
  • Boolean, Character, Short, Int, Double
  • Boolean, Character, Short, Integer, Double

Question 10

Question
Which of the following statements contain literal values?
Answer
  • int maxHorsePower = 170;
  • float currentHorsePower = (float) maxHorsePower;
  • float idleHorsePower = ((float) currentHorsePower) / 10);
  • System.out.println("Current HP: " + currentHorsePower);

Question 11

Question
What is the correct way to initialize a variable declared as a Penguin as a new Penguin object?
Answer
  • Penguin p;
  • Penguin p = new Penguin();
  • Penguin p = new Penguin[];
  • Penguin p = Penguin();

Question 12

Question
Which of the following are primitive data types? (Choose all that apply.)
Answer
  • int
  • boolean
  • char
  • Float
  • String

Question 13

Question
Which code example makes use of arrays without producing a compiler or runtime error?
Answer
  • 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

Question
Class variables, also known as static fields, have only one instance in existence. Following standing naming conventions, which answer represents a class variable?
Answer
  • variableName
  • VariableName
  • ClassName:variableName
  • ClassName.variableName

Question 15

Question
What statement about local variables is true?
Answer
  • 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.
Show full summary Hide full summary

Similar

The Geography Of Earthquakes
eimearkelly3
Social Psychology, Milgram (1963)
Robyn Chamberlain
Biology Revision - Y10 Mock
Tom Mitchell
A-Level Economics: Supply and Demand
cian.buckley+1
Know the principles of electricity
Vito Martino
Symbols in Lord of the Flies
lowri_luxton
HRCI Glossary of Terms A-N
Sandra Reed
Sociology- Key Concepts
Becky Walker
chemsitry as level topic 5 moles and equations
Talya Hambling
1PR101 2.test - Část 13.
Nikola Truong
Core 1.10 Polymers (Plastics)
T Andrews