0% found this document useful (0 votes)
5 views22 pages

Interview Oops - Notes

OOPS (Object-Oriented Programming System) is a programming paradigm centered around objects and classes, facilitating code reusability and organization. Key concepts include inheritance, polymorphism, encapsulation, and abstraction, which allow for efficient data handling and method management. The document also touches on data structures, JavaScript, cloud computing, and database normalization, providing a comprehensive overview of programming principles and practices.

Uploaded by

ggsarumathi
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)
5 views22 pages

Interview Oops - Notes

OOPS (Object-Oriented Programming System) is a programming paradigm centered around objects and classes, facilitating code reusability and organization. Key concepts include inheritance, polymorphism, encapsulation, and abstraction, which allow for efficient data handling and method management. The document also touches on data structures, JavaScript, cloud computing, and database normalization, providing a comprehensive overview of programming principles and practices.

Uploaded by

ggsarumathi
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
You are on page 1/ 22

OOPS:

1.​ OOPS is a multi-paradigm programming language that is based on objects


rather than functions and procedures.
2.​ It is a bottom up approach [Bottom-up approach begins with low level
design or development and ends with high level design. In bottom up
approach, code is developed for modules and then these modules are integrated
with main() function]
3.​ It can solve problem of any complexity
4.​ Individual objects are grouped into classes.
5.​ OOPS implements real world entities like inher,poly,abstr and
Encapsulation.

Class---USER DEFINED DATATYPE

A Class is like an object constructor, or a "blueprint" for creating objects.

which contains some values, known as member data or member, and some set of rules,
known as behaviors or functions.

Eg:car template is created and multiple units of car are created based on the
template.

Athula iruka types objects.

Objects

An Object is an instance of a Class and it is a real world entity.An Object is an


identifiable entity with some characteristics and behaviour.

Eg:cat, dog

Following properties state ,behaviour

Everything in python is treated as objects including list,tuples dict…..

Inheritance

Inheritance allows us to define a class that inherits all the methods and
properties from another class.(child class inherits the data from parent class)

Parent class is the class being inherited from, also called base class.
Child class is the class that inherits from another class, also called derived class.

Inheritance supports the concept of code reusability.

●​ Single Inheritance (only one super and subclass)--- child class inherits the data
from the parent class (mobile phone and sub is samsung ,redmi)

●​ Multiple Inheritance (several superclasses for a subclass)----If class b , c ,d are


there all inherits the data from class a.

●​ Multilevel Inheritance (subclass is super class of another class) ---- Three


classes are there class c is derived from class B and class B is derived from
class A(iphone 12 to iphone 6 - mobile phones)

●​ Hierarchical Inheritance (one base class have multiple deriving classes)

●​ Hybrid Inheritance (combination of multi level and multiple)

Polymorphism

Polymorphism is the ability of a message to be displayed in more than one form.

It is of two types :

Compile time poly--- resolved during the compilation process

1)​ Method overloading---Function overloading is the ability to have multiple


functions with the same name but with different
signatures/implementations.
2)​ Operator overloading ---giving an extended meaning beyond their predefined
operational meaning.add two integer join 2 string and merge 2 lists

Runtime polymorphism---all is not resolved by the compiler.

Eg:
Human Behaviour

Mobile phones

Encapsulation:

Encapsulation describes the concept of bundling data and methods within a single
unit.

School bag is one of the most real examples of Encapsulation. School bag can keep
our books, pens, etc. Realtime Example 2: When you log into your email accounts such
as Gmail, Yahoo Mail, or Rediff mail, there is a lot of internal processes taking place in
the backend and you have no control over it.

Abstraction:

Hiding unnecessary details from the user.

ATM OPERATIONS - Because for example in atm machine --- We can use it for
withdrawal,retrieve mini receipt etc that is displaying relevant details and hiding
unnecessary details.

DATASTRUCTURES

Stack --- is a linear ds that is last in first out --undo /redo in excel

