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

What is jit compiler ?

0 Answers  


Explain the difference between comparator and comparable in java?

0 Answers  


Should database connections be singleton?

0 Answers  


Can we restart a thread already started in java?

0 Answers  


What is constructor

9 Answers   Manforce, Tech Mahindra,






Does java isempty check for null?

0 Answers  


How to Create A Wapper Class in core Java and Why are Use in java?

2 Answers   Amdocs,


Write a function to find out longest palindrome in a given string?

0 Answers  


Can vector have duplicates in java?

0 Answers  


I have a sorting issue with a Hashmap. My constraint is that I MUST use the Hashmap and work with existing code. I do a database query and place the results in a Hashmap. When I iterate thru the Hashmap, it loses the original alphabetical sorting done by the database. So, my problem is that I must sort the results coming out of the Hashmap which is then placed into another class.

1 Answers  


Is alive in java?

0 Answers  


Explain the reason behind ending a program with a system.exit(0)?

0 Answers  


Categories