CICD
CICD
Any thing of real life about which we can stored data can be an object.
Almost any noun can be reasonably represented as a software object in
terms of:
◦ Attributes (e.g., name, color and size) and
◦ Behaviors (e.g., calculating, moving and communicating).
Class is nothing but a collection of object of similar type for example class of object
in which each student is an object.
You need to know how to handle and manage classes
The instance of a class is called object
Each class can have different instance variables and methods (Functions)
Instantiation:
◦ Building a car using the blueprint design
◦ Then we can make use of the behaviors etc.
SETTER AND GETTER METHODS
Using test class we can create objects of class Account and to access the
methods of the class.
The class Account does not have main method, hence, it will not get
executed directly unless called by another class
AccountTest class orders the Account class of what to do!
CLASS ACCOUNTTEST
PRIMITIVE TYPES VS REFERENCE TYPES
The constructor is called each time you are creating object so this is the ideal
point to initialize an object’s instance variables.
Constructor should have the same name as the class! (important)
GRAPHICAL BOXES FOR INPUT
CODE
METHODS STRUCTURE
STATIC METHODS
ClassName.methodName(arguments)
Math.sqrt(900)
Static variables
static int a=8;
CALLING METHODS
If the method is providing an output, you should define a return type, while
defining the method.
Example:
public int add(int a, int b){
◦ return a+b;
◦ }
Java contains many predefined classes that are grouped into categories of related
classes called packages.
Together, these are known as the Java Application Programming Interface (Java API),
java.util;
javax.swing;
java.io
Etc.
VARIABLE SCOPE
◦ Class Scope
◦ Method Scope
◦ Loop Scope
CLASS SCOPE
Each variable declared inside of a class's brackets ( {} ) with private access modifier
but outside of any method, has class scope.
As a result, these variables can be used everywhere in the class, but not
outside of it:
We can provide block of code in our program, in which the variables will be
accessible within the block only.