New Semester
Started
Get
50% OFF
Study Help!
--h --m --s
Claim Now
Question Answers
Textbooks
Find textbooks, questions and answers
Oops, something went wrong!
Change your search query and then try again
S
Books
FREE
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Tutors
Online Tutors
Find a Tutor
Hire a Tutor
Become a Tutor
AI Tutor
AI Study Planner
NEW
Sell Books
Search
Search
Sign In
Register
study help
computer science
oracle
OCP Oracle Certified Professional Java SE 11 Developer Practice Tests Exam 1Z0 819 And Upgrade Exam 1Z0 817 1st Edition Scott Selikoff, Jeanne Boyarsky - Solutions
What is the output of the Plant program? class Bush extends Plant { String type="bush"; } public class Plant { } String type = "plant"; public static void main(String[] args) { Plant w1= new Bush(); Bush w2= new Bush(); Plant w3= w2; System.out.print(wl.type+", "+w2.type+", "+w3.type);
Which modifier can be applied to an abstract interface method? A. finalB. interfaceC. protectedD. voidE. None of the above
Which statements can accurately fill in the blanks in this table? (Choose two.) A. Blank 1: an instance method onlyB. Blank 1: a static method onlyC. Blank 1: an instance or static methodD. Blank 2: an instance method onlyE. Blank 2: a static method onlyF. Blank 2: an instance or static
What is true of the following code? (Choose three.) A. It compiles as is.B. It does not compile as is.C. Removing line 2 would create an additional compiler error.D. Removing line 2 would not create an additional compiler error.E. Removing the static modifier on line 3 would create an
What is the correct order of statements for a Java class file?A. import statements, package statement, class declarationB. package statement, class declaration, import statementsC. class declaration, import statements, package statementD. package statement, import statements, class
Which are true of the following? (Choose two.) A. The code compiles.B. One line doesn’t compile.C. Two lines don’t compile.D. If any constructors and/or methods that do not compile are removed, the remaining code prints a.E. If the code compiles or if any constructors/methods that do not
Which of the following class types cannot be marked final or abstract?A. static nested class.B. Local class.C. Anonymous class.D. Member inner class.E. All of the above can be marked final or abstract.
Which is the first line containing a compiler error? A. x1B. x2C. x3D. None of the above var title="Weather"; // line x1 var hot 100, var cold = 20; // line x2 = var f = 32, int c = 0; // line x3
Fill in the blanks: The ___________________ access modifier allows access to everything the ___________________ access modifier does and more. (Choose three.) A. package-private, protectedB. package-private, publicC. protected, package-privateD. protected, publicE. public,
How many of the following members of Telephone interface are public? A. Zero.B. One.C. Two.D. Three.E. Four.F. The code does not compile. public interface Telephone { static int call () { return 1; } default void dial () {} long answer(); String home = "555-555-5555"; }
How many lines will not compile? A. Zero B. OneC. TwoD. ThreeE. FourF. Five 12: public void print Varargs (String... names) { System.out.println (Arrays.toString (names)); 13: 14: } 15: public void printArray (String[] names) { System.out.println (Arrays.toString (names)); 16: 17: } 18:
Which best describes what the new keyword does?A. Creates a copy of an existing object and treats it as a new one.B. Creates a new primitive.C. Instantiates a new object.D. Switches an object reference to a new one.E. The behavior depends on the class implementation.
What is the minimum number of lines that need to be removed to make this code compile? A. 1.B. 2.C. 3.D. 4.E. The code compiles as is. @FunctionalInterface public interface Play { public static void baseball () {} private static void soccer () {} default void play() {} void fun(); }
Which of the following can include a static method in its definition? (Choose three.) A. InterfaceB. Anonymous classC. Abstract classD. Member inner classE. Local classF. static nested class
What change is needed to make Secret well encapsulated? A. Change number to use a protected access modifier.B. Change number to use a public access modifier.C. Declare a private constructor.D. Declare a public constructor.E. Remove the guess method.F. None. It is already well encapsulated.
Fill in the blanks: A class that defines an instance variable with the same name as a variable in the parent class is referred to as ___________________ a variable, while a class that defines a static method with the same signature as a static method in a parent class is referred to as
What is the output of the following application? A. TALLB. The code does not compile because of line w1.C. The code does not compile because of line w2.D. The code does not compile for another reason.E. The code compiles, but the application does not produce any output at runtime.F. None of
Which of the following are the best reasons for creating a public static interface method? (Choose two.)
Which line of code, inserted at line p1, causes the application to print 5? A. this(4);B. new Jump(4);C. this(5);D. rope = 4;E. super(4);F. super(5); package games; public class Jump { } private int rope = 1; protected boolean outside; public Jump () { // line pl } public Jump(int rope)
Which of the following is not a valid order for elements within a class?A. Constructor, instance variables, method declarationsB. Instance variables, static initializer constructor, method declarationsC. Method declarations, instance variables, constructorD. Instance initializer, constructor,
Which statement about the following program is correct? (Choose two.) A. The code does not compile because of line u1.B. The code does not compile because of line u2.C. The code does not compile because of line u3.D. The code does not compile because of line u4.E. At least three of the
Which of the following is not a reason to use encapsulation when designing a class?(Choose two.)A. Improve security.B. Increase concurrency and improve performance.C. Maintain class data integrity of data elements.D. Prevent users from modifying the internal attributes of a class.E. Prevent
Which is not a true statement given this diagram? Assume all classes are public.A. Instance methods in the Blanket class can call the Flashlight class’s turnOn().B. Instance methods in the Flashlight class can call the Flashlight class’s replaceBulb().C. Instance methods in the Phone class
Which of the following statements are correct? (Choose two.)A. Java allows multiple inheritance using two abstract classes.B. Java allows multiple inheritance using two interfaces.C. Java does not allow multiple inheritance.D. An interface can extend another interface.E. An interface can
Which statement about the following code is correct? A. The code contains an invalid constant.B. The method getSize() does not compile.C. The method getLength() does not compile.D. The method tryOn() does not compile.E. The code compiles.F. None of the above. public class Dress { int size =
What is the output of the following application? A. 2B. 5C. The first line with a compiler error is line q1.D. The first line with a compiler error is line q2.E. The first line with a compiler error is line q3. package pet; public class Puppy { public static int wag = 5; 5; // q1 public void
What is the output of the following application? A. 2B. 3C. 5D. 7E. The code does not compile.F. None of the above. package ocean; abstract interface CanSwim { public void swim (final int distance); } public class Turtle { } final int distance = 2; public static void main(String[] seaweed) {
Given the following method signature, which classes can call it? void run(String government) A. Classes in other packagesB. Classes in the same packageC. Subclasses in a different packageD. All classesE. None of the above
Which is the first declaration to not compile? A. The CanBurrow interface does not compile.B. The HasHardShell interface does not compile.C. The Tortoise interface does not compile.D. The DesertTortoise interface does not compile.E. All of the interfaces compile. package desert; interface
Which of the following are not valid variable names? (Choose two.) A. _ B. _blue C. 2blue D. blue$ E. Blue
What is the value of tip after executing the following code snippet? A. 1 B. 2 C. 3 D. 7 E. None of the above int meal = 5; int tip = 2; var total. meal+ (meal>6 ? tip++: tip--);
Which is the first line to not compile? A. Line m1B. Line m2C. Line m3D. Line m4E. None of the above interface Building { default Double getHeight () { return 1.0; } // m1 } interface Office { public default String getHeight() { return null; } // m2 } abstract class Tower implements Building,
What is the output of the following code snippet? A. 1B. 55C. 56D. It does not compile. String tree = "pine"; int count = 0; if (tree.equals("pine")) { } int height 55; count count + 1; System.out.print (height + count);
Which is equivalent to var q = 4.0f;? A. float q = 4.0f; B. Float q = 4.0f; C. double q = 4.0f; D. Double q = 4.0f; E. Object q = 4.0f;
What is the output of the following? A. 12 B. 123 C. 321 D. The code does not compile. 12: var b = "12"; 13: b = "3"; 14: b.reverse(); 15 : System.out.println(b.toString());
Which of the following are valid comments in Java? (Choose three.) A. /****** TODO */ B. # Fix this bug later C. 'Error closing pod bay doors D. / Invalid record / E. * Page not found */ // IGNORE ME F.
Given the following class, what should be inserted into the two blanks to ensure the class data is properly encapsulated? A. private and getStuffB. private and isStuffC. public and getStuffD. public and isStuffE. None of the above package storage; public class Box { } public String stuff; }
Which of the following modifiers can both be applied to a method? (Choose three.) A. private and finalB. abstract and finalC. static and privateD. private and abstractE. abstract and staticF. static and protected
Given the following Venn diagram and the boolean variables, apples, oranges, and bananas, which expression most closely represents the filled-in region of the diagram? apples oranges bananas A. apples && oranges && !bananas B. orange || (oranges && !bananas) C. (apples || bananas) && oranges D.
How many rows of the following table contain an error? A. ZeroB. OneC. TwoD. ThreeE. Four. Interface member Static method Private non-static method Abstract method Default method Private static method Membership type Class Class Instance Instance Class Requires method body? Yes Yes No No Yes
What is the output of the following? A. false 1B. false 2C. true 1D. true 2E. Does not compile 5: var line = new String("-"); 6: var anotherLine = line.concat(""); 7: System.out.print(line == another Line); 8: System.out.print(" "); 9: System.out.print(line.length());
What is the output of the Watch program? A. smart watch,watchB. watch,smart watchC. watch,watchD. The code does not compile.E. An exception is printed at runtime.F. None of the above. 1: class SmartWatch extends Watch { 2: 3: 4: 12: 13: 14: 15: 16: private String getType() { return "smart
Fill in the blanks: ___________________ is used to call a constructor in the parent class, while ___________________ is used to reference a member of the parent class.A. super and this()B. super and super()C. super() and thisD. super() and superE. None of the above
What is the output of the Movie program? A. SequelB. TrilogyC. RemakeD. AdaptationE. nullF. None of the above package theater; class Cinema { private String name = "Sequel"; public Cinema (String name) { this.name = name; } } } public class Movie extends Cinema { private String name =
The author of this method forgot to include the data type. Which of the following reference types can best fill in the blank to complete this method? A. String B. StringBuilder C. Both D. Neither public static void secret(. char ch mystery.charAt (3); mystery mystery.insert(1, "more");
Where can a final instance variable be assigned a value? (Choose three.) A. Instance initializerB. static initializerC. Instance methodD. On the line it is declaredE. Class constructorF. static method
What is the output of the following code? A. hophopB. HOPhopC. hopHOPD. HOPHOPE. The code does not compile. public class Bunny { } static interface Rabbit { } static class FlemishRabbit implements Rabbit { } private static void hop (Rabbit r) { System.out.print("hop"); } private static void
Which statement about encapsulation is not true? A. Encapsulation allows putting extra logic in the getter and setter methods.B. Encapsulation can use immutable instance variables in the implementation.C. Encapsulation causes two classes to be more tightly tied together.D. Encapsulation makes
What is the output of the following application? A. Play!B. Music!C. The code does not compile.D. The code compiles, but the answer cannot be determined until runtime. package radio; public class Song { public void playMusic() { System.out.print("Play!"); } } private static void playMusic() {
What is the output of the following? A. 333 B. 333 806 1601 C. The code compiles but outputs something else. D. The code does not compile. var teams = = new StringBuilder ("333"); teams.append(" 806"); teams.append(" 1601"); System.out.print(teams);
How lines of the following code do not compile? A. None, they all compileB. OneC. TwoD. ThreeE. FourF. Five or more 10: interface Flavor { 11: 12: 13: 14: public default void happy () { printFlavor ("Rocky road"); } private static void excited () { printFlavor ("Peanut butter"); 15: 16: 17:
Which of the following statements about overriding a method are correct? (Choose three.)A. The return types must be covariant.B. The access modifier of the method in the child class must be the same or narrower than the method in the superclass.C. The return types must be the same.D. A checked
Given the following method, what is the first line that does not compile? A. k1B. k2C. k3D. k4E. k5 public static void main(String[] args) { int Integer } 0; Integer int= 0; Integer ++; int++; int var = null; = // k1 // k2 // k3 // k4 // k5
Which of the following declarations does not compile? A. double num1, int num2 B. int num1, num2; C. int num1, num2 = 0; D. E. F. = 0; int num1 = 0, num2 = 0; All of the above None of the above
Of the following four modifiers, choose the one that is not implicitly applied to all interface variables.A. finalB. abstractC. staticD. public
What is the result of compiling and executing the following class? A. The code does not compile due to line x.B. The code does not compile due to line y.C. 31D. 61 public class Tolls { private static int yesterday = 1; int tomorrow = 10; } public static void main(String[] args) { var tolls =
What is the output of the following application? A. 0 FLURRYB. 1 FLURRYC. 0 SunnyD. 1 SunnyE. The code does not compile.F. None of the above. package weather; public class Forecast { public enum Snow { } } BLIZZARD, SQUALL, FLURRY @Override public String toString() { return "Sunny"; } public
Which of the following is not a true statement? A. The first line of every constructor is a call to the parent constructor via the super() command.B. A class is not required to have a constructor explicitly defined.C. A constructor may pass arguments to the parent constructor.D. A final
Fill in the blank with the line of code that allows the program to compile and print 10 at runtime. A. Whisper.d.getVolume()B. d.Whisper.getVolume()C. Whisper.super.getVolume()D. d.Whisper.super.getVolume()E. The code does not compile regardless of what is inserted into the blank.F. None of
How many lines does the following code output? A. One.B. Two.C. Three.D. Four.E. Five.F. None of the above. The code does not compile. public class Cars { static { } } private static void drive() { System.out.println("fast"); } System.out.println("static"); {System.out.println("faster"); }
What can fill in the blank so the play() method can be called from all classes in the com. mammal and com.mammal.eland package, but not the com.mammal.gopher package? package com.mammal; public class Enrichment { void play() {} } A. Leave it blank. B. private C. protected D. public E. None of the
Which of the following properties of an enum can be marked abstract? A. The enum type definitionB. An enum methodC. An enum valueD. An enum constructorE. None of the above
Suppose foo is a reference to an instance of a class Foo. Which of the following is not possible about the variable reference foo.bar? A. bar is an instance variable.B. bar is a static variable.C. bar is a local variable.D. It can be used to read from bar.E. It can be used to write to
The following diagram shows two reference variables pointing to the same Bunny object in memory. The reference variable myBunny is of type Bunny, while unknownBunny is a valid but unknown data type. Which statements about the reference variables are true? Assume the instance methods and variables
How many of these methods compile? A. ZeroB. OneC. TwoD. ThreeE. FourF. Five public class Singing { private void sing (String key) { } public void sing_do (String key, String... harmonies) { this.sing (key); } public void sing_re(int note, String... sound, String key) { this.sing (key); } }
Given the file Magnet.java shown, which of the marked lines can you independently insert the line var color; into and still have the code compile? // line al public class Magnet { // line a2 public void attach() { // line a3 } // line a4 } A. a2 B. a3 C. a2 and a3 D. al, a2, a3, and a4 E. None of
Given the following code, which lines when placed independently in the blank allow the code to compile and print bounce? (Choose two.) A. var new = TennisBall;B. TennisBall();C. var var = new TennisBall();D. new TennisBall;E. new TennisBall(); public class TennisBall { public TennisBall() {
Which of these are functional interfaces? A. LionB. TigerC. Both Lion and TigerD. Neither is a functional interface.E. The code does not compile. interface } Lion { public void roar(); default void drink() {} String toString(); interface Tiger { } public void roar (); default void drink() {}
Which of the following interface methods are inherited by classes that implement the interface? (Choose two.)A. private methodsB. private static methodsC. default methodsD. static methodsE. abstract methodsF. final methods
Which is one of the lines output by this code? A. [] B. [8, 10] C. [8, 9, 10] D. [10, 8] E. The code does not compile. 10: var list= new ArrayList (); 11: list.add (10); 12: list.add (9); 13: list.add(8); 14: 15: var num = 9; 16: list.removeIf (x -> {int keep = num; return x != keep;}); 17:
Which of the following can fill in the blank so the code prints true? var happy :) ( "; var really happy.trim(); var question = = System.out.println(really.equals(question)); A. happy.substring(0, B. happy.substring(0, C. happy.substring(1, D. happy.substring(1, happy.length() - 1) happy.
How many of the following lines contain a compiler error? A. 0B. 1C. 2D. 3E. 4 double num1 = 2.718; double num2 = 2._718; double num3 = 2.7_1_8; double num4 = _2.718;
What is the output of the following application? A. 2 5 B. 8 5 C. 6 5 D. The code does not compile. E. None of the above. public class Airplane { static int start = 2; final int end; } public Airplane (int x) { x = 4; end = x; } public void fly(int distance) { System.out.print (end-start+"
What is the output of the following class? A. 2B. 3C. 4D. None of the above 1: package rocket; 2: public class Countdown { 3: 4: 5: 6: 7: 8: } public static void main(String[] args) { var builder = "54321"; builder builder.substring(4); } System.out.println (builder.charAt(2));
What is the output of the following code snippet? A. true-2-trueB. false-2-falseC. true-2-falseD. true-3-falseE. true-3-trueF. false-3-false int height = 2, length boolean w = height > 1 | --length < 4; var x = height=2 ? length++: height; boolean z height% length = 3; == 0;
What is the output of the following? A. eB. dC. edD. None of the above 1: public class Legos { 2: 3: 4: 5: 6: 7: 8: 9: } public static void main(String[] args) { var sb = new StringBuilder(); sb.append("red"); sb.deleteCharAt(0); sb.delete (1, 2); System.out.println(sb); }
What is the output of the following application? A. 1 1 2B. 5 2 2C. 5 2 1D. 6 2 2E. 6 2 1F. The code does not compile. package world; public class Matrix { private int level = 1; class Deep { private int level = 2; class Deeper { } } private int level = 5; public void printReality (int
What is the output of the Rocket program? A. 2,5B. 3,4C. 5,2D. 3,5E. The code does not compile.F. None of the above. } package transport; class Ship { } protected int weight = 3; private int height = 5; public int getWeight() { return weight; } public int getHeight() { return height; }
Imagine you are working with another team to build an application. You are developing code that uses a class that the other team has not finished writing yet. You want to allow easy integration once the other team’s code is complete. Which statements would meet this requirement? (Choose
For the diagram in the previous question, how many classes can write code that references the light variable?A. NoneB. OneC. TwoD. ThreeE. Four com.color Red . protected boolean light Blue . void sky () m.light Bright Light extends Red com. Light
Given the following method signature, which classes cannot call it? protected void run(String government)A. All classes in other packagesB. All classes in the same packageC. Subclasses in a different packageD. Subclasses in the same package.
How many cells in the following table are incorrect? A. ZeroB. OneC. TwoD. ThreeE. Four Allows abstract methods? Type Abstract class Yes Concrete class Yes Interface Yes Allows constants? Yes Yes Yes Allows constructors? No Yes Yes
Which statements are true about a functional interface? (Choose three.)A. It may contain any number of abstract methods.B. It must contain a single abstract method.C. It may contain any number of private methods.D. It must contain a single private method.E. It may contain any number of static
What is a possible output of the following application? A. Your gift: wrap.Gift@29ca2745B. Your gift: Your gift:C. It does not compile.D. It compiles but throws an exception at runtime. package wrap; public class Gift { } private final Object contents; protected Object getContents() { return
Which variables have a scope limited to a method?A. Interface variablesB. Class variablesC. Instance variablesD. Local variables
How many compiler errors does the following code contain? A. NoneB. OneC. TwoD. ThreeE. Four package animal; interface CanFly { public void fly() {} } final class Bird { public int fly(int speed) {} } public class Eagle extends Bird implements CanFly { public void fly () {} }
Which of the following are the best reasons for creating a default interface method? (Choose two.) A. Allow interface methods to be overloaded.B. Add backward compatibility to existing interfaces.C. Give an interface the ability to create final methods.D. Allow an interface to define a method
What is the output of the following code? A. hophopB. HOPhopC. hopHOPD. HOPHOPE. The code does not compile. public class Bunny { static class Rabbit { void hop() { } } } } static class FlemishRabbit extends Rabbit { void hop() { System.out.print("HOP"); } System.out.print("hop"); } public
Which of the following statements is not true?A. An instance of one class may access an instance of another class’s attributes if it has a reference to the instance and the attributes are declared public.B. An instance of one class may access package-private attributes in a parent class,
Which of the following are valid class declarations? (Choose three.) A. class {} B. class river {} C. class Str3@m {} D. class Pond2$ {} E. class _var_ {} F. class 50cean {}
What is the output of the InfiniteMath program? A. 2.0B. 4.0C. 8.0D. The code does not compile.E. The code compiles but prints an exception at runtime.F. None of the above. class Math { public final double secret = 2; } class ComplexMath extends Math { public final double secret = 4; }
Given the following application, which diagram best represents the state of the mySkier, mySpeed, and myName variables in the main() method after the call to the slalom() method? package slopes; public class Ski { } private int age = 18; private static void slalom (Ski racer, int[] speed, String
What is the output of the following application? A. Honk(1)!B. Honk(3)!C. The code does not compile.D. The code compiles, but the output cannot be determined until runtime.E. None of the above. package zoo; public class Penguin { private int volume 1; private class Chick { } private static
Fill in the blank with the line of code that allows the program to compile and print E at runtime. A. Edible.getColor()B. Edible.super.getColor()C. super.Edible.getColor()D. super.getColor()E. The code does not compile regardless of what is inserted into the blank.F. None of the above.
Which can implement a functional interface?A. An anonymous classB. A top-level classC. A lambda expressionD. An anonymous class or a top-level classE. A top-level class or a lambda expressionF. An anonymous class, a top-level class, or a lambda expression
Given the following two classes, each in a different package, which line inserted into the code allows the second class to compile? A. static import clothes.Store.getClothes; B. import clothes.Store.*; C. import static clothes.Store.getClothes; D. import static clothes.Store; package clothes;
What is the output of the ElectricCar program? A. Driving vehicleB. Driving electric carC. Driving carD. The code does not compile.E. The code compiles but produces a ClassCastException at runtime.F. None of the above. package vehicles; class Automobile { private final String drive () {
Given the following class declaration, which options correctly declare a local variable containing an instance of the class? A. new Sunset() extends Sky {};B. new Sky();C. new Sky() {}D. new Sky() { final static int blue = 1; };E. The code does not compile regardless of what is placed in the
What is the output of the Encyclopedia program? A. Reading is fun!-papyrusB. Reading is fun!-celluloseC. null-papyrusD. null-celluloseE. The code does not compile.F. None of the above. package paper; abstract class Book { protected static String material = "papyrus"; public Book() {}
What does the following print? A. false, false, falseB. false, false, trueC. false, true, trueD. true, false, trueE. true, true, falseF. true, true, true interface Vehicle {} class Bus implements Vehicle {} public class Transport { public static void main(String[] args) { Bus bus new Bus();
Showing 800 - 900
of 1045
1
2
3
4
5
6
7
8
9
10
11
Step by Step Answers