SlideShare a Scribd company logo
Object Oriented
Programming
Interview Preparation
Keet Malin Sugathadasa
Undergraduate
Department of Computer Science and Engineering
University of Moratuwa
Agenda
● Objects (Instances)
● Classes
● Advantages of OOP
● Disadvantages of OOP
● Let’s Design an OOP Solution
● OOP Concepts
● UML - Unified Modelling Language
● UML Syntax
● Associations
● Inheritance
● Cohesion and Coupling
Objects (Instances)
An Object can be used to effectively represent real world entities
● Object has
○ States (descriptive characteristics)
■ Simple Attributes- Primitive data types
■ Complex Attributes - Contains collections
○ Behaviours ( what it can do)
Example
● Keet’s Bank Account
○ State: Account number, Available balance
○ Behaviour: Make deposits, Withdraw
Classes
● An object is defined by a class
Advantages of OOP
● Code Reusing and Recycling
○ Saves development time and cost
● Encapsulation
○ Once object is created, knowledge of its implementation is not necessary for use.
● Design Benefits
○ Easy to understand. Large programs get more and more complex, but with OOP, designs can
be made with less flaws
● Software Maintenance
○ Programs are not disposable. An OOP is much easier to modify and maintain than a non-OOP
Disadvantages of OOP
● Size
○ OOPs are much larger than other programs
● Effort
○ OOPs require a lot of work and planning to develop
● Speed
○ OOPs are slower than other programs (Partially because of their size)
Object Oriented Problem Solving Approach
1. Identify the Problem
a. Carefully read the given problem and highlight the important points
2. Identify the Objects
a. Identify the main objects. Sometime two entities can be selected as one, but sometimes, it
might be better to have two instead of one complex one.
3. Identify the messages to be sent to other objects
a. Identify what kind of interactions happen between objects in classes
4. Create a sequence of messages to the objects - to solve the problem
a. Find a pattern to solve the final problem by interacting with different objects.
Let’s Design an OOP Solution
You need to create a Wedding Management System. Each wedding has a bride, a
groom, flower decorator, food provider, location etc. Each bride and groom has
their own parents and friends.
Find a way to model this problem into an OOP solution.
Just identifying the objects and the required interactions between them is
sufficient. Represent the interactions by simple arrows.
Overview of OOP
OOP Concepts
● Abstraction
○ Allows us to consider the important high level details
● Encapsulation
○ Allows us to consider what the program does and how it operates it. Without reading the
technical details of how it actually works
● Inheritance
○ Generalization and Specialization. Specialized objects can automatically inherit all the
characteristics of the more generalized objects.
● Polymorphism
○ Is the ability to interact with an object as its generalized category, regardless of its more
specialized category.
UML - Unified Modelling Language
● Class Diagrams
○ Classes show what the objects consists of and the methods
● Object Diagrams
○ Objects in the system and how they interact and the values in that object at a given state in time
● Sequence Diagrams
○ shows object interactions arranged in time sequence. How objects will interact to support one
specific function
● Package Diagrams
○ Packages and dependencies between packages
Class Consists of
● A unique Name
○ Conventionally starting with an Uppercase Letter
● A list of Attributes (Mostly Private)
○ Int, double, boolean, String, Complex Attributes
● A list of Methods (Mostly Public)
○ Unique method names starting with a Lowercase letter
Visibility Modifiers (Access Modifiers)
+ for public access
- for private access
UML allows us to suppress any information we do not wish to highlight in our
diagrams
UML Syntax
● Attributes
○ <visibility> <name> : <type> <multiplicity>
■ Eg: + custRef : int [1] → a public attribute custRef is a single int value
● Methods
○ <visibility> <name> ( <parameter 1> : <type 1> , …….) : <Return Type>
■ Eg: + addName (newName : String) : Boolean
Relationships Between Classes
● Some Class attributes can be complex
○ Can include some other class object as attributes
■ Eg: Teacher class has attribute → list of Students
○ String data type is a complex data type
■ Since it is part of the Java platform, it is implied that String is a primitive data type
Example
● ‘n’ → exactly n
● ‘*’ → zero or more
● ‘m..n; → between m and n
Types of Association
● Dependency A --------------------------> B
● Simple Association A B
● Bidirectional Association A B
● Aggregation A B
● Composition A B
Dependency
Class A in some way uses facilities defined by Class B. Changes to class B may
affect class A. There are 3 ways in which dependencies can occur
● Class A has a method, which passes as a parameter object of Class B
● Class A uses a local variable of Class B
● Class A calls static methods in Class B
Simple Association
Class A uses objects of Class B. Typically Class A has an attribute of Class B.
Navigability is from A to B.
● Class A objects can access Class B objects with which it is associated.
○ The reverse is not true.
Eg: Teacher wants to maintain a list of Students. So navigability is from Teacher to
Student. So Teacher object can access Student objects. But student objects do not
necessarily need access to teacher objects.
Bidirectional Association
This is when Class A and Class B has a two way association. Each refers to the
other class. Navigability is from A to B and B to A.
Navigability from A to B means
● Class A object can access Class B objects
● Objects of Class A “Has a” Class A
● This implies reference from A to B
Eg:
Between a “Degree” and “Student”. Given a degree, we may need to know which
students are studying on that degree. Alternatively, given a student, we may wish
to know the degree they are studying.
Aggregation
Aggregation denotes a situation where object(s) of Class B “Belongs to” Class B.
Aggregation also mentions that Objects of Class B, retain an existence
independent of Class A.
Eg:
We can think of tyres belonging to a car. Tyres “Belong To” Cars. But if our context
relates to a tyre shop or something, then Tyres can exist alone, in a garage as well.
Composition
● Composition is similar to aggregation, but implies a much stronger relationship.
● Class B objects are an integral part of Class A. In general, objects of class B
never exist other than as part of Class A. Both have the same lifetime.
Eg:
Between points, lines and shapes as elements of a picture. These objects can only
exist as part of a picture, and if the picture is deleted, they are also deleted.
Inheritance
Class A Class B
Class A inherits both implementation and interface of Class B.
This is how specialization and generalization works. Specialized classes can inherit
from generalized classes.
Interfaces
Class A Class B
● With interface inheritance, Class A will inherit only the interface of Class B.
● Class B contains only method headers
● Class A has to implement all methods defined in Class B
Cohesion
● Cohesion describes how closely all routines in a class or all the code in a
routing support a central purpose.
● Cohesion must be Strong.
● Classes must contain a strongly related functionality and aim for single
purpose
● Cohesion is an important tool for managing complexities
Coupling
● Coupling describes how tightly a class or routine is related to other classes or
routines.
● Coupling must be kept Loose.
○ Modules must depend little on each other
○ One module can be replaced easily without causing trouble
○ A module can be easily used by other modules
● Two types of Coupling
○ Tight Coupling
○ Loose Coupling

