0

Why code is not give output ?

public class Box { private int l,b,h; public Box() { l=8;b=4;h=6; } public Box(int L,int B,int H){ l=L;b=B;h=H; } public static void main(String[] args) { Box b1= new Box (); Box b2= new Box (20,4,6); } }

27th Mar 2020, 4:22 PM
samrat kundu
samrat kundu - avatar
6 Answers
+ 3
You need to use the object reference. These are some examples- System.out.println(b1.l); System.out.println(b2.h);
27th Mar 2020, 4:40 PM
Avinesh
Avinesh - avatar
+ 2
samrat kundu where are you printing it to see the output?
27th Mar 2020, 4:29 PM
Avinesh
Avinesh - avatar
27th Mar 2020, 5:54 PM
Muhammad Bilal
Muhammad Bilal - avatar
0
I'm beginners so I don't know properly how print this code. System.out.println(" the output is"+l " " +b " " +h); Is that right ?
27th Mar 2020, 4:34 PM
samrat kundu
samrat kundu - avatar
0
Write the print statement to print output
28th Mar 2020, 2:33 AM
Samavedam Praneeth
Samavedam Praneeth - avatar
0
Thank you 😊 Muhammad Bilal
28th Mar 2020, 5:18 AM
samrat kundu
samrat kundu - avatar