Lockheed Martin Interview Question: Object-Oriented/coding questi... | Glassdoor

Interview Question

Software Engineer Interview San Jose, CA

Object-Oriented/coding questions: Given an array (you don't

  know the size), make an array that has the elements in the opposite order. Given classes Employee and Manager. Manager inherits from Employee. If you initialize two Employees, and set the second one to a new Manager, and print the ID, will the print statement come from Employee or Manager class function/method.
Answer

Interview Answer

1 Answer

0

Given classes Employee and Manager. Manager inherits from Employee. If you initialize two Employees, and set the second one to a new Manager, and print the ID, will the print statement come from Employee or Manager class function/method.

If the Employee base class method is implemented and the Manager class is not, the print statement will come from the Employee.
If the Employee base class method is implemented and the Manager class is implemented (overrides), the print statement will come from the Manager class.
If the Employee base class method is virtual (C++), then the Manager class must implement and the print statement will come from the Manager class.

Anonymous on May 26, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.