1.

Which among the following is wrong?(a) class student{}; student s;(b) abstract class student{}; student s;(c) abstract class student{}s[50000000];(d) abstract class student{}; class toppers: public student{}; topper t;The question was posed to me by my college professor while I was bunking the class.This intriguing question originated from Objects in portion OOPs Concept & Features of Object Oriented Programming

Answer»

Correct CHOICE is (b) ABSTRACT class student{}; student s;

For explanation: We can never CREATE instance of an abstract class. Abstract classes doesn’t have constructors and hence when an instance is CREATED there is no facility to initialize its members. Option d is correct because topper class is inheriting the base abstract class student, and hence topper class object can be created easily.



Discussion

No Comment Found

Related InterviewSolutions