
44.141 Exercise12
1. Examine the Driver class listed below, the main method and the methods ( method1(), method2(),
method3(), method4(), method5() ) listed inside the Driver class. Using the variables declared in
the main method, write in the space provided how one should call each of the static methods from
inside the main method.
public class Driver
{
public static void main(String [] args)
{
int intNumber;
String message;
double doubleValue = 11.5;
//Call method1
method1();
//Call method2
intNumber = method2();
//Call method3
method3( intNumber);
//Call method4
message = method4(doubleValue);
//Call method5
doubleValue = method5(intNumber);
}
public static void method1()
{
System.out.println( "Hello from method 1" );
}
public static int method2()
{
return 10;
}
public static void method3(int number)
{
System.out.println( "This is my number " + number );
}
public static String method4(double number)
{
String message = "This is my number returned as part of a string "
+ number;
return message;
}