0% found this document useful (0 votes)
15 views

Interview Question OOPs

Interview

Uploaded by

Risdan Kristori
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
15 views

Interview Question OOPs

Interview

Uploaded by

Risdan Kristori
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
Interview Questions with Answers Note: These questions are based on my past experiences and research Chapter 1. Object Oriented Programming Basic Level: 4. What is Object Oriented Programming? Object-Oriented Programming(QOPs) is a type of programming that is based on objects rather than just functions and procedures. Individual objects are grouped into classes. OOPs implement real-worid entities like inheritance, polymorphism, hiding, ete into programming, It also allows binding data and code together. 2. Why use OOPs? OR Advantages of OOPs OOPS allows clarity in programming thereby allowing simplicity in solving complex problems Code can be reused through inheritance thereby reducing redundancy Data and code are bound together by encapsulation OOPS aliows data hiding, therefore, private data is kept confidential Problems can be divided into different parts making it simple to solve The concept of polymorphism gives flexibility to the program by allowing the entities to have multiple forms, 3. What are the main features/pillars of OOPs? Inheritance Encapsulation Polymorphism, Data Abstraction 4. What are the main features of OOPs? Inheritance Encapsulation Polymorphism, Data Abstraction Scanned with CamScanner5. What is a class? ‘Aclass is a prototype that consists of objects in different states and with different behaviors. It has a number of methods that are common to the objects present within that class, 6. What is an object? ‘An object is a real-world entity which is the basic unit of OOPs for example chair, cat, dog, etc. Different objects have different states or attributes, and behaviors. Note: Class is a concept and to map this concept in real ife is an object. 7. What is the difference between a class and a structure? Class: User-defined blueprint from which objects are created. it consists of methods or sets of instructions that are to be performed on the objects. Structure: A structure is basically a user-defined collection of variables which are of different data types. 8. Can you call the base class method without creating an instance? Yes, you can call the base class without instantiating itt: © Itisa static method ¢ The base class is inherited by some other subciass ‘Aclass is basically a template or a blueprint A real-world entity which is an instance of a class within which objects can be created Binds methods and data together into a single unit ‘An object acts ike a variable of the class ‘An object isa physical entity ‘A class isa logical entity ‘Objects take memory space when they are | Aclass does nat take memory space when created created (Objects can be declared as and when required | Classes are declared just once 9. What Is inheritance? Inheritance is a feature of OOPs which allows classes to inherit common properties from other classes. For exampé, if there is a class such as ‘vehicle’, other classes like ‘car’, bike’, elc can inherit common properties from the vehicle class. This property helps you get rid of redundant code thereby reducing the overall size of the code Scanned with CamScanner9, What are the different types of inheritance? Single inheritance Mutiple inheritance Mutiievel inheritance Hierarchical inheritance Hybrid inheritance 10. What is the difference between multiple and multilevel inheritance? ‘Muttlevel inheritance means a class inherits Multiple inheritance comes into picture when 3 cecWhnteanesSitieset class inherits more than one base class from another cl some other base class Example: A class describing a sports car will Example: A class defining a child inherits from ete een ne cor uhach inturn two base classes Mother and Father eee eee 14. What is hierarchical inheritance? Hierarchical inheritance refers to inheritance where one base class has more than one subclass. For example, the vehicle class can have ‘car’, ‘bike’, etc as its subclasses. 412. What are the limitations of inheritance? ‘¢ Increases the time and effort required to execute a program as it requires jumping back and forth between different classes ‘© The parent class and the child class get tightly coupled ‘¢ Any modifications to the program would require changes both in the parent as well as the child class ‘+ Needs careful impiementation else would lead to incorrect resutts. 43. What is a superclass? A superclass or base class is a class that acts as a parent to some other class or classes. For example, the Vehicle class is a superclass of class Car. 14. What is a subclass? ‘Aclass that inherits from another class is called the subclass. For example, the class Caris a subclass or a derived of Vehicie class. 45. What is polymorphism? Polymorphism refers to the ability to exist in multiple forms. Multiple definitions can be given to a single interface. For example, if you have a class named Vehicle, it can have a method named Scanned with CamScanner

You might also like