0
Q:

What is the output of this program ?

class main_arguments {
            public static void main(String [ ] args)
            {
                String [][] argument = new String[2][2];
                int x;
                argument[0] = args;
                x = argument[0].length;
                for (int y = 0; y < x; y++)
                    System.out.print(" " + argument[0][y]);           
            }
        }

A) 1 1 B) 1 0
C) 1 0 3 D) 1 2 3

Answer:   D) 1 2 3



Explanation:

In argument[0] = args;, the reference variable arg[0], which was referring to an array with two elements, is reassigned to an array (args) with three elements.
Output:
$ javac main_arguments.java
$ java main_arguments
1 2 3

Subject: Java
Exam Prep: GATE
Q:

What is anonymous class?

Answer

Anonymous class is class without name.


EX:


class A {


}


class Demo {


    A r = new A() {


        }; //anonymous class


}


 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1570
Q:

What is local class?

Answer

Local class is class defined inside method


EX;


class A { // top level class


  public static void main(string[] args) {


   class B { // local class


   }


}


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1691
Q:

what is non-static member class?

Answer

Non-static member class is a class defined inside outer class with out static modifier.


EX:


class A { // top level class or outer class


    ......


    class B { //non-static member class


    }


    .....


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1534
Q:

What is static member class?

Answer

Static member class is a class defined inside outer class with static modifier.


EX:


Class A {  //top level class or outer class


    .....


    static class B {  //static member class


    }


   .....


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1744
Q:

What is top level class?

Answer

Top level class is also called outer class. It is not defined inside any class.


Ex:


class A {  //top level class


 


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1578
Q:

How many types of classes are there in Java?

Answer

Two types of classes:


1) Top Level Class


2) Classes within Class


       i) member classes


             a) static member class


             b) non static member class


      ii) local classes


      iii) anonymous classes

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1587
Q:

What is the purpose of the wait(), notify(), and notifyAll() methods ?

Answer

The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods..

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1637
Q:

What are wrapped classes ?

Answer

Wrapped classes are classes that allow primitive types to be accessed as objects.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1662