<< Chapter < Page | Chapter >> Page > |
What output is produced by the program shown in Listing 11 ?
Listing 11 . Listing for Question 11. |
---|
public class Ap035{
public static void main(String args[]){new Worker().doLoop();
}//end main()}//end class definition
class Worker{public void doLoop(){
int cnt = 0;while(cnt<5){
cnt++;System.out.print(cnt + " ");
cnt++;}//end while loop
System.out.println("");}//end doLoop()
}//end class definition |
What output is produced by the program shown in Listing 12 ?
Listing 12 . Listing for Question 12. |
---|
public class Ap036{
public static void main(String args[]){new Worker().doLoop();
}//end main()}//end class definition
class Worker{public void doLoop(){
int cnt;for(cnt = 0; cnt<5; cnt++){
System.out.print(cnt + " ");}//end for loop
System.out.println(cnt + " ");}//end doLoop()
}//end class definition |
What output is produced by the program shown in Listing 13 ?
Listing 13 . Listing for Question 13. |
---|
public class Ap037{
public static void main(String args[]){new Worker().doLoop();
}//end main()}//end class definition
class Worker{public void doLoop(){
for(int cnt = 0; cnt<5; cnt++){
System.out.print(cnt + " ");}//end for loop
System.out.println(cnt + " ");}//end doLoop()
}//end class definition |
What output is produced by the program shown in Listing 14 ?
Listing 14 . Listing for Question 14. |
---|
public class Ap037{
public static void main(String args[]){new Worker().doLoop();
}//end main()}//end class definition
class Worker{public double doLoop(){
for(int cnt = 0; cnt<5; cnt++){
System.out.print(cnt + " ");if(cnt == 3){
System.out.println(cnt);return cnt;
}//end if}//end for loop
//return 3.5;}//end doLoop()
}//end class definition |
What output is produced by the program shown in Listing 15 ?
Listing 15 . Listing for Question 15. |
---|
public class Ap038{
public static void main(String args[]){new Worker().doLoop();
}//end main()}//end class definition
class Worker{public void doLoop(){
for(int cnt = 0; cnt<5; cnt++){
System.out.print(cnt + " ");if(cnt == 3){
System.out.println(cnt);return;
}//end if}//end for loop
}//end doLoop()}//end class definition |
I recommend that you open another copy of this document in a separate browser window and use the following links to easilyfind and view the listings while you are reading about them.
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?