Given:
5.
class A {
6.
void foo() throws Exception { throw new Exception(); }
7.
}
8.
class SubB2 extends A {
9.
void foo() { System.out.println("B "); }
10.
}
11.
class Tester {
12.
public static void main(String[] args) {
13.
A a = new SubB2();
14.
a.foo();
15.
}
16.
}
What is the result?
A. BGiven:
34.
HashMap props = new HashMap();
35.
props.put("key45", "some value");
36.
props.put("key12", "some other value");
37.
props.put("key39", "yet another value");
38.
Set s = props.keySet();
39.
// insert code here
What, inserted at line 39, will sort the keys in the props HashMap?
A. Arrays.sort(s);Given:
1.
package geometry;
2.
public class Hypotenuse {
3.
public InnerTriangle it = new InnerTriangle();
4.
class InnerTriangle {
5.
public int base;
6.
public int height;
7.
}
8.
}
Which statement is true about the class of an object that can reference the variable base?
A. It can be any class.Given:
1.
interface DoStuff2 {
2.
float getRange(int low, int high); }
3.
4.
interface DoMore {
5.
float getAvg(int a, int b, int c); }
6.
7.
abstract class DoAbstract implements DoStuff2, DoMore { } 8.
9.
class DoStuff implements DoStuff2 {
10.
public float getRange(int x, int y) { return 3.14f; } } 11.
12.
interface DoAll extends DoMore {
13.
float getAvg(int a, int b, int c, int d); }
What is the result?
A. The file will compile without error.Given a pre-generics implementation of a method:
11 public static int sum(List list) {
12 int sum = 0;
13 for ( Iterator iter = list.iterator(); iter.hasNext(); ) { 14 int i = ((Integer)iter.next()).intValue(); 15 sum += i;
16 }
17 return sum;
18 }
What three changes allow the class to be used with generics and avoid an unchecked warning? (Choose three.)
A. Remove line 14.Given:
11.
Float pi = new Float(3.14f);
12.
if (pi > 3) {
13.
System.out.print("pi is bigger than 3. ");
14.
}
15.
else {
16.
System.out.print("pi is not bigger than 3. ");
17.
}
18.
finally {
19.
System.out.println("Have a nice day.");
20.
}
What is the result?
A. Compilation fails.Given:
11.
public static void main(String[] args) {
12.
String str = "null";
13.
if (str == null) {
14.
System.out.println("null");
15.
} else (str.length() == 0) {
16.
System.out.println("zero");
17.
} else {
18.
System.out.println("some");
19.
}
20.
}
What is the result?
A. nullGiven:
10. interface Jumper { public void jump(); } ...
20. class Animal {} ...
30.
class Dog extends Animal {
31.
Tail tail; 32. } ...
40.
class Beagle extends Dog implements Jumper{
41.
public void jump() {}
42.
} ...
50.
class Cat implements Jumper{
51.
public void jump() {}
52.
}
Which three are true? (Choose three.)
A. Cat is-a AnimalWhich two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object? (Choose two.)
A. When using versions of Java technology earlier than 5.0.Given:
11.
class ClassA {}
12.
class ClassB extends ClassA {}
13.
class ClassC extends ClassA {} and:
21.
ClassA p0 = new ClassA();
22.
ClassB p1 = new ClassB();
23.
ClassC p2 = new ClassC();
24.
ClassA p3 = new ClassB();
25.
ClassA p4 = new ClassC();
Which three are valid? (Choose three.)
A. p0 = p1;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.