class Box { double length; double width; double height; Box (double l, double w, double h) { length = l; width = w; height = h; } double calculateVolume() { return(length * width * height); } //Define method with object Box as parameter boolean isSame(Box k) { if ((k.length == this .length) && (k.width == this.width) && (k height == this.height)) { return true; } else { return false; } } } class DemoParamObject { public void main(String [] args) { Box b1, b2, b3, b4; b1 = new Box(4, 3, 2); b2 = new Box(6, 5, 4); b3 = new Box(4, 3, 2); b4 = new Box(6, 5, 4); System.out.println ("b1 == b2 : " + b1.isSame(b2)); System.out.println ("b1 == b3 : " + b1.isSame(b3)); System.out.println ("b2 == b4 : " + b2.isSame(b4)); } }
The result will be given by the above program as follows:
b1 == b2: false
b1 == b3: true
b2 == b4: true
Method isSame() that you see above has box object as parameter. Please also be noted how to call:
b1.isSame(b2)
The above code is used to check whether the object b1 and b2 is equal to or not. If the value of both object is same, the method will return true. Otherwise, the value to be returned is false.
Thank you so much for the valuable info
ReplyDeleteHere am sharing some information about Best Training Institutes java training in hyderabad |java course in hyderabad | java institutes in hyderabad | software training institutes in hyderabad |selenium training in hyderabad | software training institutes in hyderabad with placements |python training in hyderabad | python course in hyderabad | python institutes in hyderabad
Thank You for Sharing valuable information with us.
ReplyDeleteE-Commerce is the fastest-growing platform which is becoming more demandable day by day this is a tremendous form of the vibrant sector that is bringing several opportunities to the new generation to become more skilled and professional. Taking up this great advantage in the E-Commerce sector would need the right path and the right skillset you need to learn the latest technologies and high-demand skills such as building payment gateways and developing an accessible and easy website along with the basics of E-commerce that‘s why Aptech learning official Pro E-Commerce training program in Dwarka, Janakpuri, and Gurgaon which will help to make a successful career in this booming industry. Java Programming Course helps to become an expert in Java web application development. It helps you to bring efficiency in collecting and analyzing the data through Java programming in this course you will learn effective web UI/UX design and Secure web applications by using the advanced technologies of the Java program.
For more details please visit our website : Aptech Dwarka