1. Classes & Objects: Classes, objects and methods: defining a
class, Access Control, Method overloading, constructors,
constructor overloading, use of this and static. Practice
Problems
2. Classes in Java
• The class is at the core of Java.
• It is the logical construct upon which the entire Java language is built
because it defines the shape and nature of an object.
• As such, the class forms the basis for object-oriented programming in
Java.
• Any concept you wish to implement in a Java program must be
encapsulated within a class
• a class defines a new data type.
• Once defined, this new type can be used to create objects of that
type.
• Thus, a class is a template for an object, and an object is an instance
of a class
3. The General Form of a Class
A class is declared by use of the class keyword.
Syntax
access_modifier class<class_name>
{
data member;
method;
constructor;
nested class;
interface;
}
4.
5. • The access modifiers are listed according to their restrictiveness
order.
1) private (accessible within the class where defined)
2) default or package-private (when no access modifier is
specified)
3) protected (accessible only to classes that subclass your class
directly within the current or different package)
4) public (accessible from any class)