Journey to Java: Episode 6 “Intro to Object-Oriented Programming”

  • OOP is faster and easier to execute
  • OOP provides a clear structure for the programs
  • OOP helps to keep the Java code DRY “Don’t Repeat Yourself”, and makes the code easier to maintain, modify and debug
  • OOP makes it possible to create full reusable applications with less code and shorter development time
public class Car {}
public class Car {
private String make;
private String model;
private String color;
}
public class Main {
public static void main(String[] args){
Car ford; = new Car();
Car chevy; = new Car();
}}
public class Car {
private String make;
private String model;
private String color;
public void setMake(String make) {
this.make = make;
}}
public class Main {
public static void main(String[] args){
Car ford; = new Car();
Car chevy; = new Car();
ford.setMake("Ford");}}
public class Main {
public static void main(String[] args){
Car ford; = new Car();
Car chevy; = new Car();
ford.setMake("Ford");
ford.setModel("Mustang");
ford.setColor("Silver");
}}public class Car {
private String make;
private String model;
private String color;
public void setMake(String make) {
this.make = make;
}
public void setModel(String model) {
this.model = model;
}
public void setColor(String color) {
this.color = color;
}
}
public class Car {
private String make;
private String model;
private String color;
public void setMake(String make) {
this.make = make;
}
public void setModel(String model) {
this.model = model;
}
public void setColor(String color) {
this.color = color;
}
Public String getMake() {
return this.make
}
}
public class Main {
public static void main(String[] args){
Car ford; = new Car();
Car chevy; = new Car();
ford.setMake("Ford");
ford.setModel("Mustang");
ford.setColor("Silver");

System.out.println("make is " + ford.getMake());
}}
  • What is OOP?
  • What is a class?
  • What is an object?
  • How to create a class.
  • How to create an object.
  • How to create fields.
  • How to create class methods.
  • How to set with setter methods.
  • How to get with getter methods.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store