Selenium Practice Test – 6 Posted by Editor Date 2022-09-24 Comments 0 comment Welcome to your Selenium Practice Test - 6 What is the result? public class MyThread implements Runnable { public void run() { System.out.println("running"); } public static void main(String args[]) { Thread t= new Thread(new MyThread()); t.run(); t.run(); t.start(); } } A) Compilation fails B) An Exception is thrown at runtime C) The code executes and prints "running" D) The code executes and prints "runningrunning" E) The code executes and prints "runningrunningrunning" What are the two acceptable types for the variable i? switch (i) { default: System.out.printIn("Hello"); } A) Char B) Float C) Double D) Object . Given a class named student, which of the following is a valid constructor declaration for the class? A) Student (student s) { } B) Student student( ) { } C) Private final student ( ) { } D) Void student ( ) { } E) A public static method in class X can be called by a subclass of X without explicitly referencing the class x What is the Result class SimpleCalc { public int value; public void calculate() { value +=7; } } public class MultiCalc extends SimpleCalc { public void calculate() { value -=3; } public void calculate(int multiplier) { calculate(); super.calculate(); value *= multiplier; } public static void main(String args[]) { MultiCalc calculator = new MultiCalc(); calculator.calculate(2); System.out.println("Value is: "+ calculator.value); } } A) Value is : 8 B) Compilation fails C) Value is : 12 D) Value is : -12 E) The code runs with no output F) An exception is thrown at runtime Which gets the name of the parent directory file "file.txt"? A) String name= File.getParentName("file.txt"); B) String name= (new File("file.txt")).getParent(); C) String name = (new File("file.txt")).getParentName(); D) String name= (new File("file.txt")).getParentFile(); E) Directory dir=(new File ("file.txt")).getParentDir(); String name= dir.getName(); What is the Result of below program? public class Test { public static void main (string[]args) { try { return; } finally { system.out.printIn("Finally"); } } } A) The program runs and prints nothing. B) The program runs and prints "Finally" C) The code compiles, but an exception is thrown at runtime. D) The code will not compile because the catch block is missing. Which two statements are true? (Choose two) A) An encapsulation, public class promotes re-use. B) Classes that share the same interface are always tightly encapsulated. C) An encapsulated class allows subclasses to overload methods, but does NOT allow overriding methods D) An encapsulated class allows programmer to change an implementation without affecting outside code.. Which three statements are true? (choosetwo) A) A final method in class x can be abstract if and only if X is abstract B) A protected method in class x can be overridden by any subclass of x C) A private static method can be called only within other static methods in class X D) A non-static public final method in class X can be overridden in any subclass of X E) A public static method in class X can be called by a subclass of X without explicitly referencing the class x You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability? A) java.util.Map B) java.util.Set C) java.util.List D) java.util.Collection What can directly access and change the value of the variable name? package p1; class Target { public String name = "hello"; } A)any class B)only the Target class C)any class in the p1 package D)any class that extends Target Time is Up! Time's up Share: Editor Previous post Selenium Practice Test - 5 2022-09-24 Next post Selenium Practice Test - 7 2022-09-24 You may also like Oracle Tutorial Videos 8 April, 2023 Spring Tutorial Videos 8 April, 2023 Ui Technologies Tutorial Videos 1 April, 2023