Java
Programming and Technical
Programming
Program
What is the output of this program?
class area {
public static void main(String args[])
{
double r, pi, a;
r = 9.8;
p1 = 3.14;
a = pi * r * r;
System.out.println(a);
}
}
a) 301.5656
b) 301
c) 301.56
d) 301.56560000
Read Solution (Total 41)
-
- a)301.5656
In java it will only print 301.5656.
because in java double will only print upto it finds zero after decimal
Try it yourself on java compiler - 10 years agoHelpfull: Yes(29) No(1)
- compilation error. cause pi value not specified instead of p1 specified . otherwise it will be 301.5656
- 10 years agoHelpfull: Yes(10) No(0)
- d)301.56560000
since double value gives ans. in 8 places after decimal - 11 years agoHelpfull: Yes(6) No(5)
- d)301.56560000
- 10 years agoHelpfull: Yes(2) No(5)
- a=pi*r*r, pi=3.14 , r=9.8 then a=3.14*9.8*9.8 a=301.5656
- 10 years agoHelpfull: Yes(2) No(1)
- d)301.56560000
- 10 years agoHelpfull: Yes(2) No(1)
- a)301.5656
and the program having error p1 is not defined so correct it to pi. - 10 years agoHelpfull: Yes(1) No(1)
- d
because it is defined that a is double. and double value having 8 places after decimal. - 9 years agoHelpfull: Yes(1) No(0)
- a)301.5656
- 10 years agoHelpfull: Yes(0) No(0)
- Since the datatype is double...answer is 301.5656
- 10 years agoHelpfull: Yes(0) No(0)
- a.
pi*r*r=a is nothing but the values given by the programmer to calculate
i.e,. 3.14*9.8*9.8=301.5656 - 10 years agoHelpfull: Yes(0) No(0)
- 301.5656 simply putting the values in formula.
- 10 years agoHelpfull: Yes(0) No(0)
- the answer for sure is A
- 10 years agoHelpfull: Yes(0) No(0)
- answer is (d) because of double numeric data type
- 10 years agoHelpfull: Yes(0) No(0)
- answer is a
- 10 years agoHelpfull: Yes(0) No(0)
- ans a) 301.5656
- 10 years agoHelpfull: Yes(0) No(0)
- it can not be executed.if we use static block then it will compile but it can not be executed.
- 10 years agoHelpfull: Yes(0) No(0)
- a 301.5656
- 10 years agoHelpfull: Yes(0) No(0)
- a) 301.5656
- 10 years agoHelpfull: Yes(0) No(0)
- a option is the answer.
to submit the values and simplyfy that...
u can get the value is 301.5656
a=3.14*9.8*9.8
=301.5656 - 9 years agoHelpfull: Yes(0) No(0)
- Option A is right because 9.8*9.8*3.14=301.5656 i.e :after . there are four digits so after four digits(from left ) . is placed
- 9 years agoHelpfull: Yes(0) No(0)
- compile error because p1 is undefined
- 9 years agoHelpfull: Yes(0) No(0)
- a)301.5656
- 9 years agoHelpfull: Yes(0) No(0)
E:>javac area.java
E:>java area
301.5656- 9 years agoHelpfull: Yes(0) No(0)
- A)301.5656
Pi*r*r - 9 years agoHelpfull: Yes(0) No(0)
- 301.5656. It will calculate a. As given a= pi*r*r. and the value of pi is 3.14.the answer will be 3.14 *9.8*9.8
- 9 years agoHelpfull: Yes(0) No(0)
- a)301.5656
- 8 years agoHelpfull: Yes(0) No(0)
- a 301.5656
- 8 years agoHelpfull: Yes(0) No(0)
- a because on execution of loop it yields the value 301.5656
- 8 years agoHelpfull: Yes(0) No(0)
- Ans = 301.5656
- 8 years agoHelpfull: Yes(0) No(0)
- error
there is no value(pi)
- 8 years agoHelpfull: Yes(0) No(0)
- a)301.5656
In java it will only print 301.5656.
because in java double will only print upto it finds zero after decimal
Try it yourself on java compiler - 6 years agoHelpfull: Yes(0) No(1)
- answer :a
301.5656 - 5 years agoHelpfull: Yes(0) No(0)
- option a is correct
a=3.14*9.8*9.8
a=3.14*96.04
a=301.5656 - 5 years agoHelpfull: Yes(0) No(0)
- 301.5656
3.14*96.04 - 5 years agoHelpfull: Yes(0) No(0)
- d will be answer
- 4 years agoHelpfull: Yes(0) No(0)
- 3.14 x 9.9 x 9.8 = 301.5656
- 4 years agoHelpfull: Yes(0) No(0)
- r = 9.8 * 9.8 = 96.04.
pi = 3.14
a = 96.04 * 3.14
a = 301.5656 - 4 years agoHelpfull: Yes(0) No(0)
- a) 301.5656
- 3 years agoHelpfull: Yes(0) No(0)
- It will give error why because here pi was not initialized.
- 3 years agoHelpfull: Yes(0) No(0)
- Answer is a
- 1 year agoHelpfull: Yes(0) No(0)
Java Other Question