Professional Documents
Culture Documents
2.inner class
2.inner class
java
public class Main{
public static void main(String[] args){
Quad qc = new Quad(2,5,3,20.1);
Quad.Disc dc = qc.new Disc();
dc.display();
qc.displayOuter();
}
}
Quad.java
public class Quad {
public int a;
public int b;
public int c;
private double d;
Question 13/20
Prev
Next
What happens if you attempt to catch an exception of a type that is not a superclass of the thrown exception?
Explanation
In Java, a catch block can only catch exceptions that are either of the same type or a superclass of the thrown exception. Attempting to catch an
Question 9/10
Prev
Next
Which of these exception is thrown in cases when the file specified for writing is not found?
IOException
FileException
FileNotFoundException
FileInputException
Explanation
In cases when the file specified is not found, then FileNotFoundException is thrown.
class Prepinsta
Prepinsta()throws IOException
Main()
{
Explanation
If the parent class constructor throws any checked exception , the compulsory child class constructor should throw the same checked exception
Question 2/20
Prev
Next
Executing several tasks simultaneously where each task is a separate independent part of the same program, is called?
Executing several tasks simultaneously where each task is a separate independent part of the same program, is called Thread based multitasking.
Question 3/20
Prev
Next
Three
Four
Two
One
Explanation
Executing several tasks simultaneously is the concept of multitasking. There are two types of multitasking.
Question 4/20
Prev
Next
sleep()
yield()
join()
interrupt()
Explanation
We can interrupt a sleeping or waiting thread by using the interrupt() method of Thread class.
Java uses threads to enable the entire environment to be asynchronous. Asynchronous threading is pre-emptive i.e. once a thread starts executing
a task it can hold it in mid, save the current state and start executing another task (context switching) according to priority and other specified
criteria and threading.so ,option (A) is correct.
Question 12/20
Prev
Next
run(1);
class Main
t.start();
No output
Explanation
Thread class start() method invokes no argument run() method which invokes other overload run() methods just like normal method.Hence, the
class Main
t.start();
}
}
start method
run method
Question 11/20
Prev
Next
Which of the following functional interface represents a function that accepts a double-valued argument and produces a result?
DoubleToIntFunction
DoubleSupplier
DoublePredicate
DoubleFunction<R>
Explanation
DoubleFunction<R> functional interface represents a function that accepts a double-valued argument and produces a result.
Question 16/20
Prev
Next
Explanation
Which feature of java 8 enables us to create a work stealing thread pool using all available processors at its target?
threadPool
workThreadPool
newWorkStealingPool
workPool
Explanation
Executors newWorkStealingPool() method to create a work-stealing thread pool using all available processors as its target parallelism level.
Question 3/10
Prev
Next
Explanation
Runnable
Callable
Comparable
Serializable
Explanation
An interface which contains only one abstract method is called a functional interface.
Example:
Runnable⇒ run()
Callable=> call()
Question 7/10
Prev
Next
@FunctionalInterface
interface Inter1
class Main
m.methodOne();
}
Hello Prepsters
No output
Explanation
Inter1 is a functional interface as it contains only one abstract method, hence we can write a lambda expression for it. Hence the output of the