Question 118Asked in BPSC TRE 1.0 (2023) Computer Science Class 11-12

Which feature of OOP is indicated by the following code? class student{int marks;};

Which feature of OOP is indicated by the following code? class student{int marks;}; class topper: public student{int age; topper(int age) {this.age=age;}};
  1. AEncapsulation and inheritance
  2. BInheritance and polymorphism
  3. CPolymorphism
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (A) Encapsulation and inheritance

Explanation

Data hidden inside the classes shows encapsulation, and topper deriving from student with public shows inheritance. There is no overloading or overriding, so polymorphism is not shown.

From BPSC TRE 1.0 (2023) Computer Science Class 11-12 — Previous Year Paper

This is question 118 of BPSC TRE 1.0 (2023) Computer Science Class 11-12 — Previous Year Paper. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.