Write Output of Java Program - Exam Sample Questions
Answers are given at end. 1 public class StringTest { public static void main(String args[]){ String t1=new String("Text"); String t2=new String("Text"); System.out.println(t1==t2); String t3="Text"; String t4="Text"; System.out.println(t3==t4); System.out.println(t1==t4); System.out.println(t1.equals(t3)); } } 2 public class ExceptionTest { public static void main(String[] args) { try { System.out.println("Welcome to Java"); int[] a = new int[10]; a[10] = 1; System.out.println("Welcome to Python"); } catch (Exception ex) { System.out.println("There is an exception”); } System.out.println("Bye."); } } 3 class A{ public int x = 1; public A(int i){ x += i; } } class B extends A { public B(int i){ super(i); x += i; } } public class Test{ public static void main(String args[]) { A arr[] = new A[2];