Vous êtes sur la page 1sur 7

Oop

object oriented programing.


Referes to Programing methodology based on object. OOPL
incorporates logical classes, objects, methods, relationships and
other processes with the design of software and applications.
Object
Real time entity. object refers to a particular instance of a class
where the object can be a combination of variables, functions,
and data structures.
-state values of variable
-behaviour method.
Class : class is a blueprint or prototype from which objects are
created. It is a user define data structure.
Instance :

instance means just creating a reference

Abstraction : is a process of hiding the implementation details and


showing only functionality to the user.
Abstraction refers to the act of representing essential features
without including the background details or explanations.

Encapsulation : wrapping data and function into single unit


called and keeps both safe from outside interference and
misuse. In short, it isolates a particular code and data from all
other codes and data.
We can create fully encapsulated class by making the entire data
member will be private and create getter, setter method to
access that data member.
Polymorphism : polymorphism allows you define one form/interface
and have multiple implementations.we can achive this by 2
mechanism

1)Method Overloading. : If a class have multiple methods by same name but different
parameters, it is known as Method Overloading.(static binding,early
binding,compiletime polymorphism)
1. By changing number of arguments
2. By changing the data type
3. Not possible by changing return type.
2)Method

overriding : Declaring a method in subclass which is already present in

parent class is known asmethod overriding.


o

Method overriding is used to provide specific implementation of a method that is


already provided by its super class.

The main advantage of method overriding is that the class can give its own specific
implementation to a inherited method without even modifying the parent class(base class)

Inheritance :It is the process by which one object acquires the


properties of another object. This supports the hierarchical
classification.
Why use interface?
- It is use to achieve fully abstraction.
- By using interface we achieve multiple inheritances.
Concrete class : A class is called concrete if it does not contain
any abstract method and implements all abstract method
inherited from abstract class or interface it has implemented or
extended.
Constructor :

A constructor is a bit of code that allows you to create objects from

a class.
No return type no modifiers.
No abstract,native,final.
A constructor is an instance method that usually has the same name as the class, and can be used
to set the values of the members of an object, either to default or to user-defined values.

Spring framework :

The Spring Framework is an application framework and inversion of


control container for the Java platform.

Thread : A thread is a single sequential flow of control within a


program (i.e., process). Threads are a way for a process to split
itself into multiple simultaneously running tasks.
Threads are lightweight processes.
Multithreading : refers to two or more tasks executing concurrently within a single program.
A thread is an independent path of execution within a program. Many threads can run
concurrently within a program. Everythread in Java is created and controlled by
the java.lang.Thread class.
multitasking : is when multiple processes share common processing resources such as a CPU.

Inheritance : Programming lang. feature that gives the ability to


link togather 2 designs with is-a relationship.
Inheritance is a mechanism wherein a new class is derived from an existing class
Java does not support multiple inheritance
Type : single,multiple.
Inheritance of Classes Multilevel
Inheritance of Interfaces Multiple,Multilevel.

Abstraction
Abstraction refers to the act of representing essential features
without including the background details or explanations. Classes
use the concept of abstraction and are defined as a list of abstract
attributes.
Abstract class is a class that is declared abstractit may or may not include abstract
methods. Abstract classes cannot be instantiated, but they can be subclassed.
Abstract method is a method that is declared without an implementation (without
braces, and followed by a semicolon), like this:
abstract void moveTo(double deltaX, double deltaY);
An abstract method is a method that is declared without an implementation.It just has a
method signature

->if one of method of a class is abstract then we have to mark


that class as a abstract.
-> abstract class cant be marked as final.
->AC have constructor and state.
Package : Grouping of releated classes. Or access specifier.
-> only same package members can access.
Protected : classes that belongs to same package + sub
classes & have package scope also.
Interface :

An interface in Java is similar to a class, but the body of an interfacecan


include only abstract methods and final fields (constants). A class implements an interface by
providing code for each method declared by the interface.
The class that implements interface must implement all the methods of that interface. Also,
java programming language does not support multiple inheritance, using interfaces we can
achieve this as a class can implement more than one interfaces, however it cannot extend
more than one classes.