More Related Content

What's hot

Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
Ahmed Farag
 
object oriented Programming ppt
object oriented Programming pptobject oriented Programming ppt
object oriented Programming ppt
Nitesh Dubey
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
Jin Castor
 
Concept of OOPS with real life examples
Concept of OOPS with real life examplesConcept of OOPS with real life examples
Concept of OOPS with real life examples
Neha Sharma
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
Md.Al-imran Roton
 
Classes and Objects
Classes and Objects  Classes and Objects
Classes and Objects
yndaravind
 
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | EdurekaJava Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Edureka!
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
Md. Tanvir Hossain
 
Oops ppt
Oops pptOops ppt
Oops ppt
abhayjuneja
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
colleges
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
dheva B
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
Pina Parmar
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
Moutaz Haddara
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
Introduction to oop
Introduction to oop Introduction to oop
Introduction to oop
Kumar
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
Abhigyan Singh Yadav
 
Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
Jyothishmathi Institute of Technology and Science Karimnagar
 
[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP
Muhammad Hammad Waseem
 

What's hot (20)

Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
object oriented Programming ppt
object oriented Programming pptobject oriented Programming ppt
object oriented Programming ppt
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Concept of OOPS with real life examples
Concept of OOPS with real life examplesConcept of OOPS with real life examples
Concept of OOPS with real life examples
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Classes and Objects
Classes and Objects  Classes and Objects
Classes and Objects
 
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | EdurekaJava Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
 
Introduction to oop
Introduction to oop Introduction to oop
Introduction to oop
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
 
[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP
 

Similar to Object oriented programming interview questions

Object Oriented, Design patterns and data modelling worshop
Object Oriented, Design patterns and data modelling worshopObject Oriented, Design patterns and data modelling worshop
Object Oriented, Design patterns and data modelling worshop
Mohammad Shawahneh
 
Concepts of oops
Concepts of oopsConcepts of oops
Concepts of oops
Sourabrata Mukherjee
 
Lecture 4-oop class diagram
Lecture 4-oop class diagramLecture 4-oop class diagram
Lecture 4-oop class diagram
ktuonlinenotes
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
sharmisivarajah
 
Advanced Programming _Abstract Classes vs Interfaces (Java)
Advanced Programming _Abstract Classes vs Interfaces (Java)Advanced Programming _Abstract Classes vs Interfaces (Java)
Advanced Programming _Abstract Classes vs Interfaces (Java)
Professor Lili Saghafi
 
2CPP05 - Modelling an Object Oriented Program
2CPP05 - Modelling an Object Oriented Program2CPP05 - Modelling an Object Oriented Program
2CPP05 - Modelling an Object Oriented Program
Michael Heron
 
Unified Modelling Language
Unified Modelling Language Unified Modelling Language
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
Kabindra Koirala
 
Problem solving with python programming OOP's Concept
Problem solving with python programming OOP's ConceptProblem solving with python programming OOP's Concept
Problem solving with python programming OOP's Concept
rohitsharma24121
 
oopm 2.pdf
oopm 2.pdfoopm 2.pdf
oopm 2.pdf
jayeshsoni49
 
Introduction to OOA and UML
Introduction to OOA and UMLIntroduction to OOA and UML
Introduction to OOA and UML
Veneet-BA
 
Introduction to OOA and UML
Introduction to OOA and UMLIntroduction to OOA and UML
Introduction to OOA and UML
Veneet-BA
 
CPP14 - Encapsulation
CPP14 - EncapsulationCPP14 - Encapsulation
CPP14 - Encapsulation
Michael Heron
 
O6u CS-315A OOP Lecture (1).pdf
O6u CS-315A OOP Lecture (1).pdfO6u CS-315A OOP Lecture (1).pdf
O6u CS-315A OOP Lecture (1).pdf
MohamedRamadan454985
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
Geophery sanga
 
Software Engineering1-1-UML.ppt
Software Engineering1-1-UML.pptSoftware Engineering1-1-UML.ppt
Software Engineering1-1-UML.ppt
naqibullah2022faryab
 
SAD02 - Object Orientation
SAD02 - Object OrientationSAD02 - Object Orientation
SAD02 - Object Orientation
Michael Heron
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
SwatiS-BA
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
SanmatiRM
 
UML Training for Business Analysts
UML Training for Business AnalystsUML Training for Business Analysts
UML Training for Business Analysts
SwatiS-BA
 

Similar to Object oriented programming interview questions (20)

Object Oriented, Design patterns and data modelling worshop
Object Oriented, Design patterns and data modelling worshopObject Oriented, Design patterns and data modelling worshop
Object Oriented, Design patterns and data modelling worshop
 
Concepts of oops
Concepts of oopsConcepts of oops
Concepts of oops
 
Lecture 4-oop class diagram
Lecture 4-oop class diagramLecture 4-oop class diagram
Lecture 4-oop class diagram
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Advanced Programming _Abstract Classes vs Interfaces (Java)
Advanced Programming _Abstract Classes vs Interfaces (Java)Advanced Programming _Abstract Classes vs Interfaces (Java)
Advanced Programming _Abstract Classes vs Interfaces (Java)
 
2CPP05 - Modelling an Object Oriented Program
2CPP05 - Modelling an Object Oriented Program2CPP05 - Modelling an Object Oriented Program
2CPP05 - Modelling an Object Oriented Program
 
Unified Modelling Language
Unified Modelling Language Unified Modelling Language
Unified Modelling Language
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
Problem solving with python programming OOP's Concept
Problem solving with python programming OOP's ConceptProblem solving with python programming OOP's Concept
Problem solving with python programming OOP's Concept
 
oopm 2.pdf
oopm 2.pdfoopm 2.pdf
oopm 2.pdf
 
Introduction to OOA and UML
Introduction to OOA and UMLIntroduction to OOA and UML
Introduction to OOA and UML
 
Introduction to OOA and UML
Introduction to OOA and UMLIntroduction to OOA and UML
Introduction to OOA and UML
 
CPP14 - Encapsulation
CPP14 - EncapsulationCPP14 - Encapsulation
CPP14 - Encapsulation
 
O6u CS-315A OOP Lecture (1).pdf
O6u CS-315A OOP Lecture (1).pdfO6u CS-315A OOP Lecture (1).pdf
O6u CS-315A OOP Lecture (1).pdf
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
 
Software Engineering1-1-UML.ppt
Software Engineering1-1-UML.pptSoftware Engineering1-1-UML.ppt
Software Engineering1-1-UML.ppt
 
SAD02 - Object Orientation
SAD02 - Object OrientationSAD02 - Object Orientation
SAD02 - Object Orientation
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
UML Training for Business Analysts
UML Training for Business AnalystsUML Training for Business Analysts
UML Training for Business Analysts
 

More from Keet Sugathadasa

Chaos Engineering - The Art of Breaking Things in Production
Chaos Engineering - The Art of Breaking Things in ProductionChaos Engineering - The Art of Breaking Things in Production
Chaos Engineering - The Art of Breaking Things in Production
Keet Sugathadasa
 
Site Reliability Engineering (SRE) - Tech Talk by Keet Sugathadasa
Site Reliability Engineering (SRE) - Tech Talk by Keet SugathadasaSite Reliability Engineering (SRE) - Tech Talk by Keet Sugathadasa
Site Reliability Engineering (SRE) - Tech Talk by Keet Sugathadasa
Keet Sugathadasa
 
Human Computer Interaction - Facebook Messenger
Human Computer Interaction - Facebook MessengerHuman Computer Interaction - Facebook Messenger
Human Computer Interaction - Facebook Messenger
Keet Sugathadasa
 
Cyber Security and Cloud Computing
Cyber Security and Cloud ComputingCyber Security and Cloud Computing
Cyber Security and Cloud Computing
Keet Sugathadasa
 
How to compete in hackathons
How to compete in hackathonsHow to compete in hackathons
How to compete in hackathons
Keet Sugathadasa
 
Quality Engineering - When to Stop Testing
Quality Engineering - When to Stop TestingQuality Engineering - When to Stop Testing
Quality Engineering - When to Stop Testing
Keet Sugathadasa
 
Training Report WSO2 internship
Training Report  WSO2 internshipTraining Report  WSO2 internship
Training Report WSO2 internship
Keet Sugathadasa
 
Interview Facing Workshop
Interview Facing WorkshopInterview Facing Workshop
Interview Facing Workshop
Keet Sugathadasa
 
Revolutionizing digital authentication with gsma mobile connect
Revolutionizing digital authentication with gsma mobile connectRevolutionizing digital authentication with gsma mobile connect
Revolutionizing digital authentication with gsma mobile connect
Keet Sugathadasa
 

More from Keet Sugathadasa (9)

Chaos Engineering - The Art of Breaking Things in Production
Chaos Engineering - The Art of Breaking Things in ProductionChaos Engineering - The Art of Breaking Things in Production
Chaos Engineering - The Art of Breaking Things in Production
 
Site Reliability Engineering (SRE) - Tech Talk by Keet Sugathadasa
Site Reliability Engineering (SRE) - Tech Talk by Keet SugathadasaSite Reliability Engineering (SRE) - Tech Talk by Keet Sugathadasa
Site Reliability Engineering (SRE) - Tech Talk by Keet Sugathadasa
 
Human Computer Interaction - Facebook Messenger
Human Computer Interaction - Facebook MessengerHuman Computer Interaction - Facebook Messenger
Human Computer Interaction - Facebook Messenger
 
Cyber Security and Cloud Computing
Cyber Security and Cloud ComputingCyber Security and Cloud Computing
Cyber Security and Cloud Computing
 
How to compete in hackathons
How to compete in hackathonsHow to compete in hackathons
How to compete in hackathons
 
Quality Engineering - When to Stop Testing
Quality Engineering - When to Stop TestingQuality Engineering - When to Stop Testing
Quality Engineering - When to Stop Testing
 
Training Report WSO2 internship
Training Report  WSO2 internshipTraining Report  WSO2 internship
Training Report WSO2 internship
 
Interview Facing Workshop
Interview Facing WorkshopInterview Facing Workshop
Interview Facing Workshop
 
Revolutionizing digital authentication with gsma mobile connect
Revolutionizing digital authentication with gsma mobile connectRevolutionizing digital authentication with gsma mobile connect
Revolutionizing digital authentication with gsma mobile connect
 

Recently uploaded

Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 

Recently uploaded (20)

Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 

Object oriented programming interview questions

  • 1. Object Oriented Programming Interview Preparation Keet Malin Sugathadasa Undergraduate Department of Computer Science and Engineering University of Moratuwa
  • 2. Agenda ● Objects (Instances) ● Classes ● Advantages of OOP ● Disadvantages of OOP ● Let’s Design an OOP Solution ● OOP Concepts ● UML - Unified Modelling Language ● UML Syntax ● Associations ● Inheritance ● Cohesion and Coupling
  • 3. Objects (Instances) An Object can be used to effectively represent real world entities ● Object has ○ States (descriptive characteristics) ■ Simple Attributes- Primitive data types ■ Complex Attributes - Contains collections ○ Behaviours ( what it can do) Example ● Keet’s Bank Account ○ State: Account number, Available balance ○ Behaviour: Make deposits, Withdraw
  • 4. Classes ● An object is defined by a class
  • 5. Advantages of OOP ● Code Reusing and Recycling ○ Saves development time and cost ● Encapsulation ○ Once object is created, knowledge of its implementation is not necessary for use. ● Design Benefits ○ Easy to understand. Large programs get more and more complex, but with OOP, designs can be made with less flaws ● Software Maintenance ○ Programs are not disposable. An OOP is much easier to modify and maintain than a non-OOP
  • 6. Disadvantages of OOP ● Size ○ OOPs are much larger than other programs ● Effort ○ OOPs require a lot of work and planning to develop ● Speed ○ OOPs are slower than other programs (Partially because of their size)
  • 7. Object Oriented Problem Solving Approach 1. Identify the Problem a. Carefully read the given problem and highlight the important points 2. Identify the Objects a. Identify the main objects. Sometime two entities can be selected as one, but sometimes, it might be better to have two instead of one complex one. 3. Identify the messages to be sent to other objects a. Identify what kind of interactions happen between objects in classes 4. Create a sequence of messages to the objects - to solve the problem a. Find a pattern to solve the final problem by interacting with different objects.
  • 8. Let’s Design an OOP Solution You need to create a Wedding Management System. Each wedding has a bride, a groom, flower decorator, food provider, location etc. Each bride and groom has their own parents and friends. Find a way to model this problem into an OOP solution. Just identifying the objects and the required interactions between them is sufficient. Represent the interactions by simple arrows.
  • 10. OOP Concepts ● Abstraction ○ Allows us to consider the important high level details ● Encapsulation ○ Allows us to consider what the program does and how it operates it. Without reading the technical details of how it actually works ● Inheritance ○ Generalization and Specialization. Specialized objects can automatically inherit all the characteristics of the more generalized objects. ● Polymorphism ○ Is the ability to interact with an object as its generalized category, regardless of its more specialized category.
  • 11. UML - Unified Modelling Language ● Class Diagrams ○ Classes show what the objects consists of and the methods ● Object Diagrams ○ Objects in the system and how they interact and the values in that object at a given state in time ● Sequence Diagrams ○ shows object interactions arranged in time sequence. How objects will interact to support one specific function ● Package Diagrams ○ Packages and dependencies between packages
  • 12. Class Consists of ● A unique Name ○ Conventionally starting with an Uppercase Letter ● A list of Attributes (Mostly Private) ○ Int, double, boolean, String, Complex Attributes ● A list of Methods (Mostly Public) ○ Unique method names starting with a Lowercase letter Visibility Modifiers (Access Modifiers) + for public access - for private access UML allows us to suppress any information we do not wish to highlight in our diagrams
  • 13. UML Syntax ● Attributes ○ <visibility> <name> : <type> <multiplicity> ■ Eg: + custRef : int [1] → a public attribute custRef is a single int value ● Methods ○ <visibility> <name> ( <parameter 1> : <type 1> , …….) : <Return Type> ■ Eg: + addName (newName : String) : Boolean
  • 14. Relationships Between Classes ● Some Class attributes can be complex ○ Can include some other class object as attributes ■ Eg: Teacher class has attribute → list of Students ○ String data type is a complex data type ■ Since it is part of the Java platform, it is implied that String is a primitive data type
  • 15. Example ● ‘n’ → exactly n ● ‘*’ → zero or more ● ‘m..n; → between m and n
  • 16. Types of Association ● Dependency A --------------------------> B ● Simple Association A B ● Bidirectional Association A B ● Aggregation A B ● Composition A B
  • 17. Dependency Class A in some way uses facilities defined by Class B. Changes to class B may affect class A. There are 3 ways in which dependencies can occur ● Class A has a method, which passes as a parameter object of Class B ● Class A uses a local variable of Class B ● Class A calls static methods in Class B
  • 18. Simple Association Class A uses objects of Class B. Typically Class A has an attribute of Class B. Navigability is from A to B. ● Class A objects can access Class B objects with which it is associated. ○ The reverse is not true. Eg: Teacher wants to maintain a list of Students. So navigability is from Teacher to Student. So Teacher object can access Student objects. But student objects do not necessarily need access to teacher objects.
  • 19. Bidirectional Association This is when Class A and Class B has a two way association. Each refers to the other class. Navigability is from A to B and B to A. Navigability from A to B means ● Class A object can access Class B objects ● Objects of Class A “Has a” Class A ● This implies reference from A to B Eg: Between a “Degree” and “Student”. Given a degree, we may need to know which students are studying on that degree. Alternatively, given a student, we may wish to know the degree they are studying.
  • 20. Aggregation Aggregation denotes a situation where object(s) of Class B “Belongs to” Class B. Aggregation also mentions that Objects of Class B, retain an existence independent of Class A. Eg: We can think of tyres belonging to a car. Tyres “Belong To” Cars. But if our context relates to a tyre shop or something, then Tyres can exist alone, in a garage as well.
  • 21. Composition ● Composition is similar to aggregation, but implies a much stronger relationship. ● Class B objects are an integral part of Class A. In general, objects of class B never exist other than as part of Class A. Both have the same lifetime. Eg: Between points, lines and shapes as elements of a picture. These objects can only exist as part of a picture, and if the picture is deleted, they are also deleted.
  • 22. Inheritance Class A Class B Class A inherits both implementation and interface of Class B. This is how specialization and generalization works. Specialized classes can inherit from generalized classes.
  • 23. Interfaces Class A Class B ● With interface inheritance, Class A will inherit only the interface of Class B. ● Class B contains only method headers ● Class A has to implement all methods defined in Class B
  • 24. Cohesion ● Cohesion describes how closely all routines in a class or all the code in a routing support a central purpose. ● Cohesion must be Strong. ● Classes must contain a strongly related functionality and aim for single purpose ● Cohesion is an important tool for managing complexities
  • 25. Coupling ● Coupling describes how tightly a class or routine is related to other classes or routines. ● Coupling must be kept Loose. ○ Modules must depend little on each other ○ One module can be replaced easily without causing trouble ○ A module can be easily used by other modules ● Two types of Coupling ○ Tight Coupling ○ Loose Coupling