SlideShare a Scribd company logo
1 of 20
Basics of Object Oriented
Programming
Dr.A.Martin, ME, Ph.D.
Assistant Professor,
Dept. of Computer Science,
School of Mathematics and Computer Sciences,
Central University of Tamil Nadu,
Thiruvarur, Tamilnadu-610 101.
Agenda
• Structured Programming
• Limitations in Structured Programming
• Object Oriented Programming
• Classes and Objects
• OOP’s Principles
• Static and Non Static Data
• Accessibility
• Exception Handling and Templates
Structured Programming
• It employs a top-down design model - map
out the overall program structure into
separate subsections.
• A defined function or set of similar functions
is coded in a separate module or sub module.
• Most famous for removing or reducing flaws
on the GOTO statement.
• E.g. C – The Programming Language.
Limitations in structured programming
• Data hiding
• Debugging of programs are hard
– Not Possible to handle run time errors and future
enhancements.
• Non Flexibility of Code
– In procedural programming, parts of code are
interdependent.
– This interdependency makes modification &
manipulation of a particular part of the program
without affecting other parts.
Limitations in structured programming
• Software development period is high.
• Software cost is high.
• If end user requirement changes a big
modification is needed in software
• More stress laid on procedures not on data
Object Oriented Programming
• In object oriented programming data and the
instruction for processing that data are
combined into a self-sufficient “object” that
can be used in other programs.
• It is a programming methodology used to
solve and develop complex problems by using
oops principles.
• Real world objects
• Software Objects
• Mapping of Real objects to software objects.
Class and Objects
• A Vehicle – A Car
• Mechanism – Break System, Radiator Cooling
System, Auto Door Lock, Air Conditioning, Safety
System, Security Mechanism, Gear Mechanism,
etc.,
• Spare Parts - Tires, Number of Tires, Head Light,
Density of air in tiers, Switch, window, door,
Number of windows and doors, Number of
seats.
• Car created with mechanism and spare parts.
• So many types – all from same car – differs in
flexibility and luxuries.
• Class – The bundling of data and functions
that acting on data on a single place.
• Class is a mould upon which objects are
created.
• The logical thing class is invoked by the real
thing object.
• The instance of the class is object.
OOPs Principles,
Encapsulation
Inheritance
Polymorphism
Data abstraction
Encapsulation – A rigid wall
• The binding of data and functions together to
achieve information hiding and modularity.
• Not allowed to enter.
• Not same kind of restriction to everyone.
• We want to some level of flexibility.
• Accessibility – access specifiers
• Public , Private and Protected
• Default.
Inheritance
 It allows the creation of hierarchical classifications.
 Using inheritance, you can create a general class that
defines common properties.
 This class may then inherit by more specific classes,
each adding only those things that are unique to the
inheriting class.
 The process of creating new classes from existing
classes.
 A class that inherited is referred to as a base class.
 The class that does the inheriting is called derived
class.
Benefits,
 New classes can be derived by the user
from the existing classes without any
modification.
 It saves time and money.
 It reduces program coding time.
 It increases the reliability of the program.
Types of Inheritance
 Single : one base class and derived class
 Multiple : Many base class to one derived
class
 Multilevel : derived classes in a sequential
order
 Hierarchical : one base class and many
derived class
 Hybrid : A class derived from a base class
and an inheritance class
Polymorphism
• One interface with different forms
• Moving of a vehicle – Energy required.
• Energy available in different forms
• Fuel – Petrol, Diesel, Solar, Electric – Battery.
• Objective – Moving – achieved with different
ways.
• Compile time polymorphism and Run time
polymorphism.
Compile time polymorphism and Run time
polymorphism.
• Function overloading
 Same function with different arguments
Sum(int a ,int b)
Sum (double a, double b)
Sum (double a, double b, double c)
Sum (int a, long b)
 Need not worry about return type.
Function overriding
• Both base class and sub class have the
identical function.
• Same name, same number of arguments,
same data type.
• The function which is available in derived class
overrides the function in base class – called as
function overriding.
Static and Non Static Data
• Single copy shared by all instances
• Individual copy for every object
• How objects created for a class.
• How memory is allocated and reclaimed for
objects.
• Garbage collection.
• Constructor and Destructor. [C++]
• Constructor and Garbage Thread [Java].
Accessibility Levels
• Public, Private and Protected. [C++]
• Public, Private and Protected and default.
[Java]
this pointer
• Avoids name collision
• Refers the current object
Templates
• Templates are mechanism that make it
possible to use one function or class to handle
different data types.
• Function Template
• Class Template

More Related Content

Similar to Basics of object oriented programming interview tips for Java

1unit-120324103142-phpapp02.pdf
1unit-120324103142-phpapp02.pdf1unit-120324103142-phpapp02.pdf
1unit-120324103142-phpapp02.pdf
SahajShrimal1
 
8 oo approach&uml-23_feb
8 oo approach&uml-23_feb8 oo approach&uml-23_feb
8 oo approach&uml-23_feb
Raj Shah
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop ppt
daxesh chauhan
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
Jay Patel
 

Similar to Basics of object oriented programming interview tips for Java (20)

SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
Cs2305 programming paradigms lecturer notes
Cs2305   programming paradigms lecturer notesCs2305   programming paradigms lecturer notes
Cs2305 programming paradigms lecturer notes
 
1unit-120324103142-phpapp02.pdf
1unit-120324103142-phpapp02.pdf1unit-120324103142-phpapp02.pdf
1unit-120324103142-phpapp02.pdf
 
