Вы находитесь на странице: 1из 3

1Answer: Option B

Explanation:
Output: 15 15
The reference variables a1 and a3 refer to the same long array object. When the [1] element is
updated in the fix() method, it is updating the array referred to by a1. The reference
variable a2 refers to the same array object.
So Output: 3+7+5+" "3+7+5
Output: 15 15 Because Numeric values will be added
2Answer: Option B
Explanation:
The boolean b1 in the fix() method is a different boolean than the b1 in the start() method.
The b1 in the start() method is not updated by the fix() method.

3Answer: Option D
Explanation:
When the fix() method is first entered, start()'s s1 and fix()'s s1 reference variables both
refer to the same String object (with a value of "slip"). Fix()'s s1 is reassigned to a new object that
is created when the concatenation occurs (this second String object has a value of "slipstream").
When the program returns to start(), another String object is created, referred to by s2 and with
a value of "stream".

4Answer: Option B
Explanation:
(1), (3), (4), (5) are the correct statements.
(2) is wrong because the default value for a String (and any other object reference) is null, with
no quotes.
(6) is wrong because the default value for boolean elements is false

5Answer: Option B
Explanation:
All the words in option B are among the 49 Java keywords. Although goto reserved as a keyword in
Java, goto is not used and has no function.
Option A is wrong because the keyword for the primitive int starts with a lowercase i.
Option C is wrong because "virtual" is a keyword in C++, but not Java.
Option D is wrong because "constant" is not a keyword. Constants in Java are
marked static and final.
Option E is wrong because "include" is a keyword in C, but not in Java.

6Answer: Option B
Explanation:
The word "native" is a valid keyword, used to modify a method declaration.
Option A, D and E are not keywords. Option C is wrong because the keyword for subclassing in
Java is extends, not 'subclasses
7Answer: Option A
Explanation:
interface is a valid keyword.
Option B is wrong because although "String" is a class type in Java, "string" is not a keyword.
Option C is wrong because "Float" is a class type. The keyword for the Java primitive is float.
Option D is wrong because "unsigned" is a keyword in C/C++ but not in Java.

8Answer: Option A
Explanation:
Switch statements are based on integer expressions and since both bytes and chars can implicitly
be widened to an integer, these can also be used. Also shorts can be used. Short and Long are
wrapper classes and reference types can not be used as variables.

9Answer: Option D
Explanation:
Using the integer 1 in the while statement, or any other looping or conditional construct for that
matter, will result in a compiler error. This is old C Program syntax, not valid Java.
A, B and C are incorrect because line 1 is valid (Java is case sensitive so While is a valid class
name). Line 8 is also valid because an equation may be placed in a String operation as shown.

Answer: c
Explanation: Modulus operator can be applied to both integers and floating point numbers.

1. What is a data type?

a. The part of the CPU that does arithmetic.


b. A part of main memory used to store data.
c. A particular scheme for represending values with bit patterns.
d. The collection of variables that a program uses.

2. How many patterns can be created using a single bit?

a. 1
b. 2
c. 4
d. 8

3. What is a Java primitive data type?

a. A method for representing values that is so useful that it is a fundamental part of the
language.
b. A crude form of representing numbers.
c. The part of Java that is the same as in older languages.
d. A data type that cannot be used as part of an object.

4. Does every Java variable use a data type?


a. No---only numeric variables use data types.
b. No---data types are optional.
c. Yes---all variables are of the same data type.
d. Yes---each variable must be declared along with its data type.

5. Which of the following is NOT the name of a Java primitive data type?

a. int
b. float
c. double
d. String

6. Is the value ONE always going to be represented by using the same pattern of bits?

a. Yes---there is only one "one" so there will be just one pattern.


b. No---"one" can be represented using several integer data types or floating point data
types.
c. Yes---it will always be stored in one bit.
d. No---the pattern will change each time the program is run.

7. Say that a particular item of data does NOT use a primitive data type. What must it be?

a. An object.
b. A number.
c. A literal.
d. A boolean.
8. How many places of decimal precision are there in the following number: +1200004.5

a. 4
b. 5
c. 8
d. More than a million

9. Can character data be stored in computer memory?

a. No---computers can only store numbers.


b. No---computer memory can only store patterns.
c. Yes---characters are stored in special memory.
d. Yes---a primitive data type is used to store characters.

10. In which of the following answers does the number of bits increase from fewest (on the left) to
most (on the right)?

a. byte long short int


b. int byte short long
c. byte short int long
d. short byte long int

Вам также может понравиться