Citigroup Interview Question for Applications Developers


Country: India




Comment hidden because of low score. Click to expand.
2
of 2 vote

The syntax is absolutely correct. There would be no compile time error. During method resolving the inherited method with add (int, int) signature from parent class would be resolved and a call to it would be made.

- Nawazish October 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can call only static methods using class name like "child.add(...)" here add should be static.

rules of calling method:
1) if you create pointer of base class and store object of base class then it call method of base class.
2) if you create pointer of child class and store object of child class then it call method of child class
3) if you create pointer of base class and store object of child class then
i) if method is non virtual it call method of base class
ii) if method is virtual it call method of child class

- Abhi October 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

absolutely no issues in complile time or runtime exception.

in the above case, parent class is not extending child hence no issue, it will treated as yet another method in the child class.

if incase it was ovverrided without @override annotation in child, still its absolutly fine
if thete was a @overrride annotation for add(double x, double y).. this is where compiler will complain....


Go thru few concepts in java overriding objects..

- Punith October 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In Java , this is not an issue as add(int , int ) will be inherited in the child class . So this will not be method overriding . For method overriding we need to have the same type and number of parameters . This acts as method overloading ,as child class has all the code of the super class in the child class we will have both add( double, double ) and add(int, int) . So it is very simple when we create a child object Child childObj = new Child() ; and do a childObj.add(int , int) then it will call it only .

- Mahanthopensource@gmail.com October 20, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More