0% found this document useful (0 votes)
11 views5 pages

Understanding OOP Concepts and Terminology

Uploaded by

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

Understanding OOP Concepts and Terminology

Uploaded by

yashikasengar16
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#separator:tab

#html:false

What is OOPS?
Object Oriented Programming system is a system in which programs are considered as a collection of objects.
Each object is nothing but an instance of a class.

What are the basic concepts of OOPS?


TheObject Oriented Programming system is a system in which programs are considered as a collection of objects.
basic conceps of OOPS are Abstraction :- It is the process of hiding the implementation details and only showing
the essential details or features to the user. To implement Abstraction Abstract Classes and Interfaces are
[Link] world example of Abstraction is an ATM [Link] :- Encapsulation is the practise of
bundling related data into a structured unit along with the methods used to work with the data. It is implemented
primarily through classes and the objects instantiated through those classes. An real world example of
Encapsulation is an [Link] :- The capability of a class to derive properties and characteristics from
another class is called inheritance. An real world example of inheritance is the relationship between parent and
[Link] :- It is a core concept in Object Oriented progrmming that allows the same method or object to
behave differently based on the context. An real world example is a person who can act in different roles or
capacities depending on the situation

What is a class?
A class is simply a representation of a type of object. It is the blueprint that describes the details of an object. It
defines the structure and behavious that the objects created from the class will have.

What is an Object?
An object in Java is a real-world instance of a class. It represents an individual unit that has state and behavior.
The state is defined by the object’s attributes or fields (like color, name, balance). The behavior is defined by its
methods or functions (like drive(), withdraw(), display()).

Explain the term constructor ?


A constructor in Java (or any object-oriented language) is a special method that is automatically called when an
object is created. Its main purpose is to sets the initial values of the object's variables. Types of Constructors in
Java: Default Constructor – Provided by the compiler if no constructor is defined. It initializes variables to default
values. Parameterized Constructor – Allows setting custom values at the time of object creation.

Define Destructor ?
A destructor is a method which is automatically called when the object is made of scope or destroyed. Destructor
name is also same as class name but with the tilde symbol befor the name.

What is an Inline function?


An inline function is a function where the compiler replaces the function call with the actual code of the function at
compile time. This is typically used to reduce the overhead of function calls, especially for small and frequently
used [Link] reduces the overhead of function calls which leads to faster execution and is good for small
functions.

What is a virtual function?


A virtual function is a member function that is declared within a base class and can be overridden by derived
classes. When a method is declared as virtual, the compiler determines which version of the method to call based
on the actual type of the object at runtime rather than the type of reference variable.

What is a friend function?


A friend function can be granted special access to private and protected members of a class. They are not the
member functions of the class but can access and manipulate the private and protected members of that class for
they are declared as friends. It is declared using the keyword friend inside the class whose members it needs to
access.

What is function overloading?


Function Overloading is a feature of object-oriented programming where two or more functions can have the same
name but different parameters. This allows one function to perform different tasks depending on the context of the
call. The functions must differ either by the numbers or types of their parameters. It’s a form of static
polymorphism, and the specific function to call is resolved at compile time. This increases the readability and
flexibility of the program.

What is operator overloading?


Operator Overloading is s method by which we can redefine the behavior of certain operators in Programming.
Operator Overloading is a way to implement Polymorphism by providing different implementations to a single
operators based on the data types on which they are operated. Operator Overloading is a way to redefine the
behavior of existing operators for user-defined types.

What is an abstract class?


An abstract class is basically a class that you can’t create an object from directly. It’s meant to be extended by
other classes. it like a template—it lays down some common structure or behavior, but leaves parts of it for the
subclasses to fill in. it can have both fully implemented methods and abstract methods—which are just method
declarations without any code.

Which OOPS concept exposes only the necessary information to the calling functions?
Encapsulation

Which OOPS concept is used as a reuse mechanism?


Inheritance

What is the default access specifier in a class definition?


Private access specifier

How many instances can be created for an abstract class?


You cannot create an instance of an Abstract class.

What is static and dynamic Binding?


Binding is nothing but the association of a name with the class. Static Binding is a binding in which name can be
associated with the class during compilation time. It is also called as early Binding. Dynamic Binding is a binding in
which name can be associated with the class during execution time. It is also called as Late Binding.

What are base class, subclass and superclass?


The base class is a class from which other classes can inherit properties and methods. A Subclass is a class that
inherits from one or more base classes. The superclass is the parent class from which another class inherits.

What does the keyword virtual represented in the method definition?


It means we can override the method.

What is a copy constructor?


This is a special constructor for creating a new object as a copy of an existing object. There will always be only
one copy constructor that can be either defined by the user or the system.
What is dynamic or run time polymorphism?
Dynamic or run time polymorphism is also known a method overriding in which A child class can redefine a
method of its parent class. In this two or more class have same name and parameters.

