Session03-Classes and Objects
Session03-Classes and Objects
(http://docs.oracle.com/javase/tutorial/java/javaOO/index.html)
Attribute, Field
Action, Behaviour
4 class types:
- Entity class
- Library class
- Controller class
- Boundary class
Session 02 - Learning the Java
Language
Declaring Classes
• Syntax to define a class
[public] class MyClass [extends MySuperClass implements
YourInterface]{
//field declarations
//method definitions
}
Methods
accountNumber()
22 of 30
Encapsulation: Access Modifiers
• The first (left-most) modifier used lets you
control what other classes have access to a
member field.
– public modifier—the field is accessible from all
classes.
– private modifier—the field is accessible only within
its own class.
Out of scope
or
Assign to null
Session 03 - Classes and Objects
Summary
• The key object-oriented programming
concepts: encapsulation, inheritance and
polymorphism
• The anatomy of a class, and how to declare
fields, methods, and constructors.
• Creating and using objects.
• How to instantiate an object, and, once
instantiated, how to use the dot operator to
access the object's instance variables and
methods. Session 03 - Classes and Objects