Java Reference
In-Depth Information
5. a. What is the return type of the method main ?
b. What is the return type of the method floor of the class M ath?
c. What is the return type of the method isUpperCase of the class
Character ?
6. What is the output of the following Java program?
import static java.lang.Math.*;
public class Exercise6
{
public static void main(String[] args)
{
for ( int counter = 1; counter <= 100; counter++)
if (pow(floor(sqrt(counter)), 2) == counter)
System.out.print(counter + " ");
System.out.println();
}
}
7. Which of the following method headings are valid? If they are invalid,
explain why.
public static one( int a, int b)
public static int thisone( char x)
public static char another( int a, b)
public static double yetanother
8. Consider the following statements:
double num1, num2, num3;
int int1, int2, int3;
double value;
7
num1 = 5.0; num2 = 6.0; num3 = 3.0;
int1 = 4; int2 = 7; int3 = 8;
and the method heading:
public static double cube( double a, double b, double c)
Which of the following statements are valid? If they are invalid, explain why.
value = cube (num1, 15.0, num3);
a.
System.out.println(cube(num1, num3, num2));
b.
System.out.println(cube(6.0, 8.0, 10.5));
c.
System.out.println(num1 + " " + num3);
d.
System.out.println(cube(num1, num3));
e.
value = cube(num1, int2, num3);
f.
value = cube(7, 8, 9);
g.
Search WWH ::




Custom Search