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 do you understand by java virtual machine?

0 Answers  


Which Math method is used to calculate the absolute value of a number?

3 Answers   Accenture,


Can I uninstall java?

0 Answers  


What will happen if we declare don’t declare the main as static?

1 Answers  


I have a string like _a01_a02_a03_ and another string like _2_1.5_4_ as input.I want to extract a01,a02... to a string array and 2,1.5,etc to a double array with a01 corresponds to 2 and a02 to 1.5 etc. Need code in core java.. Can you do it?

1 Answers   Cognizant,






Explain your academic project?

2 Answers   Accenture, Levonsys, SDF, TCS, Tech Mahindra,


Differences between C and Java?

0 Answers   TCS,


What is the difference between state-based unit testing and interaction-based unit testing?

0 Answers  


What is treeset and treemap in java?

0 Answers  


what is Dictionary? and what purpose it is used for?

3 Answers  


int a=1,b=10; System.out.println(a+b--);

12 Answers   HCL,


How do you implement singleton class?

0 Answers  


Categories