Queue fifo -single lane one way road, tollgate

Linked lists - prev and next page in web browsers or train

Trees- NON LINEAR ----file system that directories to folders to…


Graphs - used to estimate read off values

JavaScript is a text-based programming language used both on the client-side and


server-side that allows you to make web pages interactive.

cloud computing is the delivery of computing services—including


servers, storage, databases, networking, software, analytics, and
intelligence—over the Internet (“the cloud”) to offer faster
innovation, flexible resources, and economies of scale.it is a term
used to describe a global network of servers, each with a unique
function.

OOPS:

OOPS in java is to improve code readability and reusability by defining a Java


program efficiently. Programming languages name----.Bottom up approach ..This
approach contains less redundancy if the data encapsulation and data
hiding are being used.
Class---collection of objects

A Class is like an object constructor, or a "blueprint" for creating objects.

Class – A User-defined data type that holds data members and functions whose access
can be specified as private, public, or protected.
Eg:car

Athula iruka types objects.

a car is an object. The car has attributes, such as weight and color, and methods, such
as drive and brake.

Objects

An Object is an instance of a Class. A class is like a blueprint while an instance is a


copy of the class with actual values.

Following properties state ,behaviour

Everything in python is treated as objects including list,tuples dict…..

A dog is an object because it has states like color, name, breed, etc.

Inheritance

Inheritance allows us to define a class that inherits all the methods and
properties from another class.(child class inherits the data from parent class)

Parent class is the class being inherited from, also called base class.

Child class is the class that inherits from another class, also called derived class.

It provides code reusability.

Single,multi level-archieved when derived inherits another derived class,multiple


- multiple base classes in the child class.

SI:
a sub-class is derived from only one super class. It inherits the properties and behavior
of a single-parent class. Sometimes it is also known as simple inheritance.

In the above figure, Employee is a parent class and Executive is a child class. The
Executive class inherits all the properties of the Employee class.

Multilevel

It is a chain of inheritance. As you can see the example below the CLass as box…weight
…shipment

ship> weight

weight>box

Class inherits the data(ship) from both class a and b

Or

When a class extends a class, which extends another class then this is called
multilevel inheritance. For example class C extends class B and class B extends
class A then this type of inheritance is known as multilevel inheritance.

Multiple
multiple inheritances the newly derived class can have more than one
superclass.

Mobile have two models like samsung and vivo

Hierarchical
When two or more classes inherit a single class, it is known as hierarchical inheritance.
In the example given below, Dog and Cat classes inherit the Animal class, so there is
hierarchical inheritance.

Hierarchial
If a number of classes are derived from a single base class, it is called hierarchical
inheritance.

English,science ,social inherits a single parent class.

Hybrid

Hybrid inheritance means consist of more than one.Hybrid is the combination of one or
types inheri
Polymorphism

If one task is performed in different ways, it is known as polymorphism.

Polymorphism in python defines methods in the child class that have the same
name as the methods in the parent class.

Human beviuour

For example, a person acts as an employee in the office, a customer in the shopping
mall, a passenger in bus/train, a student in school, and a son at home.

If a class has multiple methods having same name but different in parameters, it is known as
Method Overloading.

Compile-time polymorphism is a polymorphism that is resolved during the compilation process

Encapsulation:

Encapsulation in Python describes the concept of bundling data and methods within
a single unit.
School bag is one of the most real examples of Encapsulation. School bag can keep
our books, pens, etc. Realtime Example 2: When you log into your email accounts such
as Gmail, Yahoo Mail, or Rediff mail, there is a lot of internal processes taking place in
the backend and you have no control over it.

Abstraction:

Hiding unnecessary details from the user.

ATM OPERATIONS

Static method:

Static methods, much like class methods, are methods that are bound to a
class rather than its object. They do not require a class instance creation. So,
they are not dependent on the state of the object.

To perform cal and return value

Static variable:

When we declare a variable inside a class, but outside the method, it is called a
static or class variable.
Method overriding -- runtime polymorphism. In this, the specific implementation of

