Inteview - Java Oop

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

What is Object oriented

programming?
is a programming
paradigm that focuses on
using objects to design and
build application.
What is a class?
it is a template of an
object. For example, a class
called animal would give a
blueprint for what an animal
looks like and what an animal
can do.
What is an object?
It is an entity that has
state and behaviour. A state is
the data of an object. The
behaviour is the functionality
of the object
A simple example of an
object would be a Person. A
person has a name, colour or
breed. And their behaviour is
walking.
What is a method?
a method is a set of
statements to perform a task.
What is Method
Overloading?
it is a class that have
multiple method that has the
same name but different
arguments.
What is a constructor?
a special method that is
used to initialized an object.
If we dont declare a
constructor in java, the
compiler builds a default
constructors for that class.
It doesnt have a return
type, and it must have the
same name as the class with
or without parameter.
What is static keyword?
it can call a method or a
variable even though you
didnt instantiate In main
method.
What is this keyword?
it works as a reference to
the current object whose
method is being invoke
What is inheritance?
process of obtaining data
members and methods of one
class to another class.
It represents IS-A
relationship, also known as
parent-child.
In java, the class that is
inherited is called the super
class. And the new class is
called subclass
What is aggregation?
it contains to have
ownership of that class.
It represents HAS-A
relationship

What is Method
Overriding?
it provides
implementation of a method
that is already provided in
super class.
What is super keyword?
refers to the immediate
parent class object.
What is final keyword?
it is used to restrict the
user. It can be applied in
variables and also methods
but you cannot override it.
What is polymorphism?
it is the ability of an
object than can take many
forms. There are 2 types of
polymorphism
Run time is done using
inheritance and interfaces
Compile time is done
using method overloading
What is abstraction?
process of hiding the
zimplementation details and
showing only the functionality
to the user.
In other words user will
have the information on what
the object does instead of how
it does it.
What is encapsulation?
process of wrapping
code and data in a single
unit.
Use
setters and getters
method to modify and
view the variables
What is an interface?
it is a blueprint of class
that have static constants and
abstract methods.
What is a package?
it is a namespace that
organizes a set of related
classes or interfaces.

HOW TO DECLARE A
CLASS:
You declare a class by
specifying class keyword
followed the class name that
you want.
HOW TO CREATE AN
OBJECT:
You can create an object
using new keyword.
For example, Person p1
= new Person(); , the person

is the name of the class and


the p1 is the variable name of
the object.
HOW TO CREATE METHOD:
A method needs to
define within the class.
Using the public
keyword and the return type
of the method and the
method name

Does constructor return


any value?
yes, that is current instance
(You cannot use return type
yet it returns a value)
Is constructor inherited?
No, constructor is not
inherited.
Can you make a
constructor final?
No, constructor can't be final.
What is static variable?
static variable is used to refer
the common property of all
objects
What is static method?
A static method belongs to
the class rather than object of
a class.
Difference between method
Overloading and Overriding.
method overloading is occurs
within the class.
Method overriding occurs in
two classes that have IS-A
relationship.
Difference between
abstraction and
encapsulation?
Abstraction focuses on the
outside view of object (i.e.
interface) whereas
encapsulation prevents client
seeing its inside view.
What is abstract class?
A class that is declared as
abstract is known as abstract
class. It needs to be extended
and its method implemented.
It cannot be instantiated.
What is difference between
abstract class and interface?
You can extends one abstract
class.
You can implement interfaces.
What is exception
handling?
Is to handle runtime errors.

CONCRETE METHOD:
ABSTRACT METHOD:
abstract void eat()
Abstract methods are
those who need to
implemented in subclass.
They are only defined in super
class but with no body.

Controller controls the data


flow of model and updates the
view whenever the data
changes.

WHAT IS DESIGN
PATTERN?
Solution to general problems
that software developers faced during
software development

Factory Design
Pattern
It allows you to create
objects without specifying the
exact class of object that will
be created.
For example you need to
create an interface
second is create a class
that will implement the
interface
third Is to create a
factory to generate object of
concrete class.
Lastly, use the factory to
get the object of concrete
class

MVC DESIGN
PATTERN
MVC stands for model view
controller pattern.
Model represents the POJO.
And also it contains the
business logic.
View represents the
visualization of the data

POINT OF SALE
SYSTEM

You might also like