




































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





































































Western Governors University
Western Governors University - C Completed Course Study Guide
1.Where is a program typically stored when it is not running?
A. in the core processor B. in the primary storage C. in the cpu D. in the secondary storage: D. in the secondary storage 2.What is an applet?
A. An operating system plug-in that supports Java-enabled browsers B. Java code that can be located anywhere on the internet C. Java code that resides on a client browser D. A browser plug-in that allows Java code to run: B. Java code that can be located anywhere on the internet 3.What happens when the compile option is selected in a Java integrated development environment (IDE)?
A. The IDE scans the code and checks for syntax errors without translating or executing. B. The IDE interprets and executes Java code directly C. The IDE translates the Java code into machine-specific instructions. D. The IDE enters a context-sensitive mode that flags coding errors as information is entered: C. The IDE translates the Java code into machine-specific instructions.
The IDE interprets and executes Java code directly-this is more Java Vitural machine 4.The Java programming environment includes the Java Development Kit (JDK), the Java Runtime Environment (JRE), and the Java Virtual Machine (JVM). What are the relationship of these three components?
A. The JRE contains the JDK and JVM B. The JDK contains the JVM but not the JRE C. The JDK contains the JRE but not the JVM D. The JRE contains the JVM but not the JDK: D. The JRE contains the JVM but not the JDK 5.Given the following Java code:
System.out.println ("Hello, World!");
Match each code item to the correct description. Answer options may be used more than once or not at all.
System.out println (); "Hello, World!"
6.Given the following Java code:
System.out.println ("Hello, World!"); What does System.out represent?
A. An object B. A method C. A library D. A package: A. An object 7.Which variable is a Boolean? A. 101. B. True C. 12. D. 'r': B. True
String baseball = "Game"
Match each declaration part with the correct defining term. Answer options may be used more than once or not at all.
String Baseba ll = "Game" Choices: Variable Type; Variable Name; Assignment Operator; Value: String - Variable Type Baseball - Variable Name = - Assignment Operator "Game" - Value
A. double itemPrice=0; B. go itemPrice==0; C. integer itemPrice=0; D. the itemPrice==0;: A. double itemPrice=0;
integer itemPrice=0 would have worked if the keyword int was used not interger
A. Final B. Const C. Super
What will the system do?
A. Fail during Compile B. Compile but fail to run
C. Run and print "1 / 0" D. Run but report a run-time error: D. Run but report a run- time error 16.What is the difference between objects and classes?
A. Objects are instances of a class B. Objects are primitive types in a class C. Objects to not have to belong to a class D. Objects do not have lifespans but classes do.: A. Objects are instances of a class 17.What are objects, in the realm of Java?
A. Entities that share a common location in memory B. Variables with common names C. Entities that have certain basic properties D. Variables with no functionality: C. Entities that have certain basic properties 18.What is one definition of a class? A. A building block of a program B. An action applied to an object C. A technique to store a value for later retrieval D. A set of objects with common behavior: D. A set of objects with common behavior 19.Which code represents the use of an accessor method?
A. Public void setStudentID(int sID) SutdentID = sID; B. Public void setYear (String Year) year = Year; C. Public String getTitle() return title; D. Public void setCost (double Cost) cost = Cost;: C. Public String getTitle() return title; 20.What is Javadoc used for in Java platforms?
A. To automatically generate API documentation B. To enable the Java Virtual Machine at run-time C. To quickly develop an applet from a template object D. To make code platform-independent: A. To automatically generate API documentation 21.Given the Java code:
Public static void main(String[] args) { Scanner keyboard = new Scanner (system.in); System.out.print ("input your name: "); String myName = keyboard.nextLine (); String greeting = welcome (myName); }
Match each code line to the correct description: Method call with no passed value but a return value Method call with passed value and return value Method call with passed value
System.out.print ("input your name: "); - Method call with passed value but no return value
Scanner keyboard = new Scanner (system.in); - Constructor call with passed value 22.Given the following Java code:
Public Bicycle (int startCadence, int startSpeed, int startGear) { Gear = startGear; Cadence = startCadence; Speed = startSpeed; }
Bicycle mybike = new Bicycle (30, 0,
8); What is the constructor name? A. new Bicycle B. startGear C. Bicycle D. cadence: C. Bicycle
A. Class inheritance B. Object reference C. Variable initialization D. Passing by value: C. Variable initialization 24.A programmer want to define a method that carries out a sequence of instructions, producing output but not returning a value.
Which return type should the programmer declare for this method?
A. Null B. No value need to be declared. C. Void D. polymorphic: C. Void
Public void Swap(int var1, int var2) { int temp = var1: var1 = var2; var = temp; }
Which statement is passing arguments by value?
A. Swap(1, 2); B. Int temp = var1: C. var2 = temp; D. Swap(int, int);: A. Swap(1, 2);
C. The types of the index must be declared D. The type of the array entries must be declared.: D. The type of the array entries must be declared. 30.What is one reason to use an array list?
A. To avoid specifying type during creation B. To collect objects of different types C. To create a collection of elements D. To automatically initialized elements: C. To create a collection of elements 31.What is the advantage of a Java array list over an array?
A. Array list elements can be of different types. B. Array list can you primitive types as the type parameter C. Array list elements are automatically initialized D. Array list can grow or shrink as needed.: D. Array list can grow or shrink as needed. 32.A programmer wants to access the last element in the ArrayList phoneNumbers but does not know how many elements are in the array list.
Which method should the programmer use to determine the length of this array list?
A. phoneNumbers.index () B. phoneNumbers.get () C. phoneNumbers.size () D. phoneNumbers.length (): C. phoneNumbers.size () 33.Given the following Java array list:
ArrayList students = new ArrayList ();
A programmer wants to read every element i in students, using the
Java code: for (int i = 0; ; i++ String student = student.get (i);
Which comparison, when substituted for the underscore, will iterate though this array list correctly?
A. i < students.size () ; B. i < students.length () - 1; C. i < students.length (); D. i < students.size () - 1;: A. i < students.size () -1;
A. A subclass can override inherited methods B. The inherited method can never be used directly. C. A subclass can access the private members of its parent class D. A subclass constructor cannot invoke the constructor of the superclass: A. A subclass can override inherited methods
A. Method type override B. Superclass method invocation C. Implicit parameters D. Dynamic method lookup.: A. Method type override
polymorphism-start from super class to the sub class 37.A programmer wants to create a Java method that will accept input payment codes entered while hiding the field in the object.
Which object-oriented programming technique supports this requirement to hide this information?
A. Encryption B. Inheritance C. Polymorphism D. Encaspsulation: D. Encaspsulation
A. Hide implementation details B. Hides the public interface C. Exposes implementation details D. Exposes the private interface: A. Hide implementation details 39.What does the "this" keyword reference for the current object?
A. A method that initiates a recursive procedure B. A variable that references the current instantiated object C. A method that references the called object D. An undeclared variable that references the called object.: C. A variable that references the current instantiated object 40.A program computes an int value and display the result.
If the computation yields a value outside the int range, what will the system display?
A. A stack error message B. The correct value C. An incorrect value D. A syntax error E. A truncated value: E. A truncated value 41.Given the following Java code:
short a = 5; int b = 2; double c = 1.0; double d= 5.0;
Match each operation to the correct result. Answer options may be used more than once or not at
all. System.out.println ( a / b / c ); System.out.println ( a / b ); System.out.println ( a / c / b );
code: int value = 33.333/
What is the result of the operation?
B. Buffer overflow C. Type mismatch D. 11.
What is the result of this operation: C. Type mismatch
&& ^ || !: && - And ^ - XOR (either one but not both) || - OR ! - Not
int a = 4; int b = 6;
Match each operation with the returned value of True or
False. a< 6 && b > a==4 && b<5 a>= || b< a<6 || a 5 = true 4==4 and 6<5 = false 4>=6 or 6<5 = false 4<6 or 4 <6 = true
String occupation = "StudentTeacher"; String occupation2 = occupation.toUppercase
(); What does this code do?
A. Changes the value of occupation to "STUDENTTEACHER" B. Creates a new substring occupation2 as a substring of occupation containing only the charactors "ST" C. Creates a new string occupation2 with a value of "STUDENTTEACHER" and leaves the string occupation as is D. Creates a new string occupation2 with a value of "STUDENTTEACHER" and deletes the string occupation: C. Creates a new string occupation2 with a value of "STUDENTTEACHER" and