Abstraction C Interview Questions

4 What is an exception?

An exception is a kind of message that interrupts and comes up when there is an issue with the normal execution of a program. Exceptions provide an error and transfer it to the exception handler to resolve it. The state of the program is saved as soon as an exception is raised.

3 What is a copy constructor?

By copying the members of an existing object, the copy constructor initialises the members of a newly formed object. The argument for the copy constructor is a reference to an object of the same class. Programmers have the option of directly defining the copy constructor. The compiler defines the copy constructor if the programmer doesn’t.

Top 10 Technologies to Learn in 2022| Edureka

18. 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 speed but you cannot define it because different vehicles have different speed. This method will be defined in the subclasses with different definitions for different vehicles.

Static polymorphism (static binding) is a kind of polymorphism that occurs at compile time. An example of compile-time polymorphism is method overloading.

Runtime polymorphism or dynamic polymorphism (dynamic binding) is a type of polymorphism which is resolved during runtime. An example of runtime polymorphism is method overriding.

Method overloading is a feature of OOPs which makes it possible to give the same name to more than one methods within a class if the arguments passed differ.

Method overriding is a feature of OOPs by which the child class or the subclass can redefine methods present in the base class or parent class. Here, the method that is overridden has the same name as well as the signature meaning the arguments passed and the return type.

Operator overloading refers to implementing operators using user-defined types based on the arguments passed along with it.

Overloading Overriding
Two or more methods having the same name but different parameters or signature Child class redefining methods present in the base class with the same parameters/ signature
Resolved during compile-time Resolved during runtime

To know more about polymorphism in Java and Python, read the below articles:

OOPs Interview Questions – Encapsulation

Encapsulation refers to binding the data and the code that works on that together in a single unit. For example, a class. Encapsulation also allows data-hiding as the data specified in one class is hidden from other classes.

Access specifiers or access modifiers are keywords that determine the accessibility of methods, classes, etc in OOPs. These access specifiers allow the implementation of encapsulation. The most common access specifiers are public, private and protected. However, there are a few more which are specific to the programming languages.

Name Accessibility from own class Accessibility from derived class Accessibility from world

Public

Yes

Yes

Yes

Private

Yes

No

No

Protected

Yes

Yes

No

To know more about encapsulation read along:

5 What are the limitations of OOPs?

  • Larger Program size – Programs can become lengthy if written using OOps concepts compared to procedure-oriented programming.
  • Slower execution – As the number of lines of code to be executed is more comparatively, the execution time is also more.
  • Not suitable for all types of Problems.
  • Testing time is also higher for OOP Solutions.
  • What is method overriding?

    Method overriding is a concept of object-oriented programming.

    It is a language feature that allows a subclass or child class to provide a specific implementation of a method which is already provided by one of its superclasses or parent classes.

    C# Interview Question :- Abstraction is not Abstract classes

    Related Posts

    Leave a Reply

    Your email address will not be published. Required fields are marked *