the method that is already provided by the parent class is provided by the child
class. It is used to change the behavior of existing methods and there is a need
for at least two classes for method overriding. I

Method overloading

python does not support method overloading by default.

Latest defined method

Friend Function:

a function that is given the same access as methods to private and protected
data.

Object overloading

Overloading is a method or operator that can do different functionalities with the


same name.

Stack --- is a linear ds that is last in first out --undo /redo in excel

Queue fifo -single lane one way road, tollgate

Linked lists - prev and next page in web browsers ---spotify playlist

Trees -- Organization structure------------------


Graphs - used to estimate read off values (Google maps)----------road
networks,fastest route

Multithreading

A thread is the smallest unit of a program or process executed independently or


scheduled by the Operating System.

Multithreading refers to concurrently executing multiple threads by rapidly


switching the control of the CPU between threads

EG:

a word processing program that checks the spelling of words in a document


while writing the document.

Multiprocessing

multiprocessing is a package that supports spawning (that loads and executes new
module) processes using an API similar to the threading module.

Join keys

is used to combine rows from two or more tables, based on a related column
between them.

●​ (INNER) JOIN: Returns records that have matching values in both tables
●​ LEFT (OUTER) JOIN: Returns all records from the left table, and the
matched records from the right table
●​ RIGHT (OUTER) JOIN: Returns all records from the right table, and the
matched records from the left table
●​ FULL (OUTER) JOIN: Returns all records when there is a match in either
left or right table

Normalisation:
●​ Normalization is the process of organizing the data in the database.

●​ Normalization is used to minimize the redundancy from a relation or set of


relations. It is also used to eliminate the undesirable characteristics like Insertion,
Update and Deletion Anomalies.

1NF A relation is in 1NF if it contains an atomic value.

2NF A relation will be in 2NF if it is in 1NF and all non-key attributes are fully

functional dependent on the primary key.

3NF A relation will be in 3NF if it is in 2NF and no transition dependency exists.

4NF A relation will be in 4NF if it is in Boyce Codd normal form and has no

multi-valued dependency.

Data Modelling is the process of analyzing the data objects and their relationship
to the other objects.
In Compile time Polymorphism, the call is resolved by the compiler. In Run time
Polymorphism, the call is not resolved by the compiler.

What is static and dynamic binding?

In Java static binding refers to the execution of a program where type of object is
determined/known at compile time i.e when compiler executes the code it know the type
of object or class to which object belongs. While in case of dynamic binding the type of
object is determined at runtime

In Java, an interface is a reference type similar to a class that can contain only
constants, the method signatures, default methods, and static methods, and its Nested
types.
Java Exception handling framework is used to handle runtime errors only. The
compile-time errors have to be fixed by the developer writing the code else the program
won't execute.
●​ Ensures the Continuity of the Program. ...
●​ Enhances the Robustness of the Program. ...

What is exception handling with example?

Example: Exception handling using try...

In the example, we are trying to divide a number by 0 . Here, this code generates an
exception. To handle the exception, we have put the code, 5 / 0 inside the try block.
Now when an exception occurs, the rest of the code inside the try block is skipped.

A constructor in Java is similar to a method that is invoked when an object of


the class is created.

Here, Test() is a constructor. It has the same name as that of the class and doesn't have
a return type.
class Test {
Test() {
// constructor body
}
}

a keyword is a reserved word that conveys a specific meaning to the Java compiler
While--- entry control loop
Do while --- exit control loop
Class and objects
Inheritance -- single
Abstraction :
Polymorphism
class Bike{
1.​ void run(){System.out.println("running");}
2.​ }
3.​ class Splendor extends Bike{
4.​ void run(){System.out.println("running safely with 60km");}
5.​
6.​ public static void main(String args[]){
7.​ Bike b = new Splendor();//upcasting
8.​ b.run();
9.​ }
10.​}

encapsulation

You might also like