This questions are about the core java concepts includeing language fundamentals, objects,interfaces,threads,loops,collections and garbage collections. . .
public class X
{
public static void main(String [] args)
try
badMethod();
System.out.print("A");
}
catch (Exception ex)
System.out.print("B");
finally
System.out.print("C");
System.out.print("D");
public static void badMethod() {}
int x = 0;
int y = 5 / x;
catch (Exception e)
System.out.println("Exception");
catch (ArithmeticException ae)
System.out.println(" Arithmetic Exception");
System.out.println("finished");
What is the output for the below code ?
public class A {
public A() {
public class B extends A implements Serializable {
public B() {
System.out.println("B");
public class Test {
public static void main(String... args) throws Exception {
B b = new B();
ObjectOutputStream save = new ObjectOutputStream(new FileOutputStream("datafile"));
save.writeObject(b);
save.flush();
ObjectInputStream restore = new ObjectInputStream(new FileInputStream("datafile"));
B z = (B) restore.readObject();