Java MCQ - English
What is the output of this program?
class average
{
Home | Discussion Forum
{
What is the output of this program?
class average
{
public static void main(String args[])
{
double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
double result;
result = 0;
for (int i = 0; i < 6; ++i)
result = result + num[i];
System.out.print(result/6);
}
}
Answer : C
View More Related Question
1) What is the output of this program?
class area
{
public static void main(String args[])
{
double r, pi, a;
r = 9.8;
pi = 3.14;
a = pi * r * r;
System.out.println(a);
}
}
2) What is the output of this program?
class booloperators
{
public static void main(String args[])
{
boolean var1 = true;
boolean var2 = false;
System.out.println((var2 & var2));
}
}
3) What will the output of the following program?
public class Test{
public static void main(String args[])
{
float f = (1 / 4) * 10;
int i = Math.round(f);
System.out.println(i);
}
}
4) Determine output:
public class Test{
int i = 34;
public static void main(String args[])
{
Test t1 = new Test();
Test t2 = new Test();
t1.i = 65;
System.out.print(t1.i);
System.out.print(t2.i);
}
}
5) What is the output of this program?
class increment
{
public static void main(String args[])
{
double var1 = 1 + 5;
double var2 = var1 / 4;
int var3 = 1 + 5;
int var4 = var3 / 4;
System.out.print(var2 + " " + var4);
}
}