class A
{
class B
{
psvm(String args[])
{
}
}
}
if the prg saved in A.java whats the o/p?

Answers were Sorted based on User's Feedback



class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?..

Answer / kalpana

output
-------

Inner classes cannot have static declarations

Is This Answer Correct ?    14 Yes 0 No

class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?..

Answer / amulkumar

Compiletime Error saying----
The method main cannot be declared static; static methods
can only be declared in a static or top
level type

Is This Answer Correct ?    11 Yes 0 No

class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?..

Answer / ujjal

main method must be outside of the class B.

Is This Answer Correct ?    3 Yes 1 No

class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?..

Answer / venkat

We can save it as A.java because there the main is included
in this class, And this also is not closed until the main
finction.

Is This Answer Correct ?    0 Yes 0 No

class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?..

Answer / hitesh kumar

Compilation error:-
The method main cannot be declared static; static methods
can only be declared in a static or top level type.
To make it happen you need to declare class B as static
class A{
static class B{
psvm(String arg[]){}
}
}

Is This Answer Correct ?    0 Yes 0 No

class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?..

Answer / chanchal

Compilation error:-

Becouse Inner classes cannot have static declarations

Is This Answer Correct ?    0 Yes 0 No

class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?..

Answer / sivadasan

The above code will be compiled succcessfully.

but at runtime it will throw an exception :

Exception in thread "main" java.lang.NoSuchMethodError: main

Because, Java Environment starts its execution from main
method. That method must be declared in the class which is
we are using to save our code.

If any query let me know....

Is This Answer Correct ?    2 Yes 6 No

Post New Answer

More Core Java Interview Questions

why the equals method can be override?when we override the equals method?

5 Answers  


When can we say that threads are not lightweight process in java?

0 Answers  


Difference between final and effectively final ? Why is effectively final even required ?

0 Answers  


What is a copy constructor in java?

0 Answers   Amazon,


How does arrays sort work in java?

0 Answers  






In how many ways we can create threads in java?

0 Answers  


How to perform quicksort in java?

0 Answers  


How can an object be unreferenced?

0 Answers  


What is Generic in java? Where can we write Generic ( class or method or objects or etc...)? with simple example? Thanks, Bose.

2 Answers   Infosys, Tech Mahindra,


What is binary tree in java?

0 Answers  


What classes can be used to store arbitrary number of objects ?

1 Answers  


JVM responsibility?

6 Answers   TCS,


Categories