Object-Oriented Java
Learn about object-oriented programming in Java. Explore syntax for defining classes and creating instances.
StartKey Concepts
Review core concepts you need to learn to master this subject
Java objects’ state and behavior
Java instance
Java dot notation
Constructor Method in Java.
Creating a new Class instance in Java
Reference Data Types
Constructor Signatures
null Values
Java objects’ state and behavior
Java objects’ state and behavior
public class Person {
// state of an object
int age;
String name;
// behavior of an object
public void set_value() {
age = 20;
name = "Robin";
}
public void get_value() {
System.out.println("Age is " + age);
System.out.println("Name is " + name);
}
// main method
public static void main(String [] args) {
// creates a new Person object
Person p = new Person();
// changes state through behavior
p.set_value();
}
}
In Java, instances of a class are known as objects. Every object has state and behavior in the form of instance fields and methods respectively.
What you'll create
Portfolio projects that showcase your new skills
A Basic Calculator
It's time to build fluency in Object Oriented Java. In this next Pro Project, we're going to practice Classes, Methods, Objects in Java so you can hone your skills and feel confident taking them to the real world. Why? It's vital that you get comfortable creating classes and writing methods that perform various operations. What's next? Arithmetic operations, divisibility rules, Java methods. You got this!
Build A Droid
Practice object-oriented Java by creating a `Droid` class and creating different instances of Droid. Droids are robots built to perform tasks. A droid can be built for any task so it's the perfect candidate for a Java class!
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory