Lesson 2: Object-Oriented Programming
Lesson 2: Object-Oriented Programming
Object-Oriented
Programming
Methods and Attributes
Agenda Constructor
Class Methods and
Variables
Methods are declared within a
Method class, and that they are used to
perform certain actions.
Example:
Static and
construct methods that will exist
regardless of whether or not any
className.methodName();
public class GFG {
// static variable
static int a = 40;
// instance variable
int b = 50;
void simpleDisplay()
{
System.out.println(a);
System.out.println(b);
}
// Declaration of a static method.
static void staticDisplay()
{
System.out.println(a);
}
// main method
public static void main(String[] args)
{
GFG obj = new GFG();
obj.simpleDisplay();