Answers for "OOP in java explain"

2

java oop

public class YourClass {
  String example;
  int test;
  
  // Constructor
  public YourClass(String example, int test) {
    this.example = example;
    this.test = test;
  }
  
  // Method
  public void someMethod() {
    System.out.println(example); 
  }
}

// Usage:
// Construct
YourClass exampleObject = new YourClass("Hello World!", 5);
// Execute Method:
exampleObject.someMethod();
Posted by: Guest on May-07-2021
2

java oop

public class YourClass {
  String example;
  int test;
  
  // Constructor
  public YourClass(String example, int test) {
    this.example = example;
    this.test = test;
  }
  
  // Method
  public void someMethod() {
    System.out.println(example); 
  }
}

// Usage:
// Construct
YourClass exampleObject = new YourClass("Hello World!", 5);
// Execute Method:
exampleObject.someMethod();
Posted by: Guest on May-07-2021

Browse Popular Code Answers by Language