






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A comprehensive set of questions and answers related to object-oriented programming (oop) concepts. It covers fundamental principles like abstraction, encapsulation, inheritance, and polymorphism, along with key features like constructors, destructors, virtual functions, and friend functions. The document also explores advanced topics such as operator overloading, abstract classes, and exception handling. It is a valuable resource for students learning oop and preparing for exams or quizzes.
Typology: Exams
1 / 10
This page cannot be seen from the preview
Don't miss anything!







What is OOPS? - ANSWER OOPS- Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class. Write basic concepts of OOPS? - ANSWER Abstraction. Encapsulation. Inheritance. Polymorphism. What is a class? - ANSWER A class is simply an appearance of any kind of object. It is a blueprint/plan/template that defines details about an object. What is an object? - ANSWER An object is an instance of a class. It has its own state, behavior, and identity. What is Encapsulation? - ANSWER Encapsulation is an attribute of an object, and it contains all data which is hidden. That hidden data can be restricted to the members of that class. Levels are Public, Protected, Private, Internal and Protected Internal.
What is Polymorphism? - ANSWER Polymorphism is nothing but assigning behavior or value in a subclass to something that was already declared in the main class. Simply, polymorphism takes more than one form. What is Inheritance? - ANSWER Inheritance is the concept where one class shares the structure and behaviour defined in another class. If inheritance applied on one class is called Single Inheritance, and if it depends on multiple classes, then it is called multiple Inheritance. What are manipulators? - ANSWER Manipulators are the functions which can be used in conjunction with the insertion (<<) and extraction (>>) operators on an object. Examples are endl and setw. Define a constructor? - ANSWER A constructor is a method used to initialize the state of an object, and it gets invoked at the time of object creation. Rules for constructor are:
,* can be used to pass through the function, and it has their own precedence to execute What is an abstract class? - ANSWER An abstract class is a class that cannot be instantiated. An object cannot be created with an abstract class; however, it can be inherited. An abstract class can contain only an abstract method. Java strictly allows only abstract methods in an abstract class, though for other languages, it is not so-Non abstract methods can also be permitted. What is a ternary operator? - ANSWER The ternary operator is said to be an operator that takes three arguments. Arguments and results are of different data types, and it depends on the function. The ternary operator is also called a conditional operator. What is the use of finalize method? - ANSWER Finalize method helps to perform cleanup operations on the resources which are not currently used. Finalize method is protected, and it is accessible only through this class or by a derived class. What are the different types of arguments? - ANSWER The parameter is a variable used during the declaration of the function or subroutine, and arguments are passed to the an, and it should match with the parameter defined. There are two types of Arguments. Call by Value: Value passed will be modified only inside the function, and it returns the same value whatever it is passed into the function. Call by Reference: Value passed will be modified in both inside and outside the functions, and it returns the same or different value. Does a static analyzer need to be sound to be useful? - ANSWER No it can still help reduce the number of dynamic checks
What is the super keyword? - ANSWER Super keyword is used to invoke the overridden method which overrides one of its superclass methods. This keyword allows to access overridden methods and also to access hidden members of the superclass. It also forwards a call from a constructor to a constructor in the superclass. What is method overriding? - ANSWER Method overriding is a feature that allows a subclass to provide the implementation of a method that overrides in the main class. This will overrides the implementation in the superclass by providing the same method name, same parameter and same return type. What is an interface? - ANSWER The interface is a collection of an abstract method. If the class implements inheritance, it thereby inherits all the abstract methods of an interface. What is exception handling? ANSWER An exception is an event that occurs during the execution of a program. Exceptions can be of any type - Runtime exception, Error exceptions. Those exceptions are adequately handled through exception handling mechanism like try, catch and throw keywords. What are tokens? - ANSWER The token is recognizable by a compiler, and it cannot be subdivided into component elements. The examples of tokens are Keywords, identifiers, constants, string literals and operators. Even punctuation characters are also considered as tokens - Brackets, Commas, Braces and Parentheses.
Friend. Protected Friend. What are sealed modifiers? - ANSWER Sealed modifiers are the access modifiers where it cannot be inherited by the methods. Sealed modifiers can also be applied to properties, events and methods. This modifier cannot be applied to static members. How can we invoke a base method w/o instantiating? - ANSWER Yes, it's possible to invoke a base method w/o creating any instance. And that method should be "Static method". Doing the inheritance from that class.-Use Base Keyword from a derived class. What is the difference between new and override? - ANSWER The new modifier tells the compiler to use the new implementation instead of the base class function. Whereas, Override modifier helps to override the base class function. What are the different types of constructors? - ANSWER There are three different types of constructors, and they are as follows:
What is early and late binding? - ANSWER Early binding refers to the assignment of values to variables during design time whereas late binding refers to the assignment of values to variables during run time. What is 'this' pointer? - ANSWER THIS pointer refers to the current object of a class. THIS keyword is used as a pointer which differentiates between the current object with the global object. Basically, it refers to the current object. What is the difference between structure and a class? ANSWER Structure default access type is public, but class access type is private. A structure is used for grouping data whereas class can be used for grouping data and methods. Structures are exclusively used for data, and it doesn't require strict validation, but classes are used to encapsulates and inherit data which requires strict validation. What is the default access modifier in a class? - ANSWER The default access modifier of a class is Private by default What is a pure virtual function? - ANSWER A pure virtual function is a function which can be overridden in the derived class but cannot be defined. A virtual function can be declared as Pure by using the operator =0. What all operators can not be overloaded? - ANSWER Following are the operators that can not be overloaded -. Scope Resolution (:: ) Member Selection (.) Member selection through a pointer to function (*. )
In dynamic binding, a name can be associated with the class during execution time; it is also called as Late Binding. How many instances can be created for an abstract class? - ANSWER Zero instances are created for an abstract class. Which keyword can be used for overloading? - ANSWER Operator keyword is used for overloading. What is the default access specifier in a class definition? - ANSWER Private access specifier is used in a class definition. Which OOPS concept is used as reuse mechanism? - ANSWER Inheritance is the OOPS concept that can be used as reuse mechanism. Which OOPS concept exposes only necessary information to the calling functions? - ANSWER Encapsulation