You are on page 1of 11

OOP review

part one
Grade 2
Contents …

 Class
 Static
 Non- static
 Constructor
 Default constructor
 Constructor overload
 Constructor override
 Object
Class

 A Java class file is a file containing Java bytecode that can be executed on the
Java Virtual Machine
 Examples
Access-modifier class name {

}
Static

 the particular member belongs to a type itself, rather than to an instance of


that type
 It is not necessary to create an object to use this variable
 And even if you create object of it or multiple objects of it the result will be
same value for all of them
 Example
 Static int a=1;
Non-static

 Non-static methods are those that do not have the static keyword before the method
name. Like non-static variables,
 non-static methods also should be call only using object.
 Example
 Int a=0;

 “by default members are non-static”


Constructor

 Specific type of method that used to create objects.


 Every java class has a constructor
 Example
 Access-modifier class-name()

 “By default it is public”


Default constructor

 A default constructor is a constructor created by the compiler if we do not define any


constructor(s) for a class.
 Default constructors are empty
Class name()
{

}
Constructor override

 Creating empty constructors in java by programmer is going to override the


default constructor
Constructor overload

 Constructor overloading in Java refers to the use of more than one constructor in an
instance class.
Object

 object is an instance of a Java class, meaning it is a copy of a specific class.


 Example
 Class-name any-name = new class-name();
Next week content

 Encapsulation
 Inheritance
 Polymorphism
 Abstraction

You might also like