What are all the operators that cannot be overloaded


Scope Resolution Member Selection

What is a pure virtual function?


A pure virtual function is a concept from C++—Java doesn’t use that exact term, but the closest equivalent would
be an abstract method. In C++, a pure virtual function is one that’s declared in a base class but has no
implementation, and it forces derived classes to override it.

What is the difference between structure and a class?


A structure is used for grouping data whereas a 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 encapsulate and inherent
data, which requires strict validation.

What is this pointer?


'this' pointers is a pointer to the current instance of a class. It is used to refer to the object within its own member
functions.

What are the various types of constructors?


There are three types of constructors Default constructor - With no [Link] constructor - With
Parameters. Create a new instance of a class and also passing arguments [Link] Constructor -
Which creates a new object as a copy of an existing object.

What is the difference between new and override?


The new modifier instructs the compiler to use implementation instead of the base class function. Whereas
Override modifier helps to override the base class function.

How can we call the base method without creating an instance?


Yes, it is possible to call the base method without creating an instance. To do this the base method needs to be
declared as static.

What are sealed modifires?


They are used to restrict the inheritance and overriding capabilities of classes and methods.

What are the access modifiers?


Access Specifiers are predefined keywords used to help JVM understand the scope of a variable, method, and
class.. The type of access modifiers are public:-The public access modifier is specified using the keyword public.
Classes, methods, or data members that are declared as public are accessible from everywhere in the program.
There is no restriction on the scope of public data [Link]:- The protected access modifier is specified
using the keyword protected. The methods or data members declared as protected are accessible within the same
package or subclasses in different [Link]:- When no access modifier is specified for a class, method, or
data member, it is said to have the default access modifier by default. This means only classes within the same
package can access [Link]:- The private access modifier is specified using the keyword private. The methods
or data members declared as private are accessible only within the class in which they are declared.

What is the main difference between a class and an object?


A class is like a blueprint—it defines the structure and behavior, like what variables and methods it should have.
An object is the actual thing you build from that blueprint. It’s an instance of the class, with real values and
memory allocation.

What is the main difference between overloading and overriding


Overloading happens when you have multiple methods with the same name in the same class, but with different
parameter lists. It’s resolved at compile-time—Java decides which method to call based on the arguments.
Overriding, on the other hand, is when a subclass provides its own version of a method that it inherits from a
parent class. That’s decided at runtime, based on the actual object type.

What are tokens?


Tokens are the smallest elements of a program that is meaningful to the compiler. They are also known as the
fundamental building blocks of the program. Tokens can be classified as follows:Keywords:- Keywords are
pre-defined or reserved words in a programming [Link]:- Identifiers are used as the general
terminology for naming of variables, functions, and [Link]/Literals:- Constants are also like normal
variables. But the only difference is, their values cannot be modified by the program once they are
[Link]:- Separators are used to separate different parts of the codes. It tells the compiler
about completion of a statement in the program.

throws keyword
"throws is a keyword in Java that is used in the signature of a method to indicate that this method might throw one
of the listed type exceptions. The caller to these methods has to handle the exception using a try-catch block. //
Java program to illustrate throws class Geeks { public static void main(String[] args) throws InterruptedException {
[Link](10000); [Link](""Hello Geeks""); } }"

What is a ternary operator?


The ternary operator is a shortcut for writing simple if-else statements. It uses ? and : and takes three parts—a
condition, a result if true, and a result if false. It’s useful when you want to assign a value based on a condition in a
single line, without writing a full if-else block.

What is the use of finalize method?


Finalize methods helps to perform cleanup operations on the resources which are not currently used.

What is an interface?
An interface defines what a class should do, but not how it does it. It has method signatures and constants. Any
class that implements the interface agrees to provide the actual implementations. It’s a way to achieve abstraction
and multiple inheritance in Java, and it's super useful when you want different classes to follow the same structure
but have their own behaviors.

What are different types of arguments?


Whenever any particular method is called during the execution of the program, there are some values that are
passed to call that method. These values are called arguments. There are two type of Arguments Call by value:-
value passed will get modified only inside the function and it returns the same value whatever it is passed into the
[Link] by Reference:- Value passed will get modified in both inside and outside the functions and it returns
the same or different value.

What are manipulators?


Manipulators are the functions which can be used in conjuncton with the insertion operators on an object.
Examples are endl and setw.

What is the super keyword


The 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.
What is exception handling?
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 handled through exception handling mechanism like try, catch,
and throw keywords.

What are sealed modifiers?


Sealed modifiers are the access modifiers where the methods can not inherit it.

What is early and late Binding?


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 the default access modifier in a class?


The default access modifier of a class is Private by default

You might also like