Predict the output of following Java program class Main { public static void main(String args[]) { try { throw 10; } catch(int e) { System.out.println("Got… Read More
Category Archives: Java Quiz
class Test { public static void main (String[] args) { int arr1[] = {1, 2, 3}; int arr2[] = {1, 2, 3}; if (arr1.equals(arr2)) System.out.println("Same");… Read More
Output of following Java program? import java.util.Arrays; class Test { public static void main (String[] args) { int arr1[] = {1, 2, 3}; int arr2[]… Read More
Output of following Java program? class Test { public static void main (String[] args) { int arr1[] = {1, 2, 3}; int arr2[] = {1,… Read More
Which of the following is/are advantages of packages? (A) Packages avoid name clashes (B) Classes, even though they are visible outside their package, can have… Read More
Which of the following is/are true about packages in Java? 1) Every class is part of some package. 2) All classes in a file are… Read More
final class Complex { private double re, im; public Complex(double re, double im) { this.re = re; this.im = im; } Complex(Complex c) { System.out.println("Copy… Read More
public class Main { public static void main(String args[]) { int arr[][] = new int[4][]; arr[0] = new int[1]; arr[1] = new int[2]; arr[2] =… Read More
Output of following Java program class Point { int m_x, m_y; public Point(int x, int y) { m_x = x; m_y = y; }… Read More
Is there any compiler error in the below Java program? class Point { int m_x, m_y; public Point(int x, int y) { m_x = x; … Read More
Which of the following is/are true about constructors in Java? 1) Constructor name should be same as class name. 2) If you don't define a… Read More
class Test { public static void main(String args[]) { int arr[] = new int[2]; System.out.println(arr[0]); System.out.println(arr[1]); } } (A) 0 0 (B) garbage value garbage… Read More
class Test { public static void main(String args[]) { int arr[2]; System.out.println(arr[0]); System.out.println(arr[1]); } } (A) 0 0 (B) garbage value garbage value (C) Compiler… Read More
class Base { public final void show() { System.out.println("Base::show() called"); } } class Derived extends Base { public void show() { System.out.println("Derived::show() called"); } }… Read More
class Main { public static void main(String args[]){ final int i; i = 20; i = 30; System.out.println(i); } } (A) 30 (B) Compiler Error… Read More