33. Program
//Find what it gives ?
Compiletion Error / Compiletion Successfully / Run Time Error / Output
class U
{
U() throws ClassNotFoundException
{
System.out.println(1);
}
}
class V extends U
{
V()
{
}
}
34. Program
//Find what it gives ?
Compiletion Error / Compiletion Successfully / Run Time Error / Output
// it will give error get the answer from next Q.
class X
{
public static void main(String[] args)
{
try
{
int i = 10/0;
}
catch(Throwable t)
{
System.out.println(1);
}
catch(Exception ex)
{
System.out.println(2);
}
catch(RuntimeException rt)
{
System.out.println(3);
}
catch(ArithmeticException a)
{
System.out.println(4);
}
}
}
35. Program
//Find what it gives ?
Compiletion Error / Compiletion Successfully / Run Time Error / Output
//keeping multiple catch (catch must be most specific to most general order)
class X
{
public static void main(String[] args)
{
try
{
int i = 10/0;
}
catch(ArithmeticException a)
{
System.out.println(4);
}
catch(RuntimeException rt)
{
System.out.println(3);
}
catch(Exception ex)
{
System.out.println(2);
}
catch(Throwable t)
{
System.out.println(1);
}
}
}
36. Program
//Find what it gives ?
Compiletion Error / Compiletion Successfully / Run Time Error / Output
class Y extends ArithmeticException
{
public Y()
{
}
public Y(String msg)
{
super(msg);
}
public static void main (String[] args)
{
Y y1 = new Y("asas");
}
}