Advertisement
fozlerabbi2

Method in Java OOP Lab

Feb 26th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. package method;
  2.  
  3. public class Method {
  4.     public static void main(String[] args) {
  5.         Rectangle obj = new Rectangle();
  6.        
  7.         obj.test(10,5,2);
  8.         obj.test(10, 5);
  9.         obj.test();
  10.     }
  11.    
  12. }
  13.  
  14. class Rectangle{
  15.     double width;
  16.     double length;
  17.     double height;
  18.     void test(double length, double width, double height){
  19.         System.out.println(height*length*width);
  20.     }
  21.     void test(double length, double width){
  22.         System.out.println(length*width);
  23.     }
  24.     void test(){
  25.         System.out.println("Hello Fozle!");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement