Inside Collection (Course): Object-Oriented Programming (OOP) with Java
Summary: This module contains review questions and answers keyed to the module titled Jb0190: Java OOP: Using the System and PrintStream Classes
This module contains review questions and answers keyed to the module titled Jb0190: Java OOP: Using the System and PrintStream Classes .
The questions and the answers are connected by hyperlinks to make it easy for you to navigate from the question to the answer and back again.
True or false? The main method in the controlling class of a Java application controls the flow of the program.
True or false? The main method cannot access the variables and methods of objects instantiated from other classes.
True or false? The main method must instantiate objects of other classes in order for the program to execute.
True or false? In order to be useful, the System class must be used to instantiate objects in a Java application.
True or false? Class variables such as the out variable of the System class must be of some specific type.
True or false? Class variables must be of a primitive type such as int or float .
True or false? The out variable in the System class is of a primitive type.
True or false? An object of type PrintStream is automatically instantiated when the System class is loaded into an application.
True or false? The out variable in the System class refers to an instance of what class?
True or false? The println method is an instance method of what class?
What is the primary behavior of the println method?
How can the println method be accessed?
Assuming that the standard output device has not been redirected, write a code fragment that will cause your name to be displayed on the screen.
If you have a class named MyClass that has a class variable named myClassVariable that requires four bytes of memory and you instantiate ten objects of type MyClass , how much total memory will be allocated to contain the allocated variables (assume that the class definition contains no other class, instance, or local variables) .
How many actual instances of the variable named out are allocated in memory by the following code fragment?
System.out.println("Dick Baldwin"); If you have a class named MyClass that has an instance variable named myInstanceVariable that requires four bytes of memory and you instantiate ten objects of type MyClass , how much total memory will be allocated to contain the allocated variables (assume that the class definition contains no other class, instance, or local variables) .
What is the meaning of the following two images?
This image was inserted here simply to insert some space between the questions and the answers to keep them from being visible on the screen at the same time.
The image is also an example of the kinds of things that we do in my course titled ITSE 2321, Object-Oriented Programming.

This image was also inserted for the purpose of inserting space between the questions and the answers.
Every instance of a class has its own set of instance variables. You can only access instance variables and instance methods through an object of the class. In this case, forty bytes of memory would be required to contain the instance variables of the ten objects.
Only one, because out is a class variable of the System class.
The runtime system allocates a class variable only once no matter how many instances of the class are instantiated. Thus, all objects of the class share the same physical memory space for the class variable, and in this case, only four bytes of memory will be allocated to contain the allocated variables.
The statement in Answer 14 calls the println method belonging to an object of the PrintStream class, which is referenced (pointed to) by the out variable, which is a class variable of the System class.
System.out.println("Dick Baldwin"); The println method can be accessed by joining the name of a variable that references a PrintStream object to the name of the println method using a period.
The println method causes its argument to be displayed on the standard output device. (The standard output device is the screen by default, but can be redirected by the user at the operating system level.)
The println method is an instance method of the PrintStream class.
The out variable in the System class refers to an instance of the PrintStream class (a PrintStream object), which is automatically instantiated when the System class is loaded into the application.
True.
The code fragment accesses the contents of the class variable named out in the class named System .
False. the variable named out defined in the System class is a reference variable that points to an object of another type.
False. A class variable can be a primitive type, or it can be a reference variable that points to another object.
True.
False. The System class has several class variables (including out and in ) that are useful without the requirement to instantiate an object of the System class.
False. While it is probably true that the main method must instantiate objects of other classes in order to accomplish much that is of value, this is not a requirement. The main method in the "Hello World" program of this module does not instantiate objects of any class at all.
False. The main method can access the variables and methods of objects instantiated from other classes. Otherwise, the flow of the program would be stuck within the main method itself and wouldn't be very useful.
True.
This section contains a variety of miscellaneous information.
Financial : Although the Connexions site makes it possible for you to download a PDF file for this module at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should be aware that some of the HTML elements in this module may not translate well into PDF.
I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.
In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. I neither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please be aware that it is a copy of a module that is freely available on cnx.org and that it was made and published without my prior knowledge.
Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.
-end-