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 the difference between path and classpath?

Answer

Path contains path of .exe files(commands).


Classpath contains path of packages. packages can be stored in folder or .jar files

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1733
Q:

What is JAR file? what are the main uses of JAR files?

Answer

JAR files are java's version of ZIP files. In fact, JAR uses the ZIP file format.


uses:


- to compress a number of . class files into one file


- to make a java executable JAR file.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1471
Q:

What is unwrapping?

Answer

Unwrapping is also called as unpacking or unboxing.


Getting the private data stored in the object by using methods is called unpacking or unwrapping.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1834
Q:

What is wrapping?

Answer

Wrapping is also called as packing or boxing.


Storing the data inside the object as private data which can accessed outside the class only by using methods.


 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1898
Q:

What is different among String, StringBuffer, StringBuilder?

Answer

String class objects are immutable objects and they represents strings( sequence of characters)


StringBuffer class objects are mutable objects representing strings and they are Thread safe


StringBuild class objects are also mutable objects representing strings and they are not Thread safe

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1577
Q:

How to call argument constructor?

Answer

new ClassName( arg1, arg2, .... argN);


Ex:


Class sample {


   Sample(int a) {


   System.out.println("arg con a =" +a);


   }


}


class Demo {


    Public static void main( String[] args) {


     Sample s1= new Sample(23);


     Sample s2= new Sample(45);


    }


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1581
Q:

What is Constructor?

Answer

Constructor is not a special method.


Constructor is block of code that is executed automatically whenever object of the class is created.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1618
Q:

What is difference between methods and blocks?

Answer

Method contains name, parameters, return type and executable body. But block does not contains name, parameters, return type.It contains only executable body.


Methods are executed by method call statements. Blocks are executed automatically with class loading and with object creation.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1714