Skip to content

Category Archives: Java Quiz

class Test {     public static void main(String[] args)     {         try         {             int a[]= {1, 2, 3, 4};             for (int i = 1; i <= 4;… Read More
class Test {     public static void main (String[] args)     {         try         {             int a = 0;             System.out.println ("a = " + a);             int b =… Read More
class demo {     int a, b;            demo()     {         a = 10;         b = 20;     }            public void print()     {         System.out.println ("a = "… Read More
class demo {     int a, b, c;     demo(int a, int b, int c)     {         this.a = a;         this.b = b;     }            demo()     {         a… Read More
class Test {     static int a;            static     {         a = 4;         System.out.println ("inside static block\n");         System.out.println ("a = " + a);     }            Test()… Read More
class Test {     public static void main(String args[])     {         String s1 = "geeksquiz";         String s2 = "geeksquiz";         System.out.println("s1 == s2 is:" + s1 == s2);… Read More
class Base {}    class Derived extends Base {    public static void main(String args[]){       Base a = new Derived();       System.out.println(a instanceof Derived);    } } (A)… Read More
Which of the following is not an operator in Java? (A) instanceof (B) sizeof (C) new (D) >>>= Answer: (B) Explanation: There is no sizeof… Read More
class Test {     public static void main(String args[])  {        System.out.println(10*20 + "GeeksQuiz");        System.out.println("GeeksQuiz" + 10*20);    }  } (A) 10*20GeeksQuiz GeeksQuiz10*20 (B) 200GeeksQuiz GeeksQuiz200 (C) 200GeeksQuiz… Read More
class Test {     public static void main(String args[])  {        System.out.println(10  +  20 + "GeeksQuiz");         System.out.println("GeeksQuiz" + 10 + 20);     }   } (A) 30GeeksQuiz GeeksQuiz30 (B)… Read More
Predict the output of following Java program. Assume that int is stored using 32 bits. class Test {     public static void main(String args[])  {        int… Read More
Predict the output of following Java Program class Test {     public static void main(String args[])  {        int x = -4;        System.out.println(x>>1);          int y = 4;… Read More
class Base extends Exception {} class Derived extends Base  {}    public class Main {   public static void main(String args[]) {    // some other stuff… Read More
Output of following Java program? class Main {    public static void main(String args[]) {       int x = 0;       int y = 10;       int z =… Read More
class Test extends Exception { }     class Main {    public static void main(String args[]) {        try {          throw new Test();       }       catch(Test t) {… Read More