Java Reference
In-Depth Information
Exercises
Visit www.myprogramminglab.com to complete many of these Exercises
online and get instant feedback.
EX 2.1
Explain the following programming statement in terms of objects
and the services they provide:
System.out.println ("I gotta be me!");
EX 2.2
What output is produced by the following code fragment?
Explain.
System.out.print ("Here we go!");
System.out.println ("12345");
System.out.print ("Test this if you are not sure.");
System.out.print ("Another.");
System.out.println ();
System.out.println ("All done.");
EX 2.3
What is wrong with the following program statement? How can
it be fixed?
System.out.println ("To be or not to be, that
is the question.");
EX 2.4
What output is produced by the following statement? Explain.
System.out.println ("50 plus 25 is " + 50 + 25);
EX 2.5
What is the output produced by the following statement?
Explain.
System. o ut.println ("He thrusts his fists\n\tagainst" +
"the po st \nand still insists\n\the sees the \"ghost\"");
EX 2.6
What value is contained in the integer variable size after the fol-
lowing statements are executed?
size = 18;
size = size + 12;
size = size * 2;
size = size / 4;
EX 2.7
What value is contained in the floating point variable depth after
the following statements are executed?
depth = 2.4;
depth = 20 - depth * 4;
depth = depth / 5;
Search WWH ::




Custom Search