Interview Question for Software Engineer / Developers






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

VF concept is used to make decision at run time which function is to be called... if you know that you are going to make a function call to derived/base class before hand then it doesn't make sense to use VF...

- Somebody June 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Moreover in big projects using inheritance helps in keeping the code flexible/open for extension. So when you program you program to interfaces not to the implementations.

- King@Work June 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

yes you can call but with this approach you have to always figure out the type of the derived class's pointer but by accessing the derived class functions(which are virtual function) through base class pointers you don't have to worry about the pointer type and it will automatically invoke the desired type function. That's the advantage of virtual functions.
plz correct me if I am wrong.

- Anonymous July 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is concept is necessary for extensibility/flexibility as others mentioned. You have a decision whether to call base/derived now. But, say in future you want to add one more derived class with a different implementation and you want to call this new derived class's function, you can do that with virtual functions by deferring the call till runtime.

- Jaya June 16, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

with out virtual function,
if you have 5 Derived class, then you have to make 5 conditions in the main process to call different function from the 5 Different class. moreover, if someone extend a few class from your Derived class or he just want to have a few more Derived class, then he have to update the main process.

- Liang April 16, 2013 | Flag Reply


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