1Z0-851 Exam Questions
190 real 1Z0-851 exam questions with expert-verified answers and explanations. Page 2 of 4.
- Question #51
Given: 11. static class A { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println("B"); } 16....
- Question #53
Given: public class TestOne implements Runnable { public static void main (String[] args) throws Exception { Thread t = new Thread(new TestOne()); t.start(); System.out.print("Star...
- Question #54
Click the Exhibit button. What is the output if the main() method is run?
- Question #55
Given: 1. public class TestFive { 2. private int x; 3. 4. public void foo() { 5. int current = x; 6. x = current + 1; 7. } 8. 9. public void go() { 10. for(int i = 0; i < 5; i++) {...
- Question #56
Given: public class Threads2 implements Runnable { public void run() { System.out.println("run."); throw new RuntimeException("Problem"); } public static void main(String[] args) {...
- Question #61
Given: public class TestString1 { public static void main(String[] args) { String str = "420"; str += 42; System.out.print(str); } } What is the output?
- Question #62
Given: 12. Date date = new Date(); 13. df.setLocale(Locale.ITALY); 14. String s = df.format(date); The variable df is an object of type DateFormat that has been initialized in line...
- Question #63
Given: 1. public class KungFu { 2. public static void main(String[] args) { 3. Integer x = 400; 4. Integer y = x; 5. x++; 6. StringBuilder sb1 = new StringBuilder("123"); 7. String...
- Question #64
Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following: import java.io.*; public class Maker { publi...
- Question #65
Given: 12. String csv = "Sue,5,true,3"; 13. Scanner scanner = new Scanner( csv ); 14. scanner.useDelimiter(","); 15. int age = scanner.nextInt(); What is the result?
- Question #66
Given that t1 is a reference to a live thread, which is true?
- Question #67
Given that Triangle implements Runnable, and: 31. void go() throws Exception { 32. Thread t = new Thread(new Triangle()); 33. t.start(); 34. for(int x = 1; x < 100000; x++) { 35. /...
- Question #68
Given: public class Threads3 implements Runnable { public void run() { System.out.print("running"); } public static void main(String[] args) { Thread t = new Thread(new Threads3())...
- Question #70
Given: public class PingPong implements Runnable { synchronized void hit(long n) { for(int i = 1; i < 3; i++) System.out.print(n + "-" + i + " "); } public static void main(String[...
- Question #71
Given: interface A { void x(); } class B implements A { public void x() {} public void y() {} } class C extends B { public void x() {} } and: 20. java.util.List<A> list = new java....
- Question #72
Given: class Mammal { } class Raccoon extends Mammal { Mammal m = new Mammal(); } class BabyRaccoon extends Mammal { } Which four statements are true? (Choose four.)
- Question #73
Given: 10: public class Hello { 11: String title; 12: int value; 13: public Hello() { 14: title += " World"; 15: } 16: public Hello(int value) { 17: this.value = value; 18: title =...
- Question #74
Given: class ClassA { public int numberOfInstances; protected ClassA(int numberOfInstances) { this.numberOfInstances = numberOfInstances; } } public class ExtendedA extends ClassA...
- Question #75
Given: 1. public class Target { 2. private int i = 0; 3. public int addOne() { 4. return ++i; 5. } 6. } And: 1. public class Client { 2. public static void main(String[] args){ 3....
- Question #76
Given: 01. public class Blip { 02. protected int blipvert(int x) { return 0; } 03. } 04. class Vert extends Blip { 05. // insert code here 06. } Which five methods, inserted indepe...
- Question #77
Given: class Pizza { java.util.ArrayList toppings; public final void addTopping(String topping) { toppings.add(topping); } } public class PepperoniPizza extends Pizza { public void...
- Question #78
Given: class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 =...
- Question #79
Given two files, GrizzlyBear.java and Salmon.java: 01. package animals.mammals; 02. 03. public class GrizzlyBear extends Bear { 04. void hunt() { 05. Salmon s = findSalmon(); 06. s...
- Question #80
Given: package com.company.application; public class MainClass { public static void main(String[] args) {} } And MainClass exists in the /apps/com/company/application directory. As...
- Question #81
Click the Exhibit button. Which three code fragments, added individually at line 29, produce the output 100? (Choose three.)
- Question #82
A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar. Which three, taken independently, will allow the devel...
- Question #83
Given: 1. interface DeclareStuff { 2. public static final int EASY = 3; 3. 4. void doStuff(int t); 5. } 6. 7. public class TestDeclare implements DeclareStuff { 8. public static vo...
- Question #84
Given: 12. public class Commander { 13. public static void main(String[] args) { 14. String myProp = /* insert code here */ 15. System.out.println(myProp); 16. } 17. } and the comm...
- Question #85
Given: public class Spock { public static void main(String[] args) { Long tail = 2000L; Long distance = 1999L; Long story = 1000L; if((tail > distance) ^ ((story * 2) == tail)) Sys...
- Question #87
Click the Exhibit button. What is the result?
- Question #88
Given: 1. public class Plant { 2. private String name; 3. 4. public Plant(String name) { 5. this.name = name; 6. } 7. 8. public String getName() { 9. return name; 10. } 11.} 1. pub...
- Question #89
Given: 11. public enum Title { 12. MR("Mr."), MRS("Mrs."), MS("Ms."); 13. private final String title; 14. private Title(String t) { title = t; } 15. public String format(String las...
- Question #90
Click the Exhibit button. Given: A a = new A(); System.out.println(a.doit(4, 5)); What is the result?
- Question #91
Given: 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...
- Question #92
Given: 01. interface TestA { String toString(); } 02. 03. public class Test { 04. public static void main(String[] args) { 05. System.out.println(new TestA() { 06. public String to...
- Question #93
Given: public class Drink implements Comparable { public String name; public int compareTo(Object o) { return 0; } } and: Drink one = new Drink(); Drink two = new Drink(); one.name...
- Question #94
Given: 08. abstract public class Employee { 09. protected abstract double getSalesAmount(); 10. 11. public double getCommision() { 12. return getSalesAmount() * 0.15; 13. } 14. } 1...
- Question #95
Given: import java.util.*; public class Mapit { public static void main(String[] args) { Set<Integer> set = new HashSet<Integer>(); Integer i1 = 45; Integer i2 = 46; set.add(i1); s...
- Question #96
Click the Exhibit button. What is the result?
- Question #97
Given: 1. d is a valid, non-null Date object 2. df is a valid, non-null DateFormat object set to the current locale What outputs the current locale's country name and the appropria...
- Question #99
Given: 1. import java.util.*; 2. 3. public class Explorer3 { 4. public static void main(String[] args) { 5. TreeSet<Integer> s = new TreeSet<Integer>(); 6. TreeSet<Integer> subs =...
- Question #100
Given: public class BuildStuff { public static void main(String[] args) { Boolean test = new Boolean(true); Integer x = 343; Integer y = new BuildStuff().go(test, x); System.out.pr...
- Question #101
Given: import java.util.*; public class Explorer1 { public static void main(String[] args) { TreeSet<Integer> s = new TreeSet<Integer>(); TreeSet<Integer> subs = new TreeSet<Intege...
- Question #102
Given: 23. Object [] myObjects = { 24. new Integer(12), 25. new String("foo"), 26. new Integer(5), 27. new Boolean(true) 28. }; 29. Arrays.sort(myObjects); 30. for(int i=0; i<myObj...
- Question #104
Given: Float pi = new Float(3.14f); if (pi > 3) { System.out.print("pi is bigger than 3. "); } else { System.out.print("pi is not bigger than 3. "); } finally { System.out.println(...
- Question #105
Given: public static void main(String[] args) { try { args = null; args[0] = "test"; System.out.println(args[0]); } catch (Exception ex) { System.out.println("Exception"); } catch...
- Question #107
Given: public class Test { public enum Dogs {collie, harrier}; public static void main(String [] args) { Dogs myDog = Dogs.collie; switch (myDog) { case collie: System.out.print("c...
- Question #108
Click the Exhibit button. Given: public void method() { A a = new A(); a.method1(); } Which statement is true if a TestException is thrown on line 3 of class B?
- Question #109
Given: 01. public class Boxer1{ 02. Integer i; 03. int x; 04. public Boxer1(int y) { 05. x = i+y; 06. System.out.println(x); 07. } 08. public static void main(String[] args) { 09....
- Question #111
Given: 1. public class Venus { 2. public static void main(String[] args) { 3. int[] x = { 1, 2, 3 }; 4. int y[] = { 4, 5, 6 }; 5. new Venus().go(x, y); 6. } 7. 8. void go(int[]......