Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Ridhiverma
//JAVA LAB-Q1- Write a Java Program to define a class, describe its constructor, overload the Constructors and instantiate its object //'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { Box mybox1 = new Box(10, 20, 15); Box mybox2 = new Box(); Box mycube = new Box(7); double vol; System.out.println(" AIM : Java Program to define a class, describe its constructor, overload the Constructors and instantiate its object "); System.out.println(" NAME : RIDHI VERMA"); System.out.println(" ROLLNO : 179035"); // get volume of first box vol = mybox1.volume(); System.out.println(" Volume of mybox1 is " + vol); // get volume of second box vol = mybox2.volume(); System.out.println(" Volume of mybox2 is " + vol); // get volume of cube vol = mycube.volume(); System.out.println(" Volume of mycube is " + vol); } } // Java program to illustrate // Constructor Overloading class Box { double width, height, depth; // constructor used when all dimensions // specified Box(double w, double h, double d) { width = w; height = h; depth = d; } // constructor used when no dimensions // specified Box() { width = height = depth = 0; } // constructor used when cube is created Box(double len) { width = height = depth = len; } // compute and return volume double volume() { return width * height * depth; } }
run
|
edit
|
history
|
help
0
Info by dfs
different ways to add parenthesis leetcode #241
WM Test
qwe
Counter.java
Multiples of 3 and 5
pk3
Problem: fb_series
Java Procedural Progamming
"encryption"