abstract Classes

Interfaces

abstract class can extend only one class or one abstract class at a

interface can extend any n

time

interfaces at a time

abstract class can extend from a class or from an abstract class

interface can extend only f

abstract class can have both abstract and concrete methods

interface can have only ab

A class can extend only one abstract class

5
6
7

A class can implement any


interfaces

In abstract class keyword abstract is mandatory to declare a

In an interface keyword ab

method as an abstract

to declare a method as an a

abstract class can have protected , public and public abstract

Interface can have only pub

methods

methods i.e. by default

abstract class can have static, final or static final variable with

interface can have only st

any access specifier

(constant) variable i.e. by d

Abstract Class vs. Interface


Java provides and supports the creation of abstract classes and interfaces. Both
implementations share some common features, but they differ in the following
features:

All methods in an interface are implicitly abstract. On the other hand, an


abstract class may contain both abstract and non-abstract methods.

A class may implement a number of Interfaces, but can extend only one
abstract class.

In order for a class to implement an interface, it must implement all its


declared methods. However, a class may not implement all declared methods
of an abstract class. Though, in this case, the sub-class must also be declared
as abstract.

Abstract classes can implement interfaces without even providing the


implementation of interface methods.

Variables declared in a Java interface is by default final. An abstract class


may contain non-final variables.

Members of a Java interface are public by default. A member of an


abstract class can either be private, protected or public.

An interface is absolutely abstract and cannot be instantiated. An abstract


class also cannot be instantiated, but can be invoked if it contains a main
method.

Exception : an exception is an event, which occurs during the


execution of a program, that interrupts the normal flow of the
program. It is an error thrown by a class or method reporting an
error in code.
-Checked exceptions (compile time) are the one which forces the programmer to
handle it, without which the program doesnt compile successfully.

conditions that are out of the control of the program (for


example, I/O errors)

FileNotFoundException
ParseException
ClassNotFoundException
CloneNotSupportedException
InstantiationException
InterruptedException
NoSuchMethodException
NoSuchFieldException

-- unchecked exception (Runtime) : doesnt get checked during compilation. Throws


keyword is mainly used for handling checked exception as using throws we can declare
multiple exceptions in one go.

occurred during runtime and used to indicate


programming errors (for example, a null pointer).
the occurrences of which are not checked by the compiler. They will come
into life/occur into your program, once any buggy code is executed. Unchecked
exceptions are usually result of bad code in your system. A method is not
forced by compiler to declare the unchecked exceptions thrown by its
implementation and methods almost always do not declare them.
ArrayStoreException
ClassCastException
IllegalArgumentException
IndexOutOfBoundsException
NullPointerException

BufferOverflowException
BufferUnderflowException
CMMException
ConcurrentModificationException
DOMException
EmptyStackException
IllegalMonitorStateException
IllegalPathStateException
IllegalStateException
ImagingOpException
MissingResourceException
NegativeArraySizeException
NoSuchElementException
ProfileDataException
ProviderException
RasterFormatException
SecurityException

SystemException
UndeclaredThrowableException
UnmodifiableSetException
UnsupportedOperationException

Thread : Thread is a concurrent unit of execution. Or in other words you can say that it is
part of process that can run concurrently with other parts of the process.

The process of executing multiple threads simultaneously is known as multithreading.


Java supports multithreading. The main advantage of multithreading is reducing CPU
idle time and improving the CPU utilization. This makes the job to be completed in
less time.
Daemon thread is a low priority thread (in context of JVM) that runs in background to
perform tasks such as garbage collection (gc) etc., they do not prevent the JVM from exiting
(even if the daemon thread itself is running) when all the user threads (non-daemon threads)
finish their execution. JVM terminates itself when all user threads (non-daemon threads)
finish their execution, JVM does not care whether Daemon thread is running or not, if JVM
finds running daemon thread (upon completion of user threads), it terminates the thread and
after that shutdown itself.

Vous aimerez peut-être aussi