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

Does the order of public and static declaration matter in main method?

0 Answers  


Can we sort hashmap in java?

0 Answers  


What is the default initialized value of String type variable?

4 Answers  


What is scope & storage allocation of static, local and register variables? Explain with an example.

0 Answers   IBS,


What is the use of string and stringbuffer?

0 Answers  






How the elements are organized in GridLayout?

2 Answers  


Is java still necessary?

0 Answers  


what is collections in java?

4 Answers  


how are methods defined?

0 Answers  


What is stream api in java8?

0 Answers  


Can list be final in java?

0 Answers  


when i write string s1="java"; in one program(application) and string s2="java"; in another application on the same jvm will both objects s2,s2 will refer to same memory location where "java" is stored in string pool.

2 Answers  


Categories