Which of the following are checked exceptions?(Choose all that apply) class One extends RuntimeException{} class Two extends Exception{} class Three extends Error{} class Four extends One{} class Five extends Two{} class Six extends Three{}
A) Three B) One C) Six D) Four E) Five F) Two
Answer
class A{
private void printName(){
System.out.println("Value-A");
}
}
class B extends A{
public void printName(){
System.out.println("Name-B");
}
}
public class Test{
public static void main(String[] args){
A a = new B();
a.printName();
}
}
Which of the following pairs fills in the blanks to make this code compile?
public void read()__________SQLException{ ____________new SQLException(); }
A) throws on line 5 and throw on line 6 B) throw on line 5 and throws on line 6 C) None of the above. SQLException is a checked exception and cannot be thrown D) throws on line 5 and throws on line 6 E) throw on line 5 and throw on line 6 F) None of the above. SQLException is a runtime exception and cannot be thrown
Answer
import java.util.*;
import java.util.stream.IntStream;
class GFG
{
public static void main(String[] args)
{
IntStream stream = IntStream.of(2,3,4);
int answer = stream.reduce(0,(num1,num2)->(num1+num2)*2);
System.out.println(answer);
}
}
An abstract data type typically comprises a_______and a set of_____ respectively.
A) Data representation, objects B) Data representation, operations C) Database, operations D) Data representation, classes E) Control structure, operations
A) None of these B) A public member of a class can be accessed in all the packages. C) A private member of a class cannot be accessed by the methods of the same class. D) A protected member of a class can be accessed from its derived class. E) A private member of a class cannot be accessed from its derived class.
A) Objects can be explicitly destroyed using the finalized method. B) Objects can be explicitly destroyed using keyword delete. C) If object obj1 can access object obj2 that is eligible for garbage collection, then obj1 is also eligible for garbage collection. D) An object will be garbage collected immediately after it becomes unreachable. E) None of these
Which of the following statements are true about checked an unchecked exceptions?
A) NullPointerException is an example of unchecked exception B) ClassNotFoundException is an example of unchecked exception. C) Unchecked exception is required handle at compile time. D) Both of these exceptions can be handled using try,catch keywords. E) checked exceptions is required to be handled at compile time.
A) find elements from desktop applications B) find defects in API specifications C) generates test reports automatically D) perform operations on element inside an iframe