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
Answer / kalpana
output
-------
Inner classes cannot have static declarations
Is This Answer Correct ? | 14 Yes | 0 No |
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 |
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 |
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 |
Answer / chanchal
Compilation error:-
Becouse Inner classes cannot have static declarations
Is This Answer Correct ? | 0 Yes | 0 No |
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 |
What is main difference between variable and constant?
What are the differences between wait() and sleep()?
What is exception propagation?
What is a jit compiler?
Can a list be null in java?
What is xslt in java?
Is it compulsory to have atleast one abstract method in abstract class?
what is Abstract DataType?
In the HashMap, we know the values but we dont know the key, then how can we get the key from HashMap ?????
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
How variables are stored in memory?
What is an object?s lock? Give name of object?s that have locks?