Revised: February 3, 2007
By Richard G. Baldwin
File Pfsg00110.htm
Practice Text Index
The practice tests in this series were written specifically for the benefit of my students in COSC 1315, Fundamentals of Programming. They consists of questions, answers, and explanations. The questions are based on the material covered in my series of online lecture notes for the course. Each practice test is keyed to a specific lecture. This practice test is keyed to lecture #110 titled Basic Object-Based Program Structure.
110-2. True or False. An Object-Oriented program exhibits three critical attributes:
110-3. True or False. It is easy to eliminate all global functions in C++.
110-4. True or False. As is the case in C++, the C# programming language also requires a global Main function (which is usually called a method instead of a function).
110-5. True or False. A static function or method can be accessed without a requirement to instantiate an object of the class.
110-6. The program shown in Listing 110-6 is:
public class Hello1{ public static void Main(){ System.Console.WriteLine("Hello World"); }//end Main }//end class Hello01 |
110-7. What output is produced by the C# program shown in Listing 110-7?
public class Hello1{ public static void Main(){ System.Console.WriteLine("Hello World"); }//end Main }//end class Hello01 |
110-8. True or False. To compile C# programs, you must use a fancy IDE such as Microsoft Visual Studio.
110-9. The program shown in Listing 110-9 is:
class Hello1{ public static void main(String[] args){ System.out.println("Hello World"); }//end main }//End Hello1 class |
110-10. What output is produced by the Java program shown in Listing 110-10?
class Hello1{ public static void main(String[] args){ System.out.println("Hello World"); }//end main }//End Hello1 class |
110-11. The program shown in Listing 110-11 is:
#include <iostream> using namespace std; class Hello1{ public: static void classMain(){ cout << "Hello World" << endl; }//End classMain function };//End Hello1 class //---------------------------------------------// int main(){ Hello1::classMain(); return 0; }//end main |
110-12. What output is produced by the C++ program shown in Listing 110-12?
#include <iostream> using namespace std; class Hello1{ public: static void classMain(){ cout << "Hello World" << endl; }//End classMain function };//End Hello1 class //---------------------------------------------// int main(){ Hello1::classMain(); return 0; }//end main |
110-13. True or False. There are essentially four kinds of functions in C++:
110-14. True or False. Global functions are essentially accessible by any code in any function that knows the name of the global function.
110-15. True or False. Class functions are functions that are defined inside a class without using the static keyword.
110-16. True or False. Class functions in C++ can be declared public, private, package-private, or protected.
110-17. True or False. Public class functions can be accessed by any code in any function that knows the name of the function and the name of the class in which the function is defined.
110-18. True or False. Public static functions can be accessed in the total absence of an object of the class.
110-19. True or False. Instance functions are functions that are defined inside a class without using the static keyword.
110-20. True or False. For efficiency purposes, only one copy of an instance function actually exists. However some "smoke and mirrors" is used to make it appear that every object instantiated from the class has its own copy of every instance function that is defined in the class.
110-21. True or False.
110-22. True or False. Instance functions can be declared public, private, or protected. Public instance functions can be invoked by any code that has access to the object to which the functions belong.
110-23. True or False. It is common practice in object-oriented programming to cause an object to encapsulate:
110-24. True or False. The program in Listing 110-24:
#include <iostream> using namespace std; class Hello2{ public: static void classMain(){ Hello2* ptrToObject = new Hello2(); ptrToObject -> doSomething(); }//End classMain function //-------------------------------------------// //An instance function belonging to the Hello2 // object. void doSomething(){ cout << "Hello World\n"; }//end doSomething function };//End Hello2 class //---------------------------------------------// int main(){ Hello2::classMain(); return 0; }//end main |
110-25. True or False. The boldface statement in Listing 110-25:
#include <iostream> using namespace std; class Hello2{ public: static void classMain(){ Hello2* ptrToObject = new Hello2(); ptrToObject -> doSomething(); }//End classMain function //-------------------------------------------// //An instance function belonging to the Hello2 // object. void doSomething(){ cout << "Hello World\n"; }//end doSomething function };//End Hello2 class //---------------------------------------------// int main(){ Hello2::classMain(); return 0; }//end main |
110-26. True of False. The boldface statement in Listing 110-26 effectively:
#include <iostream> using namespace std; class Hello2{ public: static void classMain(){ Hello2* ptrToObject = new Hello2(); ptrToObject -> doSomething(); }//End classMain function //-------------------------------------------// //An instance function belonging to the Hello2 // object. void doSomething(){ cout << "Hello World\n"; }//end doSomething function };//End Hello2 class //---------------------------------------------// int main(){ Hello2::classMain(); return 0; }//end main |
Richard has participated in numerous consulting projects involving Java, XML, or a combination of the two. He frequently provides onsite Java and/or XML training at the high-tech companies located in and around Austin, Texas. He is the author of Baldwin's Java Programming Tutorials, which has gained a worldwide following among experienced and aspiring Java programmers. He has also published articles on Java Programming in Java Pro magazine.
Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.
Richard has participated in numerous consulting projects involving Java, XML, or a combination of the two. He frequently provides onsite Java and/or XML training at the high-tech companies located in and around Austin, Texas. He is the author of Baldwin's Java Programming Tutorials, which has gained a worldwide following among experienced and aspiring Java programmers. He has also published articles on Java Programming in Java Pro magazine.
Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.
-end-