|
We have the following organization of classes.
class Parent { }
class DerivedOne extends Parent { }
class DerivedTwo extends Parent { } |
Which of the following statements is correct
for the following expression.
Parent p = new Parent();
DerivedOne d1 = new DerivedOne();
DerivedTwo d2 = new DerivedTwo();
p = d1; |
- llegal both compile and runtime,
- Legal at compile time, but fails at
runtime,
- Legal at compile and runtime
We have the following organization of classes.
class Parent { }
class DerivedOne extends Parent { }
class DerivedTwo extends Parent { } |
Which of the following statements is correct
for the following expression.
Parent p = new Parent();
DerivedOne d1 = new DerivedOne();
DerivedTwo d2 = new DerivedTwo();
d1 = d2; |
- llegal both compile and runtime,
- Legal at compile time, but fails at
runtime,
- Legal at compile and runtime
We have the following organization of classes.
class Parent { }
class DerivedOne extends Parent { }
class DerivedTwo extends Parent { } |
Which of the following statements is correct
for the following expression.
Parent p = new Parent();
DerivedOne d1 = new DerivedOne();
DerivedTwo d2 = new DerivedTwo();
d1 = (DerivedOne)d2; |
- llegal both compile and runtime,
- Legal at compile time, but fails at
runtime,
- Legal at compile and runtime
We have the following organization of classes.
class Parent { }
class DerivedOne extends Parent { }
class DerivedTwo extends Parent { } |
Which of the following statements is correct
for the following expression.
Parent p = new Parent();
DerivedOne d1 = new DerivedOne();
DerivedTwo d2 = new DerivedTwo();
d1 = (DerivedOne)p; |
- llegal both compile and runtime,
- Legal at compile time, but fails at
runtime,
- Legal at compile and runtime
We have the following organization of classes.
class Parent { }
class DerivedOne extends Parent { }
class DerivedTwo extends Parent { } |
Which of the following statements is correct
for the following expression.
Parent p = new Parent();
DerivedOne d1 = new DerivedOne();
DerivedTwo d2 = new DerivedTwo();
p = (Parent)d1; |
- llegal both compile and runtime,
- Legal at compile time, but fails at
runtime,
- Legal at compile and runtime
With which I/O operation can we append. update
a file?
- RandomAccessFile(),
- OutputStream()
- DataOutputStream()
For which of the following code will produce
‘test” as output on the screen?
-
int x=10.0;
if ( x==10.0) { System.out.println(“test”); } |
int x=012;
if ( x==10.0) { System.out.println(“test”); } |
-
int x=10f;
if ( x==10.0) { System.out.println(“test”); } |
int x=10L;
if ( x==10.0) { System.out.println(“test”); } |
Given this class?
|
class Loop {
public static void main( String [] agrs) {
int x=0; int y=0;
outer: for (x=0; x<100;x++) {
middle: for (y=0;y<100;y++) {
System.out.println("x=" + x + "; y=" + y);
if (y==10) { <<<
>>> } } }
} //main
} //class |
The question is which code must replace the <<>> to finish the outerloop?
-
-
Which component cannot be added to a container?
- Component
- Menu
- Container
- Applet
- Button
What does it mean when the handleEvent() returns the true boolean?
- the event will be handled by the component,
- the action() method will handle the event,
- the event will be handled by the super.handleEvent()
- do nothing
|