Q.– Given:
public class Triangle {
static double area;
int b = 2, h = 3;
public static void main(String[ ] args ) {
double p, b, h; // line n1
if (area == 0) {
b = 3;
h = 4;
p = 0.5;
area = p* b* h; // line n2
}
System.out.println("Area is " + area) ;
}
}
What is the result?
A) Compilation fails at line n2.
B) Area is 3.0
C) Area is 6
D) Compilation fails at line n1.
⧪ please give your answer in a comment section.
public class Triangle {
static double area;
int b = 2, h = 3;
public static void main(String[ ] args ) {
double p, b, h; // line n1
if (area == 0) {
b = 3;
h = 4;
p = 0.5;
area = p* b* h; // line n2
}
System.out.println("Area is " + area) ;
}
}
What is the result?
A) Compilation fails at line n2.
B) Area is 3.0
C) Area is 6
D) Compilation fails at line n1.
⧪ please give your answer in a comment section.
4 Comments
d
ReplyDeleteD
ReplyDeleteC
ReplyDeleteC
ReplyDelete