READ Free Dumps For Oracle- 1z0-803
Question ID 21927 | Given:
class X {
String str = "default";
X(String s) { str = s;}
void print () { System.out.println(str); }
public static void main(String[] args) {
new X("hello").print();
}}
What is the result?
|
Option A | hello
|
Option B | default
|
Option C | Compilation fails
|
Option D | The program prints nothing
|
Option E | An exception is thrown at run time
|
Correct Answer | A |
Explanation Explanation: The program compiles fine. The program runs fine. The output is: hello
Question ID 21928 | Given:
public class SampleClass {
public static void main(String[] args) {
AnotherSampleClass asc = new AnotherSampleClass();
SampleClass sc = new SampleClass();
// TODO code application logic here
}
}
class AnotherSampleClass extends SampleClass {
}
Which statement, when inserted into line "// TODO code application logic here ", is valid change?
|
Option A | asc = sc;
|
Option B | sc = asc;
|
Option C | asc = (object) sc;
|
Option D | asc = sc.clone ()
|
Correct Answer | B |
Explanation Explanation: Works fine. Incorrect answers: asc = sc.clone(); Incompatible types. asc =sc; Incompatible types. asc = (object) sc; Syntax error