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 following? A. [3, three, THREE]B. [3, THREE, three]C. [three, THREE, 3]D. [THREE, three, 3]E. None of the above var threes = Arrays.asList ("3", "three", "THREE"); Collections.sort (threes); System.out.println(threes);
How many of these allow inserting null values: ArrayList, LinkedList, HashSet, and TreeSet?A. 0B. 1C. 2D. 3E. 4
How many dimensions does the array reference moreBools allow? boolean[] [] [] bools, moreBools; A. One dimensionB. Two dimensionsC. Three dimensionsD. None of the above
Given that Integer and Long are direct subclasses of Number, what type can be used to fill in the blank in the following class to allow it to compile? A. LongB. IntegerC. Long or IntegerD. Long or NumberE. Long, Integer, or NumberF. None of the above package orchestra; interface MusicCreator
Which changes made to the following class would help to properly encapsulate the data in the class? A. Add a getter method for material.B. Add a setter method for material.C. Change the access modifier of material to protected.D. Change the access modifier of strength to private.E. None of
What is output by the following?A. 3 10 B. 3 12 C. 5 10 D. 5 12 E. The code does not compile. F. None of the above. 10: int m = 0, n = 0; 11: while (m < 5) { 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: n++; if (m == 3) continue; switch (m) { case 0: case 1: n++; default: n++; } m++; 24:
Which of the following rules about a default branch in a switch statement are correct? (Choose two.) A. A switch statement is required to declare a default statement. B. A default statement must be placed after all case statements. C. A default statement can be placed between any case
Which are true statements comparing for-each and traditional for loops? (Choose two.) A. Both can iterate through an array starting with the first element. B. Only the for-each loop can iterate through an array starting with the first element. C. Only the traditional for loop can iterate through
What happens when running the following code snippet? A. It completes successfully without output. B. It outputs helium once. C. It outputs helium repeatedly. D. Line 6 does not compile. E. None of the above. 3: var gas = true; 4: do ( 5: System.out.println("helium"); gas gas; 6: gas 7: gas =
Variables declared as which of the following are never permitted in a switch statement? (Choose two.) A. var B. double C. int D. String E. char F. Object
Given the following, which can fill in the blank and allow the code to compile? (Choose three.) var quest = for (var zelda : quest) { System.out.print(zelda); }
What does the following method output? A. The code does not compile. B. The method completes with no output. C. The method prints 0 and then terminates. D. The method enters an infinite loop. E. None of the above. void dance() { var singer = 0; while (singer) System.out.print (singer++);
What is the output of the following application? A. Plan AB. Plan BC. Plan CD. The class does not compile.E. None of the above. package planning; public class ThePlan { } public static void main(String[] input) { var plan = 1; plan = plan+++ --plan; if (plan==1) { System.out.print("Plan A"); }
What is true about the following code? (Choose two.) A. It outputs x.B. It does not compile.C. It is an infinite loop.D. With lines 25 and 28 removed, it outputs x.E. With lines 25 and 28 removed, it does not compile.F. With lines 25 and 28 removed, it is an infinite loop. 23: var race = 24: loop:
Which of the following can replace the body of the perform() method to produce the same output on any nonempty input? (Choose two.) public void perform (String[] circus) { for (int i-circus.length-1; i>=0; i--) System.out.print(circus [i]); }
What does the following code snippet output? var bottles - List.of("glass", "plastic", "can"); for (int type = 1; type < bottles.size();) { System.out.print (bottles.get(type) + "-"); if (type < bottles.size()) break; } System.out.print("end"); A. glass-end B. C. plastic-end D. plastic-can-end E.
What is the result of executing the following code snippet? A. 1-B. 1-2-C. 2-D. 3-E. 4-F. None of the above. final var GOOD = 100; var score = 10; switch (score) { default: 1: System.out.print("1-"); -1: System.out.print("2-"); break; 4,5 System.out.print("3-"); 6: System.out.print("4-"); 9:
What is the output of the following application? A. 2 B. 3 C. 4 D. The code does not compile. E. The code compiles but throws an exception at runtime. package dinosaur; public class Park { public final static void main(String... arguments) { int pterodactyl = 8; long triceratops = 3; if
What variable type of red allows the following application to compile? package tornado; public class Kansas { public static void main(String[] args) { int colorOfRainbow = 10; red = 5; switch(colorOfRainbow) { } } hanged } default: System.out.print("Home"); break; case red:
How many lines of the magic() method contain compilation errors? A. Zero B. One C. Two D. Three E. Four 10: public void magic() { 11: do { 12: 13: 14: 15: 16: 17: 18: 19: } int trick = 0; LOOP: do { trick++; } while (trick < 2--); continue LOOP; } while (1 > 2); System.out.println(trick);
How many of these statements can be inserted after the println to have the code flow follow the arrow in this diagram? A. One B. Two C. Three D. Four E. Five F. None of above break; break letters; break numbers; continue; continue letters; continue numbers; letters: for (char ch = 'a'; ch
What is the output of the following application? A. 1B. 2C. 3D. The code does not compile because var cannot be used in a switch statement.E. The code does not compile for another reason.F. None of the above. package dessert; public class IceCream { } public final static void main(String... args)
Which of the following statements compile and create infinite loops at runtime? (Choose two.) A. while (! false) {} B. do {} C. for() {} D. do {} while (true); E. while {} F. for(;;) {}
Which of the following iterates a different number of times than the others? A. for (int k=0; k < 5; k++) {} B. for (int k=1; k
What is the output of the following code snippet? A. 0B. 1C. 2D. 3E. The code does not compile.F. None of the above. int count 0; var stops = new String[] { "Washington", "Monroe", "Jackson", "LaSalle" }; = while (count < stops.length) if (stops [++count].length() < 8) break; else continue;
What is the output of the following code snippet? int hops = 0; int jumps = 0; jumps = hops++; if (jumps) System.out.print("Jump!"); else System.out.print("Hop!"); A. Jump! B. Hop! C. The code does not compile. D. The code compiles but throws an exception at runtime. E. None of the above.
Which of the following best describes the flow of execution in this for loop if beta always returns false? for (alpha; beta; gamma) { delta; } A. alpha B. alpha, beta C. alpha, beta, gamma. D. alpha, gamma E. alpha, gamma, beta None of the above F.
What is the output of the following code snippet? A. done B. inflate-doneC. The code does not compile. D. This is an infinite loop. E. None of the above. boolean balloonInflated = false; do { if (!balloonInflated) { balloonInflated = true; System.out.print("inflate-"); } } while (!
Which of these code snippets behaves differently from the others? A. if (numChipmunks == if (numChipmunks 1) System.out.println("One chipmunk"); System.out.println("Two chipmunks"); if (numChipmunks == 3) System.out.println("Three chipmunks"); 2) B. switch (numChipmunks) { case 1:
Given the following enum and class, which option fills in the blank and allows the code to compile? enum Season { SPRING, SUMMER, WINTER } public class Weather { } public int getAverage Temperate (Season s) { switch (s) { default: } } return 30;
Which statements about loops are correct? (Choose three.) A. A do/while loop requires a body. B. A while loop cannot be exited early with a return statement. C. A while loop requires a conditional expression. D. A do/while loop executes the body (if present) at least once. E. A do/while loop
Fill in the blank with the line of code that causes the application to compile and print exactly one line at runtime. package nyc; public class TourBus { public static void main(String... args) { var nycTour = new String[] { "Downtown", "Uptown", "Brooklyn" }; } var times = new String[] { "Day",
The code contains six pairs of curly braces. How many pairs can be removed without changing the behavior? A. One B. Two C. Three D. Four E. Five F. Six 12: public static void main(String[] args) { int secret = 0; 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: } for (int i= 0; i <
Given the diagram in the previous question, how many of the classes shown in the diagram can call the display() method? A. ZeroB. OneC. TwoD. ThreeE. Four m.light Flashlight com. private replaceBulb () public turnon () Phone protected display() public charge () com.dark Blanket wash() Tent
Which of the following results is not a possible output of this program? A. WEST is printed.B. south is printed.C. An ArrayIndexOutOfBoundsException is thrown at runtime.D. An IllegalArgumentException is thrown at runtime.E. All of the above are possible. package sea; enum Direction { north,
What is the output of the RightTriangle program? package shapes; A. rtB. irtC. The code does not compile due to line g1.D. The code does not compile due to line g2.E. The code does not compile due to line g3.F. None of the above. abstract class Triangle { abstract String getDescription(); }
Which of the following are advantages of using enumerated types in Java, rather than static constant values? (Choose three.) A. Improve performance.B. Provide access to fixed set of constants whose values do not change during the course of the application.C. Provide a caller with a list of
How do you force garbage collection to occur at a certain point? A. Calling System.forceGc()B. Calling System.gc()C. Calling System.requireGc()D. Calling GarbageCollection.clean()E. None of the above
Given the following two classes, each in a different package, which line inserted into the code allows the second class to compile? A. import static commerce.Bank.*;B. import static commerce.Bank;C. static import commerce.Bank.*;D. static import commerce.Bank;E. None of the above package
Which are true statements about referencing variables from a lambda? (Choose two.)A. Instance and static variables can be used regardless of whether effectively final.B. Instance and local variables can be used regardless of whether effectively final.C. Instance variables and method parameters
Given the following structure, which snippets of code return true? (Choose three.) A. new Coral() instanceof Friendly B. null instanceof ObjectC. new Coral() instanceof ObjectD. new Fish() instanceof FriendlyE. new Whale() instanceof ObjectF. new Dolphin() instanceof Friendly interface
What is true of the following code? A. It prints 20 20 20B. It prints 20 20 75C. It prints 20 21 75D. It prints 21 21 75E. It does not compile due to setNumDays().F. It does not compile for another reason. } public class Eggs { enum Animal { } CHICKEN (21), PENGUIN (75); private int numDays;
What statement about the following interface is correct? A. Line 2 does not compile.B. Line 3 does not compile.C. Line 4 does not compile.D. Line 5 does not compile.E. Line 6 does not compile.F. Line 7 does not compile.G. All of the lines compile. 1: public interface Thunderstorm { float
What is the output of the following application? A. -1B. 0C. 1D. The Provider class does not compile.E. The Bank class does not compile.F. None of the above. package finance; enum Currency { DOLLAR, YEN, EURO } abstract class Provider { protected Currency c= Currency. EURO; } public class
How many lines need to be removed for this code to compile? A. ZeroB. OneC. TwoD. ThreeE. FourF. Five 1: package figures; 2: public class Dolls { 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:} public int num() { return 3.0; } public int size() { return 5L; } public void nested () { nested (2, true);
Fill in the blanks: A class may be assigned to a(n) ___________________ reference variable automatically but requires an explicit cast when assigned to a(n) ___________________ reference variable.A. subclass, outer classB. superclass, subclassC. concrete class, subclassD. subclass,
What are possible outputs of the following given that the comment on line X can be replaced by code? A. 0B. 5C. Either 0 or 5D. Any int valueE. Does not compile. // Mandrill.java public class Mandrill { public int age; } public Mandrill(int age) { this.age = age; } } public String toString()
Which statement about functional interfaces is incorrect?A. A functional interface can have any number of static methods.B. A functional interface can have any number of default methods.C. A functional interface can have any number of private static methods.D. A functional interface can have
How many of the String objects are eligible for garbage collection right before the end of the main() method? A. NoneB. OneC. TwoD. ThreeE. None of the above public static void main(String[] ohMy) { String animal1 = new String("lion"); String animal2= new String("tiger"); String animal3 = new
Suppose Panther and Cub are interfaces and neither contains any default methods. Which statements are true? (Choose two.) A. If Panther has a single abstract method, Cub is guaranteed to be a functional interface.B. If Panther has a single abstract method, Cub may be a functional
What does the following output? A. blockB. constructorC. instanceD. The code does not compile.E. None of the above. 1: public class InitOrder public String first public InitOrder () { 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:} = "instance"; first = "constructor"; } { first = "block"; } public
A local class can access which type of local variables? (Choose two.) A. finalB. privateC. effectively finalD. staticE. defaultF. const
Which statement about the following interface is correct? A. The code compiles.B. The method produceSap() does not compile.C. The method getNumberOfRings() does not compile.D. The method growLeaves() does not compile.E. The method getHeight() does not compile. F. The code does not compile
Which statements about a variable with a type of var are true? (Choose two.)A. The variable can be assigned null at any point in the program.B. The variable can be assigned null only after initial initialization.C. The variable can never be assigned null.D. Only primitives can be used with the
Assume there is a class Bouncer with a protected variable. Methods in which class can access this variable?A. Any subclass of Bouncer or any class in the same package as BouncerB. Any superclass of BouncerC. Only subclasses of BouncerD. Only classes in the same package as BouncerE. None of the
What is the output of the following application? A. 8 B. Line p1 contains a compiler error. C. Line p2 contains a compiler error. D. Another line of code contains a compiler error. E. None of the above. package forest; public class Woods { } static class Tree {} public static void main(String[]
Which can fill in the blank to make the code compile? (Choose two.) A. class Quokka extendsB. class Quokka implementsC. Neither A norB. Only one interface can be specified.D. interface Quokka extendsE. interface Quokka implementsF. Neither D norE. Only one interface can be specified.
What is true of the following method? A. It is a correctly implemented accessor method.B. It is a correctly implemented mutator method.C. It is an incorrectly implemented accessor method.D. It is an incorrectly implemented mutator method.E. None of the above. public void setColor (String
What is the result of compiling and executing the following class? A. The code does not compile.B. 4C. 5D. 10E. 20 public class RollerSkates { static int wheels = 1; int tracks = 5; public static void main(String[] arguments) { RollerSkates s= new Roller Skates (); } } int feet-4, tracks =
Which of the following statements about calling this() in a constructor are true? (Choose three.)A. If arguments are provided to this(), then there must be a constructor in the class able to take those arguments.B. If arguments are provided to this(), then there must be a constructor in the
Which statements about the following program are correct? (Choose two.) A. The code does not compile because of line m1.B. The code does not compile because of line m2.C. The code does not compile because of line m3.D. The code does not compile because of line m4.E. The code does not compile
Which statements about top-level and member inner classes are correct? (Choose three.)A. Both can be marked protected.B. Only top-level classes can be declared final.C. Both can declare constructors.D. Member inner classes cannot be marked private.E. Member inner classes can access private
What is required to define a valid Java class file? A. A class declarationB. A package statementC. An import statementD. A class declaration and package statementE. A class declaration and at least one import statementF. The public modifier
How many objects are eligible for garbage collection right before the end of the main() method? A. None.B. One.C. Two.D. Three.E. The code does not compile. 1: public class Person { 2: public Person youngest Child; 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: } } public static void main (String... args)
What is the output of the following application? A. 5B. 10C. 15D. The code does not compile.E. The answer cannot be determined with the information given. package race; interface Drive { int SPEED = 5; default int getSpeed () { return SPEED; } } interface Hover { int MAX_SPEED = 10; default
What is the output of the following application? (Choose two.) A. 2B. 3C. 5D. 6E. 8 1: public class ChooseWisely { 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:} public ChooseWisely () { super(); } public int choose (int choice) { return 5; } public int choose (short choice) { return 2; } public
How many lines of the following program do not compile? A. ZeroB. OneC. TwoD. ThreeE. More than three. 1: public enum Color { 2: 3: 4: 5: 6: 7: 8: 9: } RED (1,2) { void toSpectrum () {} }, BLUE (2) { void toSpectrum () {} void printColor() {} }, ORANGE () { void toSpectrum () {} }, GREEN (4);
What can fill in the blank so the play() method can be called from all classes in the com. mammal package, but not the com.mammal.gopher package? A. Leave it blank.B. privateC. protectedD. publicE. None of the above. package com.mammal; public class Enrichment { void play() {} }
What is the output of the Square program? A. 0B. 2C. 4D. The code does not compile due to line x1.E. The code does not compile due to line x2.F. The code does not compile due to line x3. package shapes; abstract class Trapezoid { private int getEqual Sides() {return 0;} } abstract class
Fill in the blanks: It is possible to extend a(n) ______________ but not a(n) ______________. (Choose two.) A. interface, abstract classB. anonymous class, static nested classC. abstract class, enumD. enum, interfaceE. abstract class, interfaceF. local class, anonymous class.
Which of the following can replace the body of the travel() method to produce the same output on any nonempty input? public void travel (List roads) { for (int w= 1; w 0; t--) System.out.print(roads.get(t)); D. for (var var: roads) System.out.print (roads); E. for (int q = roads.size() ; q >= 0;
Which statement about the following code snippet is correct? A. One line does not compile.B. Two lines do not compile.C. Three lines do not compile.D. It compiles and prints two lines at runtime.E. It compiles and prints three lines at runtime.F. None of the above. 3: final var java Versions =
What is the output of the following application? A. 3B. 9C. 93D. The code does not compile because of line g1.E. The code does not compile because of line g2.F. None of the above. package dnd; final class Story { void recite (int chapter) throws Exception {} } public class Adventure extends Story
Which of the following lines of code are not permitted as the first line of a Java class file? (Choose two.) A. import widget. *; B. // Widget Manager C. int facilityNumber; D. package sprockets; E. /** Author: Cid **/ F. void produce () {}
What is the result of compiling and executing the following class? A. It compiles and outputs 5.B. It compiles and outputs 15.C. It does not compile.D. It compiles but throws an exception at runtime. 1: public class ParkRanger { int birds 10; 2: 3: 4: 5: 6: 7: } public static void main(String[]
Which of the following modifiers can be applied to an abstract method? (Choose two.) A. finalB. privateC. publicD. defaultE. protectedF. concrete
Fill in the blanks: The ___________________ access modifier allows access to everything the ___________________ access modifier does and more. A. package-private, protectedB. private, package-privateC. private, protectedD. private, publicE. public, privateF. None of the above
A. package-private, protected B. private, package-private C. private, protected D. private, public E. public, private F. None of the above A. constB. finalC. staticD. privateE. private staticF. None of the above
Given the following application, fill in the missing values in the table starting from the top and going downward. A. 2, 0, 1B. 2, 2, 1C. 1, 0, 1D. 0, 2, 1 package competition; public class Robot { } static String weight = "A lot"; double ageMonths = 5, ageDays = 2; private static boolean success
Given the following code, what values inserted, in order, into the blank lines allow the code to compile? (Choose two.) A. package, new, intB. package, class, longC. import, class, nullD. //, class, intE. import, interface, voidF. package, class, void public } agent; } Banker { private static
Which of the following are correct? (Choose two.) public class Phone { private int size; // insert constructor here public static void sendHome (Phone p, int newSize) { p = new Phone (newSize); p.size = 4; } public static final void main(String... params) { final var phone = new Phone (3);
Given the following class structures, which lines can be inserted into the blank independently that would allow the class to compile? (Choose two.) A. dino.Pterodactyl()B. Dinosaur.new Pterodactyl()C. dino.new Pterodactyl()D. new Dino().new Pterodactyl()E. new Dinosaur().Pterodactyl()F. new
What is the output of the Computer program? A. computer-laptopB. laptop-computerC. laptop-laptopD. The code does not compile.E. None of the above. class Laptop extends Computer { public void startup() { System.out.print("laptop-"); } } public class Computer { public void startup() { }
How many lines does the following code output? A. One.B. Two.C. Three.D. Four.E. None of the above. The code does not compile. public class Cars { private static void drive() { static { } } System.out.println ("static"); System.out.println("fast"); { System.out.println ("faster"); } } public
What access modifier is used to mark class members package-private? A. default B. friend C. protected D. private E. None of the above
Which statements about static interface methods are correct? (Choose three.) A. A static interface method can be final.B. A static interface method can be declared private.C. A static interface method can be package-private.D. A static interface method can be declared public.E. A static interface
What is the result of executing the following program? A. 15B. 25C. 35D. One line does not compile.E. Two lines do not compile.F. The program compiles but throws an exception at runtime. public class Canine { public String woof (int bark) { return "1"+bark.toString(); } } public String
Fill in the blanks with the only option that makes this statement false: A(n) ______________can access ______________ of the enclosing class in which it is defined.A. static nested class, static membersB. static nested class, instance membersC. member inner class, static membersD. member inner
What statement best describes the notion of effectively final in Java? A. A local variable that is marked finalB. A static variable that is marked finalC. A local variable whose primitive value or object reference does not change after it isinitializedD. A local variable whose primitive value or
What is the output of the Turnip class? A. 3B. 5C. The code does not compile.D. The code compiles but throws an exception at runtime.E. None of the above. package animal; interface GameItem { int sell(); } abstract class Vegetable implements GameItem { public final int sell() { return 5; } }
What is the output of the following application? A. 1B. 2C. 12D. The code does not compile.E. The code compiles but throws an exception at runtime.F. None of the above. package holiday; enum Daysoff { Thanksgiving, PresidentsDay, Valentines Day } public class Vacation { public static void
Which statements about instance keywords are correct? (Choose two.)A. The that keyword can be used to read public members in the direct parent class.B. The this keyword can be used to read all members declared within the class.C. The super keyword can be used to read all members declared in a
Suppose you have the following code. Which of the images best represents the state of the references c1, c2, and c3, right before the end of the main() method, assuming garbage collection hasn’t run? In the diagrams, each box represents a Chicken object with a number of eggs. A. Option A.B.
Fill in the blanks: A class ____________ an interface and ______________ an abstract class.An interface ______________ another interface.A. extends, extends, implementsB. extends, implements, extendsC. extends, implements, implementsD. implements, extends, extendsE. implements, extends,
What is the output of the following application?A. 7B. 5C. The code does not compile.D. The code compiles without issue, but the output cannot be determined until runtime.E. None of the above. package musical; interface Speak { default int talk() { return 7; } } interface Sing { default int
What is the output of the following application? A. 5 bent!B. 5.0 bent!C. The code does not compile because Bend is not a functional interface.D. The code does not compile because of the apply( ) method declaration.E. None of the above. package ai; interface Pump { void pump (double psi); }
Which statement is true about encapsulation while providing the broadest access allowed?A. Variables are private, and methods are private.B. Variables are private, and methods are public.C. Variables are public, and methods are private.D. Variables are public, and methods are public.E. None of
Fill in the blanks: The ___________________ access modifier allows access to everything the ___________________ access modifier does and more.A. package-private, privateB. private, protectedC. protected, publicD. private, package-privateE. None of the above
Which statement about the following interface is correct? A. The code compiles without issue.B. The code does not compile because of line k1.C. The code does not compile because of line k2.D. The code does not compile because of line k3.E. The code does not compile because of line k4.F. None
Which is the first line to fail to compile? A. r1B. r2C. r3D. r4E. r5F. None of the above class Tool { } private void repair() {} void use() {} } // r1 // r2 class Hammer extends Tool { private int repair() { return 0; } // r3 private void use () {} // r4 public void bang() {} // r5
Showing 700 - 800
of 1045
1
2
3
4
5
6
7
8
9
10
11
Step by Step Answers