Object-Oriented Programming Java Tutorial (Java OOP)

Java is an object oriented language, it creates objects to store information that is related together

Student as an object (written in a class):

Key characteristics (variables):

Name

Age

Operations:

Get Name

Set Name

Get Age Set Age

public class studentMain{
	public static void main(String[]args){
		Student s1 = new Student(); //exactly like the scanner
		Student s2 = new Student(); //each object is one instance of a class
		//Student s1 = declaration
		//s1 points to a whole set of information, name, age, etc

		s1.setName("Alex");
		s2.setName("Jessie"); //two diff students that have the same functions and variables 
		System.out.println(s1.getName() + " + s2.getName());
	}

}

//new file (class)
public class Student{
	private String name; //only this class can see private (instance) variables 
	private int age;
	
	public Student(){ //Constructor should initialize variables 
		name = "";
		age = 0;
	}

	public void setName(String newName){ //Modifier or mutator method
		//code to set the string as a name here
		name = newName;
	}

	public String getName(String name){ //Accessor method
		return name;
	}

}

overloaded constructors & .toString() method

.equals() method

arrays of objects

static variables and methods

fractions assignment