Quiz
OCA Exam Objectives 2.1 / 2.2
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (18)
1You need to create an application that is used to calculate the attendance at a baseball game. What data type would be most appropriate for storing the attendance?
- Aboolean
- Bchar
- Cfloat
- Dint
2What is the best data type to use if you are required to perform many addition, subtraction, and multiplication calculations on a whole number?
- Adouble
- BDouble
- Cint
- DInteger
3You are writing a class that will store the status of an on/off switch. Which data type is most appropriate for storing this value?
- Aboolean
- Bchar
- Cshort
- Dint
4You have decided on the data type for a variable that will store the information about the on/off switch. Now you must determine a name for it. Which of the following names follows the Java naming conventions?
- ALIGHTSWITCHENABLED
- BLightSwitchEnabled
- ClightSwitchEnabled
- Dx
5What is the best data type to use when storing a status code that may have one of the following values: success, failed, success with errors, or undetermined?
- AObject
- BClass
- Cboolean
- Denum
- Eint
6A system has three sensors attached to it. You need a way to represent this system in your program. What would be the best data type to use to model this system and sensors?
- AObject
- Bboolean
- Cenum
- Dint
7The "new" keyword is used to initialize which of the following data types? (Choose all that apply.)
- AObject
- Bboolean
- CBoolean
- DFloat
- Efloat
- Ffloat[]
8 In the following line of code, what does the (int) represent?
number = (int)sensorReading;- ARounding the sensorReading variable to the nearest int
- BCasting the sensorReading variable to the int data type
- CNothing; it is there as a comment
9Given the following line of code, which of the lines of code listed are incorrect? (Choose all that apply.)
char c;- Ac = new char();
- Bc = 'Y';
- Cc = '\u0056';
- Dc = "Yes";
10Which of the following variables are being set with the use of a literal? (Choose all that apply.)
- Aint tvChannel = 4;
- Bchar c = '5';
- Cchar d = '\u0123';
- D char e = c;
- Eint oldChannel = tvChannel;
11Given the following line of code, what lines below are valid? (Choose all that apply.)
enums Sports {FOOTBALL, BASKETBALL, BASEBALL, TRACK}- A Sports sport = FOOTBALL;
- BSports sport = Sports.FOOTBALL;
- CSports sport = Sports.HOCKEY;
- DSports sport = 'TRACK'
12What is wrong with the following method?
public double interestDue(double currentBalance, float interestRate) {
double interestDue = currentBalance * interestRate;
return interestDue;
}- A It should use all float primitives.
- BIt should use all Float objects
- C It should use all double primitives
- DIt should use all Double objects
- EIt should use BigDecimal objects
- FNothing is wrong with this method
- GIt does not compile because you cannot do math operations with primitives that are not the same type
13What is the correct way to create an array with five int data types? (Choose all that apply.)
- Aint intArray = new int[5];
- Bint intArray = new int(5);
- Cint[] intArray = new int[5];
- Dint intArray[] = new int[5];
14What is the correct way to initialize a variable declared with the data type of Book, as a new Book object?
- ABook b;
- BBook b = new Book();
- CBook b = new Book[];
- DBook b = Book();
15What is the difference between an int and an Integer?
- ANothing. They are both fully interchangeable.
- BAn int is an object and Integer is a primitive. An int is fastest when performing calculations.
- CAn int is a primitive and Integer is an object. An int is fastest when performing calculations.
- DThis is a trick question. There is no such thing as an Integer.
- EThis is a trick question. An Integer can be defined to be anything a developer wants it to be.
16What is the result of using a method of an uninitialized object?
- A Null is returned.
- BThe object is automatically initialized and an appropriate value is returned.
- CA NullPointerException is thrown from the Java Virtual Machine.
17What is wrong with the following code segment? (Choose all that apply.)

- ANothing is wrong.
- BThere is an error on line 1
- CThere is an error on line 2.
- DThere is an error on line 3
- EThere is an error on line 4.
- FThere is an error on line 5
- GThere is an error on line 6
- HThere is an error on line 7.
- IThere is an error on line 8
18What is the value of variable x in the following code segment?

- A0
- B0.0f
- C5.0f
- D8.3f
- E8.3
- FThis code will not compile.
Information
- Description
- Differentiate between object reference variables and primitive variables
- Author
- juanpelaez41
- Language
- Español
- Views
- 56
- Rating
- No ratings yet Rate this quiz