Machine-translated by Google. Questions are authored in English.
Top

Language Fundamentals - General Questions Questions and Answers

11.

Which one of the following will declare an array and initialize it with five numbers?

Answer: B

Option B is the legal way to declare and initialize an array with five elements.

Option A is wrong because it shows an example of instantiating a class named Array, passing the integer value 5 to the object's constructor. If you don't see the brackets, you can be certain there is no actual array object! In other words, an Array object (instance of class Array) is not the same as an array object.

Option C is wrong because it shows a legal array declaration, but with no initialization.

Option D is wrong (and will not compile) because it declares an array with a size. Arrays must never be given a size when declared.

Please log in or register to report this question.

Answer: C

Correct answer: boolean b3 = false;

A boolean accepts only the literals true and false. Java performs no conversion between numbers and booleans, so 0 is not accepted - the C idiom of zero meaning false does not carry over. 'false' in single quotes is a char literal and in any case too long to be one, Boolean.false() is not a method, and no is an undeclared identifier.

Please log in or register to report this question.

13.

Which is a reserved word in the Java programming language?

Answer: B

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'.

Please log in or register to report this question.

Answer: B

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.

Please log in or register to report this question.

Answer: A

Option A sets the String reference to null.

Option B is wrong because null cannot be in single quotes.

Option C is wrong because there are multiple characters between the single quotes ('abc').

Option D is wrong because you can't cast a char (primitive) to a String (object).

Please log in or register to report this question.

Loading…
Tags: Language Fundamentals - General Questions Questions and Answers || Language Fundamentals - General Questions MCQ Questions and Answers || Language Fundamentals - General Questions GK Questions and Answers || Language Fundamentals - General Questions GK MCQ Questions || Language Fundamentals - General Questions Multiple Choice Questions and Answers || Language Fundamentals - General Questions GK || GK on Language Fundamentals - General Questions || Java Programming Questions and Answers || Java Programming MCQ Questions and Answers || Java Programming GK Questions and Answers || GK on Java Programming