



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Define a superclass? - ANSSuperclass is also a part of Inheritance. The superclass is an entity, which allows subclasses or child classes to inherit from itself. Dynamic polymorphism is also known as: - ANSRuntime polymorphism Explain inheritance with an example - ANScar, truck, bus. different behaviors and characteristics but common elements among them. How is an abstract class different from an interface? - ANSInterface and abstract class both are special types of classes that contain only the methods declaration and not their implementation. But the interface is entirely different from an abstract class. The main difference between the two is that, when an interface is implemented, the subclass must define all its methods and provide its implementation. Whereas when an abstract class is inherited, the subclass does not need to provide the definition of its abstract method, until and unless the subclass is using it. Also, an abstract class can contain abstract methods as well as non-abstract methods. How is data abstraction accomplished? - ANSData abstraction is accomplished with the help of abstract methods or abstract classes.
How much memory does a class occupy? - ANSClasses do not consume memory. They are just a blueprint based on which objects are created. Now when objects are created, they actually initialize the class members and methods and therefore consume memory. In encapsulation, what is "private", "protected", and "public" - ANSPrivate - Only the current class will have access to the field or method. Protected - Only the current class and subclasses of this class will have access to the field or method. Public - Any class can refer to the field or call the method. Is it always necessary to create objects from classes? - ANSNo. An object is necessary to be created if the base class has non-static methods. But if the class has static methods, then objects don't need to be created. You can call the class method directly in this case, using the class name. Static polymorphism is also known as: - ANSCompile-time polymorphism What are access specifiers and what is their significance? - ANSAccess specifiers, as the name suggests, are a special type of keywords, which are used to control or specify the accessibility of entities like classes, methods, etc. Some of the access specifiers or access modifiers include "private", "public", etc. These access specifiers also play a very vital role in achieving Encapsulation - one of the major features of OOPs. What are some major Object Oriented Programming Languages? - ANSJava, C++, Javascript, Python, PHP, Perl What are some other programming paradigms - ANSImperative, Declarative
Copy-constructors is a type of constructor, whose purpose is to copy an object to another. What it means is that a copy constructor will clone an object and its values, into another object, provided that both objects are of the same class. Destructor - Contrary to constructors, which initialize objects and specify space for them, Destructors are also special methods. But they free up the resources and memory occupied by an object. Destructors are automatically called when an object is being destroyed. What is a subclass? - ANSThe subclass is a part of Inheritance. The subclass is an entity, which inherits from another class. It is also known as the child class. What is abstraction? - ANSIf you are a user, and you have a problem statement, you don't want to know the components of the software, how it works, or how it's made. You only want to know how the software solves your problem. Abstraction is the method of hiding unnecessary details from the necessary ones. It is one of the main features of OOPs. For example, consider a car. You only need to know how to run a car, and not how the wires are connected inside of it. What is an abstract class? - ANSAn abstract class is a special class containing abstract methods. The significance of abstract class is that the What is an exception? - ANSAn exception can be considered as a special event, which is raised during the execution of a program at runtime, that brings the execution to a halt. The reason for the exception is mainly due to a position in the program, where the user wants to do something for which the program is not specified, like undesirable input.
What is an interface? - ANSIt is a special type of class, which contains methods, but not their definition. Only the declaration of methods is allowed inside an interface. To use an interface, you cannot create objects. Instead, you need to implement that interface and define the methods for their implementation. What is an object? - ANSAn object refers to an instance of the class, which contains the instance of the members and behaviors defined in the class template. In the real world, an object is an actual entity to which a user interacts, whereas class is just the template for that object. So the objects consume space and have some characteristic behavior. E.g. A ford fusion What is compile time polymorphism and how is it different from runtime polymorphism? - ANSCompile time polymorphism, also known as static polymorphism, refers to the type of polymorphism that happens at compile time. What it means is that the compiler decides what shape or value has to be taken by the entity. Runtime polymorphism, also known as dynamic polymorphism, refers to the type of polymorphism that happens at the run time. What it means is that it can't be decided by the compiler. Therefore what shape or value has to be taken depends upon the execution. What is encapsulation? - ANSThe method of putting everything that is required to do the job, inside a capsule and presenting that capsule to the user. What it means is that by Encapsulation, all the necessary data and methods are bound together and all the unnecessary details are hidden to the normal user. So Encapsulation is the process of binding data members and methods of a program together to do a specific job, without revealing unnecessary details. Encapsulation can also be defined in two different ways:
What is the difference between overloading and overriding? - ANSOver loading is a compile polymorphism feature in which an entity has multiple implementations with the same name. For example, Method overloading and Operator overloading. Overriding is a runtime polymorphism feature in which an entity has the same name, but its implementation changes during execution. For example - "Method Overriding" What is the need for OOPs? - ANSThere are many reasons why OOPs is mostly preferred, but the most important among them are: