public class Base {
public void myMethod(int a,intb) {}
}

// Uses myMethod and then hides it.
public class DerivedOne extends Base {

private void myMethod(int a,int b);
}

will this compile or not .yes or no. why

Answers were Sorted based on User's Feedback



public class Base { public void myMethod(int a,intb) {} } // Uses myMethod and then hides i..

Answer / ashwin khandelwal

It cannot be compiled because of weaker access privilege give to method in DerivedOne class while overidding method of Base Class

Is This Answer Correct ?    12 Yes 0 No

public class Base { public void myMethod(int a,intb) {} } // Uses myMethod and then hides i..

Answer / narayana

This will not compile because in the base class myMethod()
function is not having the body ,only abstract methods
should not have the body remaining all methods should have
the body

Is This Answer Correct ?    6 Yes 6 No

Post New Answer

More Core Java Interview Questions

can u give one sinario when you use Abstract Class and When you use Interface.

5 Answers   ITC Infotech,


What is string builder in java?

0 Answers  


What is matcher in java?

0 Answers  


which pattern is default in scanner package?

0 Answers   Satyam,


What is sortedset in java?

0 Answers  






what is run time polymorphism

4 Answers  


What enableEvents() method do?

1 Answers  


what is the need to set path in java? how many ways to set path in java? Explain breif?

5 Answers  


What is Session and cookies?Explain in detail with an example?

4 Answers   Accenture, CTS,


Explain garbage collection in java?

0 Answers  


Are functions objects in java?

0 Answers  


for what purpose we use applets ?

3 Answers   Mindlogicx,


Categories