Java Programming OOPs
Questions 221 to 230
221.
|
Which of
the following statements is/are valid array declarations?
I. int number();
II. float average[];
III. double[] marks;
IV. counter int[];
V. []double marks;
|
||||||||||
222.
|
Consider
the following code
int number[] = new int[5]; After execution of this
statement, which of the following is/are true?
I. number[0] is undefined.
II. number[5] is undefined.
III. number[4] is null.
IV. number[2] is 0.
V. number.length() is 5.
|
||||||||||
223.
|
What will
be the content of array variable table after executing the following code?
for(int
i=0; i<3; i++)
for(int
j=0; j<3; j++)
if(j ==
i) table[i][j] = 1;
else
table[i][j] = 0;
|
||||||||||
224.
|
Which of
the following statements about abstract methods/classes in Java is/are true?
I. An abstract class cannot be instantiated.
II. Constructors cannot be abstract.
III. A subclass of an abstract class must
defined the abstract methods.
IV. Static methods may be declared abstract.
|
||||||||||
225.
|
Which
keyword can protect a class in a package from accessibility by the classes
outside the package?
|
||||||||||
226.
|
We would
like to make a member of a class visible in all subclasses regardless of what
package they are in. Which one of the following keywords would achieve this?
|
||||||||||
227.
|
The type
long can be used to store values in the following range:
|
||||||||||
228.
|
Which of
the following is/are not
hexadecimal numbers?
I. 999.
II. (hex)23.
III. 0x556.
IV. 0x1F2.
|
||||||||||
229.
|
Select
the invalid assignment statement(s) from the following:
I. Float x = 238.88;
II. Double y = 0x443;
III. int n = (int) true;
IV. long m =778645;
|
||||||||||
230.
|
Which of
the following expressions will produce errors upon compilation?
I. boolean a = (boolean) 1;
II. boolean b = (false && true);
III. float y = 22.3;
IV. int x = (25 | 125)
|
Answers
221.
|
Answer : (a)
Reason: Remaining all are invalid declarations.
|
222.
|
Answer : (a)
Reason: Remaining choices are false
|
223.
|
Answer : (a)
Reason: The content of array variable table after
executing the following code is
1 0 0
0 1 0
0 0 1
|
224.
|
Answer : (a)
Reason: Line 1 and line 2 only
A subclass of an
abstract class can also be abstract if it does not define all the abstract
methods in the parent class.
|
225.
|
Answer : (a)
Reason: don't use any keyword at all (make it
default)
|
226.
|
Answer : (a)
Reason: To make a member of a class visible in all
subclasses regardless of what package they are in either private OR protected
|
227.
|
Answer : (a)
Reason: -263 to 263 – 1 The type long is a 64-bit
two's complement that can be used for long integers.
|
228.
|
Answer : (a)
Reason: Hexadecimal numbers start with
"0x" in the Java programming language.
|
229.
|
Answer : (a)
Reason: 238.88 is a double in Java. To assign this
value to a float, 238.88f must be used. A variable of type boolean cannot be
converted to an integer in Java.
|
230.
|
Answer : (a)
Reason: Integers cannot be converted to booleans,
and floats must be explicitly specified (22.3f, and not 22.3 which is a
double).
|
in 226 How private member can be accessed outside even a class, you are talking about packages ???
ReplyDeletethank you.
ReplyDeletejava tutorial
java tutorial