8 oo approach&uml-23_feb
8 oo approach&uml-23_feb8 oo approach&uml-23_feb
8 oo approach&uml-23_feb
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop ppt
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdf
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
Basic concepts of oops
Basic concepts of oopsBasic concepts of oops
Basic concepts of oops
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
Unit 2.pptx
Unit 2.pptxUnit 2.pptx
Unit 2.pptx
 
Unit 2.pptx
Unit 2.pptxUnit 2.pptx
Unit 2.pptx
 
Deep Learning For Practitioners, lecture 2: Selecting the right applications...
Deep Learning For Practitioners,  lecture 2: Selecting the right applications...Deep Learning For Practitioners,  lecture 2: Selecting the right applications...
Deep Learning For Practitioners, lecture 2: Selecting the right applications...
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) Introduction
 
PPL, OQL & oodbms
PPL, OQL & oodbmsPPL, OQL & oodbms
PPL, OQL & oodbms
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
 
CPP19 - Revision
CPP19 - RevisionCPP19 - Revision
CPP19 - Revision
 
Better Understanding OOP using C#
Better Understanding OOP using C#Better Understanding OOP using C#
Better Understanding OOP using C#
 

Recently uploaded

Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Andrea Goulet
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Lisi Hocke
 

Recently uploaded (20)

architecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdfarchitecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdf
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
 
The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements Engineering
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
 
Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...
Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...
Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
 

Basics of object oriented programming interview tips for Java

  • 1. Basics of Object Oriented Programming Dr.A.Martin, ME, Ph.D. Assistant Professor, Dept. of Computer Science, School of Mathematics and Computer Sciences, Central University of Tamil Nadu, Thiruvarur, Tamilnadu-610 101.
  • 2. Agenda • Structured Programming • Limitations in Structured Programming • Object Oriented Programming • Classes and Objects • OOP’s Principles • Static and Non Static Data • Accessibility • Exception Handling and Templates
  • 3. Structured Programming • It employs a top-down design model - map out the overall program structure into separate subsections. • A defined function or set of similar functions is coded in a separate module or sub module. • Most famous for removing or reducing flaws on the GOTO statement. • E.g. C – The Programming Language.
  • 4. Limitations in structured programming • Data hiding • Debugging of programs are hard – Not Possible to handle run time errors and future enhancements. • Non Flexibility of Code – In procedural programming, parts of code are interdependent. – This interdependency makes modification & manipulation of a particular part of the program without affecting other parts.
  • 5. Limitations in structured programming • Software development period is high. • Software cost is high. • If end user requirement changes a big modification is needed in software • More stress laid on procedures not on data
  • 6. Object Oriented Programming • In object oriented programming data and the instruction for processing that data are combined into a self-sufficient “object” that can be used in other programs. • It is a programming methodology used to solve and develop complex problems by using oops principles. • Real world objects • Software Objects • Mapping of Real objects to software objects.
  • 7. Class and Objects • A Vehicle – A Car • Mechanism – Break System, Radiator Cooling System, Auto Door Lock, Air Conditioning, Safety System, Security Mechanism, Gear Mechanism, etc., • Spare Parts - Tires, Number of Tires, Head Light, Density of air in tiers, Switch, window, door, Number of windows and doors, Number of seats. • Car created with mechanism and spare parts. • So many types – all from same car – differs in flexibility and luxuries.
  • 8. • Class – The bundling of data and functions that acting on data on a single place. • Class is a mould upon which objects are created. • The logical thing class is invoked by the real thing object. • The instance of the class is object.
  • 10. Encapsulation – A rigid wall • The binding of data and functions together to achieve information hiding and modularity. • Not allowed to enter. • Not same kind of restriction to everyone. • We want to some level of flexibility. • Accessibility – access specifiers • Public , Private and Protected • Default.
  • 11. Inheritance  It allows the creation of hierarchical classifications.  Using inheritance, you can create a general class that defines common properties.  This class may then inherit by more specific classes, each adding only those things that are unique to the inheriting class.  The process of creating new classes from existing classes.  A class that inherited is referred to as a base class.  The class that does the inheriting is called derived class.
  • 12. Benefits,  New classes can be derived by the user from the existing classes without any modification.  It saves time and money.  It reduces program coding time.  It increases the reliability of the program.
  • 13. Types of Inheritance  Single : one base class and derived class  Multiple : Many base class to one derived class  Multilevel : derived classes in a sequential order  Hierarchical : one base class and many derived class  Hybrid : A class derived from a base class and an inheritance class
  • 14. Polymorphism • One interface with different forms • Moving of a vehicle – Energy required. • Energy available in different forms • Fuel – Petrol, Diesel, Solar, Electric – Battery. • Objective – Moving – achieved with different ways. • Compile time polymorphism and Run time polymorphism.
  • 15. Compile time polymorphism and Run time polymorphism. • Function overloading  Same function with different arguments Sum(int a ,int b) Sum (double a, double b) Sum (double a, double b, double c) Sum (int a, long b)  Need not worry about return type.
  • 16. Function overriding • Both base class and sub class have the identical function. • Same name, same number of arguments, same data type. • The function which is available in derived class overrides the function in base class – called as function overriding.
  • 17. Static and Non Static Data • Single copy shared by all instances • Individual copy for every object • How objects created for a class. • How memory is allocated and reclaimed for objects. • Garbage collection. • Constructor and Destructor. [C++] • Constructor and Garbage Thread [Java].
  • 18. Accessibility Levels • Public, Private and Protected. [C++] • Public, Private and Protected and default. [Java]
  • 19. this pointer • Avoids name collision • Refers the current object
  • 20. Templates • Templates are mechanism that make it possible to use one function or class to handle different data types. • Function Template • Class Template