<< Chapter < Page | Chapter >> Page > |
What output is produced by the program shown in Listing 6 ?
Listing 6 . Listing for Question 6. |
---|
public class Ap044{
public static void main(String args[]){new Worker().doCast();
}//end main()}//end class definition
class Worker{public void doCast(){
double w = 3.5;double x = -3.499999999999;
System.out.println(doIt(w) +" " +
doIt(x));}//end doCast()private int doIt(double arg){
if(arg>0){
return (int)(arg + 0.5);}else{
return (int)(arg - 0.5);}//end else
}//end doIt()}//end class definition |
What output is produced by the program shown in Listing 7 ?
Listing 7 . Listing for Question 7. |
---|
public class Ap045{
public static void main(String args[]){new Worker().doConcat();
}//end main()}//end class definition
class Worker{public void doConcat(){
double w = 3.5;int x = 9;
boolean y = true;String z = w + "/" + x + "/" + y;
System.out.println(z);}//end doConcat()
}// end class |
Which of the following best approximates the output from the program shown in Listing 8 ?
Listing 8 . Listing for Question 8. |
---|
public class Ap046{
public static void main(String args[]){new Worker().doConcat();
}//end main()}//end class definition
class Worker{public void doConcat(){
Dummy y = new Dummy();System.out.println(y);
}//end doConcat()}// end class
class Dummy{private String name = "Joe";
private int age = 35;private double weight = 162.5;
}//end class dummy |
Which of the following best approximates the output from the program shown in Listing 9 ?
Listing 9 . Listing for Question 9. |
---|
public class Ap047{
public static void main(String args[]){new Worker().doConcat();
}//end main()}//end class definition
class Worker{public void doConcat(){
Dummy y = new Dummy();System.out.println(y);
}//end doConcat()}// end class
class Dummy{private String name = "Joe";
private int age = 35;private double weight = 162.5;public String toString(){
String x = name + " " +" Age = " + age + " " +
" Weight = " + weight;return x;
}}//end class dummy |
Which of the following best approximates the output from the program shown in Listing 10 ? (Note the use of the constructor for the Date class that takes no parameters.)
Listing 10 . Listing for Question 10. |
---|
import java.util.*;
public class Ap048{public static void main(
String args[]){
new Worker().doConcat();}//end main()
}//end class definitionclass Worker{
public void doConcat(){Date w = new Date();
String y = w.toString();System.out.print(y);
System.out.println(" " + w.getTime());}//end doConcat()
}// end class |
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?