Java Programming OOPs
Questions 231 to 240
231.
|
Which of
the following will produce an error?
I. byte a1 = 2, a2 = 4, a3;
II. short s = 16;
III. a2 = s;
IV. a3 = a1 * a2;
|
||||||||||
232.
|
Examine
the following code snippets to identify the legal loop constructs:
I. for (int i = 22, int j = 0; i + j >
11; i = i-3, j++)
{
...
(Other statements)
}
II. int i = 100;
while(i)
{
...
(other statements)
}
III. while (int i > 0)
{
i--;
...
(other statements)
}
IV. int i = -10, sum = 0;
do {
...
(other statements)
}
while(sum
< 5 || i < 0);
|
||||||||||
233.
|
When we
invoke repaint () for a java.awt.Component object, the AWT invokes the method
|
||||||||||
234.
|
What does the following line of code do?
Textfield
text = new Textfield (10);
|
||||||||||
235.
|
Which of
the following applet tags is legal to embed an applet class named Test into a
Web page?
|
||||||||||
236.
|
Which of
the following classes are available in the java.lang package?
I. Stack.
II. Object.
III. Math.
IV. String.
V. StringBuffer.
Choose
the correct option from the following:
|
||||||||||
237.
|
Which of the
following are the wrapper classes?
I. Random.
II. Byte.
III. Integer.
IV. Short.
V. Double.
|
||||||||||
238.
|
Which of the
following contain error?
I. int x[] = int[10];.
II. int[] y = new int[5];
III. x = y = new int[10];
IV. int a[] = {1, 2}; int b[]; b = a;
V. int i = new int(10);
|
||||||||||
239.
|
Which is the
latest version of the Java language?
|
||||||||||
240.
|
How to
declare a class which has fields that are not serializable?
|
Answers
231.
|
Answer : (a)
Reason: In line 3, a short value is being assigned
to a variable of type byte, which is illegal. Also, the "*"
operator promotes the bytes to integers, which makes it illegal to assign the
return value to a variable of type byte.
|
232.
|
Answer : (a)
Reason: In option (B), the argument of
"while" is an integer, which is illegal. It can only be Boolean. In
option (C), "int i > 0" is an illegal construct.
|
233.
|
Answer : (a)
Reason: In option (B), the argument of
"while" is an integer, which is illegal. It can only be Boolean. In
option (C), "int i > 0" is an illegal construct.
|
234.
|
Answer : (a)
Reason: Creates text object that can hold 10 columns
of text.
|
235.
|
Answer : (c)
Reason: < applet
Code = Test. class
width = 200 height = 100>
|
236.
|
Answer : (a)
Reason: Object, Math, String, String Buffer belong
to Java.lang package.1
|
237.
|
Answer : (a)
Reason: Byte, integer, short and double are the
wrapper classes.
|
238.
|
Answer : (a)
Reason: Statements (I), (III) and (V) contain error.
|
239.
|
Answer : (a)
Reason: Java 5.0 includes a number of new language
features, most notably generic types, which increase both the complexity and
the power of the language.
|
240.
|
Answer : (e)
Reason: We can declare them as transient.
|
<< Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
23 24 25 26 27 28 29 30 Next >>
thank you.
ReplyDeletejava tutorial
java tutorial