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

What is a numeric format?

0 Answers  


Write a program to print fibonacci series

0 Answers  


What is nested interface?

0 Answers  


What are the advantages of java?

0 Answers  


perpare on factorypattern,linklist wothout using collection, (multitharding ie create producer/customer therad producer create Queue continuesly,consumer consume queue, consumer wait if queue is full,producer wait if queue is empty),diff betn sleep(1000)&wait(1000) these r the main Q ask in huawei(2008)

1 Answers   Huawei,






What is the simpletimezone class in java programming?

0 Answers  


Convert Binary tree to linked list.

0 Answers   Amazon,


When should I use abstract classes and when should I use interfaces?

2 Answers  


Can we use catch statement for checked exceptions when there is no chance of raising exception in our code?

0 Answers  


What is the use join() in Threads ?

5 Answers   HCL,


What is finalize method?

0 Answers  


Difference between arraylist and vector.

0 Answers  


Categories