Given:

What is the result?
Reveal answer details Close answer details
Correct answerD
Oracle · 1Z0-808
Preview real exam questions, verified answers and available explanations before choosing a study plan.
|
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerD
Single choice
Given: ![]() And given the code fragment: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerC
Single choice
Which of the following can fill in the blank in this code to make it compile? ![]() Reveal answer details Close answer detailsCorrect answerC Explanation From Java SE 8, we can use static and/or default methods in interfaces, but they should be non abstract methods. SO in this case using default in blank is completely legal. Hence option C is correct.
Single choice
Given the code fragment: ![]() What is the result if the integer aVar is 9? Reveal answer details Close answer detailsCorrect answerB
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerC
Single choice
Given: public static void main(String[] args) { int array[] = {0, 1, 2, 3, 4}; int key = 3; for (int pos = 0; pos < array.length; ++pos) { if (array[pos] == key) { break; } } System.out.print("Found " + key + "at " + pos); } } What is the result? Reveal answer details Close answer detailsCorrect answerC Explanation Explanation: The following line does not compile: The variable pos is undefined at this line, as its scope is only valid in the for loop. Any variables created inside of a loop are LOCAL TO THE LOOP.
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerC
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerE
Single choice
Given the code fragment: class Student { int rollnumber; String name; List cources = new ArrayList(); // insert code here public String toString() { return rollnumber + " : " + name + " : " + cources; } } And, public class Test { public static void main(String[] args) { List cs = newArrayList(); cs.add("Java"); cs.add("C"); Student s = new Student(123,"Fred", cs); System.out.println(s); } Which code fragment, when inserted at line // insert code here, enables class Test to print 123 : Fred : Reveal answer details Close answer detailsCorrect answerC Explanation Incorrect:
Single choice
Given the code fragment: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerC
Single choice
Given: ![]() What is result? Reveal answer details Close answer detailsCorrect answerC
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerC
Multiple choice
Which three statements are true about the structure of a Java class? (Choose three.) Reveal answer details Close answer detailsCorrect answersC, D, F
Single choice
Given: ![]() And given the code fragment: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerE
Single choice
Given the code fragment: ![]() Which code fragment at line 10 prints Welcome 100? ![]() Reveal answer details Close answer detailsCorrect answerB Explanation ![]()
Single choice
Given: ![]() Which inserted at line 11, will provide the following output? [21, 15, 11] Reveal answer details Close answer detailsCorrect answerC Explanation In output we can see that only odd numbers present, so we need to remove only even numbers to get expected output. From Java SE 8, there is new method call removelf which takes predicate object and remove elements which satisfies predicate condition. Predicate has functional method call take object and check if the given condition met or not, if met it returns true, otherwise false. Option C we have passed correct lambda expression to check whether the number is odd or even that matches to the functional method of predicate interface.
Single choice
Given: public class Test { public static void main(String[] args) { try { String[] arr =new String[4]; arr[1] = "Unix"; arr[2] = "Linux"; arr[3] = "Solarios"; for (String var : arr) { System.out.print(var + " "); } } System.out.print (e.getClass()); } } } What is the result? Reveal answer details Close answer detailsCorrect answerB Explanation Explanation: null Unix Linux Solarios The first element, arr[0], has not been defined.
Single choice
Given the following code: ![]() What is the output? Reveal answer details Close answer detailsCorrect answerE
Multiple choice
Given: ![]() Which two code fragments can be inserted at line n1? Reveal answer details Close answer detailsCorrect answersA, C
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerB
Multiple choice
Given the following segment of code: Which two statements, if either were true, would make the code compile? (Choose two.) Reveal answer details Close answer detailsCorrect answersB, C
Single choice
Given: class Sports { int num_players; String name, ground_condition; Sports(int np, String sname, String sground){ num_players = np; name = sname; ground_condition = sground; } } class Cricket extends Sports { int num_umpires; int num_substitutes; Which code fragment can be inserted at line //insert code here to enable the code to compile? Reveal answer details Close answer detailsCorrect answerA Explanation Incorrect:
Single choice
Given the code fragment: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerC
Single choice
Given the code fragment: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerA
Single choice
Given: ![]() What is the output? Reveal answer details Close answer detailsCorrect answerE Explanation Option E is the correct answer.
Single choice
Given the content of three files: ![]() Which statement is true? Which statement is true? Reveal answer details Close answer detailsCorrect answerA Explanation Explanation: In class B.Java doStuff() has access modifier with variable name which is not allowed. C.Java class name is different than file name. Only private classes can have different names than file names
Single choice
Which of the following will print current time? Reveal answer details Close answer detailsCorrect answerC Explanation The LocalTime is an interface, so we can't use new keyword with them. So options A and C are incorrect.
Multiple choice
Which two statements correctly describe checked exception? Reveal answer details Close answer detailsCorrect answersB, D Explanation Explanation: Checked exceptions: * a method is obliged to establish a policy for all checked exceptions thrown by its implementation (either pass the checked exception further up the stack, or handle it somehow) References:
Multiple choice
Given the code fragment: And given the requirements: Which two statements are true? (Choose two.) Reveal answer details Close answer detailsCorrect answersB, D
Multiple choice
Which three statements are true about exception handling? (Choose three.) Reveal answer details Close answer detailsCorrect answersC, E, F
Single choice
Consider Integer number = Integer.valueOff 808.1"); Which is true about the above statement? Reveal answer details Close answer detailsCorrect answerD Explanation The Integer class value of 0 returns an Integer from given string. But we need to pass string which has correct format for integer otherwise it will throw a NumberFormatException. In this case we have passed string which is not an integer value (since what we passed is fractional number), so option D is correct.
Single choice
Given the code fragment: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerC
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerB
Single choice
Given the code fragments: ![]() And, ![]() Which statement is true? Reveal answer details Close answer detailsCorrect answerC
Single choice
Given: public class Painting { private String type; public String getType() { return type; } public void setType(String type) { this.type = type; } public static void main(String[] args) { Painting obj1 = new Painting(); Painting obj2 = new Painting(); obj1.setType(null); obj2.setType("Fresco"); System.out.print(obj1.getType() + " : " + obj2.getType()); } } What is the result? Reveal answer details Close answer detailsCorrect answerB
Single choice
Given: ![]() Which code fragment, when inserted at line 9, enables the code to print true? Reveal answer details Close answer detailsCorrect answerA
Single choice
Given the code fragment: List colors = new ArrayList(); colors.add("green"); colors.add("red"); colors.add("blue"); colors.add("yellow"); colors.remove(2); colors.add(3,"cyan"); System.out.print(colors); What is the result? Reveal answer details Close answer detailsCorrect answerB
Single choice
Given the code fragment: ![]() Which modification enables the code fragment to print TrueDone? Reveal answer details Close answer detailsCorrect answerA
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerA
Single choice
Given: ![]() Which code fragment should you use at line n1 to instantiate the dvd object successfully? ![]() Reveal answer details Close answer detailsCorrect answerC
Single choice
Given: ![]() Reveal answer details Close answer detailsCorrect answerB
Multiple choice
Given: ![]() Which two code fragments are valid? ![]() Reveal answer details Close answer detailsCorrect answersB, C Explanation Explanation: When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class (C). However, if it does not, then the subclass must also be declared abstract (B). Note: An abstract class is a class that is declared abstract--it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.
Single choice
Given the code fragment: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerD
Single choice
Given the code fragment: ![]() Which two code fragments inserted at line 10 print ****? ![]() Reveal answer details Close answer detailsCorrect answerE Explanation ![]()
Single choice
Given the code fragments: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerE
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerC
Single choice
Given the code fragment: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerE
Single choice
Given the classes: * AssertionError * ArithmeticException * FileNotFoundException * IllegalArgumentException * IOError * IOException * NumberFormatException * SQLException Which option lists only those classes that belong to the unchecked exception category? Reveal answer details Close answer detailsCorrect answerA Explanation Explanation: Not B: IOError and IOException are both checked errors. Not C, not D, not E: Note:
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerC
Single choice
Given: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerE
Single choice
Given: public class Test { static boolean bVar; public static void main(String[] args) { boolean bVar1 = true; int count =8; do { System.out.println("Hello Java! " +count); if (count >= 7) { bVar1 = false; } count -= 2; } } What is the result? Reveal answer details Close answer detailsCorrect answerC Explanation Explanation: Hello Java! 8
Single choice
Given the code fragment int var2 = var1--; int var3 = 0; if (var2 < 0) { var3 = var2++; } else { var3 = --var2; } System.out.println(var3); What is the result? Reveal answer details Close answer detailsCorrect answerC
Single choice
Given the fragment: String[][] arra = new String[3][]; arra[0] = new String[]{"rose", "lily"}; arra[1] = new String[]{"apple", "berry","cherry","grapes"}; arra[0] = new String[]{"beans", "carrot","potato"}; // insert code fragment here Which code fragment when inserted at line '// insert code fragment here', enables the code to successfully change arra elements to uppercase? Reveal answer details Close answer detailsCorrect answerC Explanation Incorrect:
Single choice
Given the code fragment: String[] cartoons = {"tom","jerry","micky","tom"}; int counter =0; if ("tom".equals(cartoons[0])) { counter++; } else if ("tom".equals(cartoons[1])) { } else if ("tom".equals(cartoons[2])) { counter++; } else if ("tom".equals(cartoons[3])) { counter++; } System.out.print(counter); What is the result? Reveal answer details Close answer detailsCorrect answerA Explanation Explanation: Counter++ will be executed only once because of the else if constructs.
Single choice
Which usage represents a valid way of compiling java source file with the name "Main"? Reveal answer details Close answer detailsCorrect answerA Explanation Explanation: The compiler is invoked by the javac command. When compiling a Java class, you must include the file name, which houses the main classes including the Java extension. So to run Main.java file we have to use command in option A. TO execute Java program we can use Java command but can't use it for compiling.
Single choice
Given: ![]() Which statement is true? Reveal answer details Close answer detailsCorrect answerB
Multiple choice
Given the code fragment: ![]() Which two modifications should you make so that the code compiles successfully? ![]() Reveal answer details Close answer detailsCorrect answersA, C Explanation Add throws clause in both printFileContent and main.
Single choice
Given the code fragment: ![]() What is the result? Reveal answer details Close answer detailsCorrect answerD Explanation Explanation: ![]() |