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:

How to create Directory on the HD?

Answer

To create directory on the HD we use mkDir() method:


boolean mkDir();


This method returns true if the directory is created on HD


This method returns false if the directory is already existing on HD

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1727
Q:

How to create a file on the hard disk by using File class object?

Answer

We can use the following method call:


boolean createNewFile();


This method creates a new file on the HD. 


 


If a file is already existing with the name given in the constructor then this method does not creates file on HD.


If file is successfully created then this method returns true.


If file is already existing on the HD then this method returns false.


This method may throw IOException whenever IO error is generated while creating file on HD.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1541
Q:

Why interface data is public?

Answer

to access non-public data outside class getter methods be defined but we cannot define a  method inside interface we can declared a method inside interface.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 4340
Q:

Why interface data is final?

Answer

bcoz interface does not contains any initializers and constructors to initialize its data members.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1804
Q:

Why interface data is static?

Answer

Interface data is static data why bcoz interface supports multiple inheritance.


if inteface data is non-static then there is chance for replication of the data (bcoz of replication of data ambiguity problem occurs )

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1591
Q:

What is abstract method?

Answer

abstract method is a method declared with abstract modifier but  with out body.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1652
Q:

why protected modifier?

Answer

Outside the package if any other class other than JVM calls the finalize method our class then it is not allowed

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1992
Q:

What is the use of tostring() method?

Answer

If we print any object by using println() or print() methods.


The println() or print() methods internally calls tostring() method and prints the return value of toString() method.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1558