Core Java Question

Will it compile and run?? If No ... please explain?
Code
  1.  

  2. public class Test{

  3.  

  4. public static void main(String asd[]){

  5.  

  6. System.out.println(" Test!! ");

  7. }

  8.  

  9. }

  10.  

  11. protected class A{

  12. }

  13.  

  14. private class B extends A{

  15. }
Copyright GeekInterview.com

Questions by vshri12

Showing Answers 1 - 5 of 5 Answers

Phanindra Ramesh

  • Feb 5th, 2013
 

It will be a compiler error as public and default are the only access modifiers allowed for a Class.

  Was this answer useful?  Yes

Abhinav Rohatgi

  • Apr 1st, 2013
 

Class will only be public,default,final
protected & private yield to compile time error

  Was this answer useful?  Yes

venkataramana

  • May 29th, 2013
 

first of it will not compile,because outer classes we cant create with the modifier protected

  Was this answer useful?  Yes

Sajad rasheed

  • Jun 15th, 2015
 

In this case if will show compile time error because the order of access specifier is stronger to weaker and calling of parent requires super keyword which isnt written in code 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions