Given:
11.
class Alpha {
12.
public void foo() { System.out.print("Afoo "); }
13.
}
14.
public class Beta extends Alpha {
15.
public void foo() { System.out.print("Bfoo "); }
16.
public static void main(String[] args) {
17.
Alpha a = new Beta();
18.
Beta b = (Beta)a;
19.
a.foo();
20.
b.foo();
21.
}
22.
}
What is the result?
A. Afoo AfooGiven:
1.
public class Breaker2 {
2.
static String o = "";
3.
public static void main(String[] args) {
4.
z:
5.
for(int x = 2; x < 7; x++) {
6.
if(x==3) continue;
7.
if(x==5) break z;
8.
o = o + x;
9.
}
10.
System.out.println(o);
11.
}
12.
}
What is the result?
A. 2Given:
11.
public interface A111 {
12.
String s = "yo";
13.
public void method1();
14.
}
17. interface B { }
20.
interface C extends A111, B {
21.
public void method1();
22.
public void method1(int x);
23.
}
What is the result?
A. Compilation succeeds.Given that t1 is a reference to a live thread, which is true?
A. The Thread.sleep() method can take t1 as an argument.Given:
10.
interface Foo {}
11.
class Alpha implements Foo {}
12.
class Beta extends Alpha {}
13.
class Delta extends Beta {
14.
public static void main( String[] args ) {
15.
Beta x = new Beta();
16.
// insert code here
17.
}
18.
}
Which code, inserted at line 16, will cause a java.lang.ClassCastException?
A. Alpha a = x;Given:
1.
public class Donkey {
2.
public static void main(String[] args) {
3.
boolean assertsOn = false;
4.
assert (assertsOn) : assertsOn = true;
5.
if(assertsOn) {
6.
System.out.println("assert is on");
7.
}
8.
}
9.
}
If class Donkey is invoked twice, the first time without assertions enabled, and the second time with assertions enabled, what are the results?
A. no outputGiven:
3.
class Employee {
4.
String name; double baseSalary;
5.
Employee(String name, double baseSalary) {
6.
this.name = name;
7.
this.baseSalary = baseSalary;
8.
}
9.
}
10.
public class SalesPerson extends Employee {
11.
double commission;
12.
public SalesPerson(String name, double baseSalary, double commission) {
13.
// insert code here
14.
}
15.
}
Which two code fragments, inserted independently at line 13, will compile? (Choose two.)
A. super(name, baseSalary);Given a correctly compiled class whose source code is:
1. package com.sun.sjcp;
2. public class Commander {
3. public static void main(String[] args) {
4. // more code here
5. }
6. }
Assume that the class file is located in /foo/com/sun/sjcp/, the current directory is /foo/, and that the classpath contains "." (current directory).
Which command line correctly runs Commander?
A. java CommanderGiven:
1 public class Score implements Comparable
3 public Score(int w, int l) { wins = w; losses = l; } 4 public int getWins() { return wins; }
5 public int getLosses() { return losses; }
6 public String toString() {
7 return "<" + wins + "," + losses + ">";
8 }
9 // insert code here
10 }
Which method will complete this class?
A. public int compareTo(Object o){/*more code here*/}Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following:
1.
import java.io.*;
2.
public class Maker {
3.
public static void main(String[] args) {
4.
File dir = new File("dir");
5.
File f = new File(dir, "f");
6.
}
7.
}
Which statement is true?
A. Compilation fails.Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only Oracle exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your 1Z0-851 exam preparations and Oracle certification application, do not hesitate to visit our Vcedump.com to find your solutions here.