Question:- What do you understand by OOP?
Answer:- OOP stands for object-oriented programming. It is a programming paradigm that revolves around the object rather than function and procedure. In other words, it is an approach for developing applications that emphasize on objects. An object is a real word entity that contains data and code. It allows binding data and code together.
Question:- Name any seven widely used OOP languages.
Answer:- There are various OOP languages but the most widely used are: • Python • Java • Go • Dart • C++ • C# • Ruby
Question:- What is the purpose of using OOPs concepts?
Answer:- The aim of OOP is to implement real-world entities like inheritance, hiding, polymorphism in programming. The main purpose of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.
Question:- What are the four main features of OOPs?
Answer:- The OOP has the following four features: • Inheritance • Encapsulation • Polymorphism • Data Abstraction
Question:- Why OOP is so popular?
Answer:- OOPs, programming paradigm is considered as a better style of programming. Not only it helps in writing a complex piece of code easily, but it also allows users to handle and maintain them easily as well. Not only that, the main pillar of OOPs - Data Abstraction, Encapsulation, Inheritance, and Polymorphism, makes it easy for programmers to solve complex scenarios. As a result of these, OOPs is so popular.
Question:- What are the advantages and disadvantages of OOP?
Answer:- Advantages of OOP It follows a bottom-up approach. It models the real word well. It allows us the reusability of code. Avoids unnecessary data exposure to the user by using the abstraction. OOP forces the designers to have a long and extensive design phase that results in better design and fewer flaws. Decompose a complex problem into smaller chunks. Programmer are able to reach their goals faster. Minimizes the complexity. Easy redesign and extension of code that does not affect the other functionality. Disadvantages of OOP Proper planning is required. Program design is tricky. Programmer should be well skilled. Classes tend to be overly generalized.
Question:- What are the limitations of OOPs?
Answer:- • Requires intensive testing processes. • Solving problems takes more time as compared to Procedure Oriented Programming. • The size of the programs created using this approach may become larger than the programs written using the procedure-oriented programming approach. • Software developed using this approach requires a substantial amount of pre-work and planning. • OOP code is difficult to understand if you do not have the corresponding class documentation. • In certain scenarios, these programs can consume a large amount of memory. • Not suitable for small problems. • Takes more time to solve problems.
Question:- What do you understand by pure object-oriented language? Why Java is not a pure object-oriented programming language?
Answer:- The programming language is called pure object-oriented language that treats everything inside the program as an object. The primitive types are not supported by the pure OOPs language. There are some other features that must satisfy by a pure object-oriented language: • Encapsulation • Inheritance • Polymorphism • Abstraction • All predefined types are objects • All user-defined types are objects • All operations performed on objects must be only through methods exposed to the objects. Java is not a pure object-oriented programming language because pre-defined data types in Java are not treated as objects. Hence, it is not an object-oriented language.
Question:- What do you understand by class and object? Also, give example.
Answer:- • Class: A class is a blueprint or template of an object. It is a user-defined data type. Inside a class, we define variables, constants, member functions, and other functionality. It does not consume memory at run time. Note that classes are not considered as a data structure. It is a logical entity. It is the best example of data binding. • Object: An object is a real-world entity that has attributes, behavior, and properties. It is referred to as an instance of the class. It contains member functions, variables that we have defined in the class. It occupies space in the memory. Different objects have different states or attributes, and behaviors.
Question:- What is the concept of access specifiers when should we use these?
Answer:- In OOPs language, access specifiers are reserved keyword that is used to set the accessibility of the classes, methods and other members of the class. It is also known as access modifiers. It includes public, private, and protected. There is some other access specifier that is language-specific. Such as Java has another access specifier default. These access specifiers play a vital role in achieving one of the major functions of OOP, i.e. encapsulation. The following table depicts the accessibility.
Question:- What are the manipulators in OOP and how it works?
Answer:- Manipulators are helping functions. It is used to manipulate or modify the input or output stream. The modification is possible by using the insertion (<<) and extraction (>>) operators. Note that the modification of input or output stream does not mean to change the values of variables. There are two types of manipulators with arguments or without arguments.
Question:- What are the rules for creating a constructor?
Answer:- • It cannot have a return type. • It must have the same name as the Class name. • It cannot be marked as static. • It cannot be marked as abstract. • It cannot be overridden. • It cannot be final.
Question:- What are the characteristics of an abstract class?
Answer:- An abstract class is a class that is declared as abstract. It cannot be instantiated and is always used as a base class. The characteristics of an abstract class are as follows: • Instantiation of an abstract class is not allowed. It must be inherited. • An abstract class can have both abstract and non-abstract methods. • An abstract class must have at least one abstract method. • You must declare at least one abstract method in the abstract class. • It is always public. • It is declared using the abstract The purpose of an abstract class is to provide a common definition of the base class that multiple derived classes can share.
Question:- Is it possible for a class to inherit the constructor of its base class?
Answer:- No, a class cannot inherit the constructor of its base class.
