CSIT 210 Final Exam review Questions

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/240

flashcard set

Earn XP

Description and Tags

CSIT 210 Final Exam review Questions Taken from Practice Quiz 1-9

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

241 Terms

1
New cards
_____________ consists of specific words and symbols to express a problem solution.
a) A programming language
b) Hardware
c) An application
d) Software
e) A computer
a) A programming language
2
New cards
Java is _____________________.
a) a functional language
b) a fourth-generation language
c) a procedural language
d) a spoken-language
e) an object-oriented language
e) an object-oriented language
3
New cards
In Java, an identifier that is made up by the programmer can consist of ___________________.
a) any characters
b) only numbers
c) only letters, the underscore ( _ ), and the dollar sign ( $ )
d) numbers, letters, the underscore ( _ ), and the dollar sign ( $ )
e) only letters
d) numbers, letters, the underscore ( _ ), and the dollar sign ( $ )
4
New cards
In order for a program to run on a computer, it must be expressed in ______________________.
a) a high-level language
b) a machine language
c) a fourth generation language
d) an assembly language
e) an object-oriented language
b) a machine language
5
New cards
A syntax error is a _____________________.
a) a run-time error
b) a bug
c) a compile-time error
d) a logical error
e) an exception
c) a compile-time error
6
New cards
Which of the following is not one of the four basic software development activities?
a) testing
b) preliminary practice coding
c) establishing the requirements
d) implementing the design
e) creating a design
b) preliminary practice coding
7
New cards
Software requirements specify ____________________.
a) how a solution should be implemented
b) which programming language the developer should use
c) how objects should be encapsulated
d) a programming schedule
e) what a program should accomplish
e) what a program should accomplish
8
New cards
The _____________ of an object define it define its potential behaviors.
a) variables
b) methods
c) attributes
d) name
e) white spaces
b) methods
9
New cards
Which of the following is considered a logical error?
a) misspelling an identifier
b) forgetting a semicolon at the end of a programming statement
c) multiplying two numbers when you meant to add them
d) typing a curly bracket when you should have typed a parenthesis
e) dividing by zero
c) multiplying two numbers when you meant to add them
10
New cards
Which of the following lines is a properly formatted comment?
a) // This is a comment
b) /* This is a comment */
c) /*
this is a comment
*/
d) both a and b
e) a, b and c
e) a, b and c
11
New cards
The Java compiler translates Java source code into _____________ .
a) C++
b) machine code
c) an object-oriented language
d) assembly code
e) Java bytecode
e) Java bytecode
12
New cards
Classes can be created from other classes by using _______________ .
a) encapsulation
b) machine code
c) attributes
d) polymorphism
e) inheritance
e) inheritance
13
New cards
Which of the following is not a valid Java identifier?
a) anExtremelyLongIdentifierIfYouAskMe
b) highest$
c) 2ndlevel
d) answer_7
e) thirdNumber
c) 2ndlevel
14
New cards
Which of the following might be included in an IDE?
a) a compiler
b) an editor
c) a debugger
d) all of the above
e) none of the above
d) all of the above
15
New cards
Which of the following describes the act of ensuring that a program solves the intended problem in all cases?
a) creating a design
b) implementing the design
c) establishing the requirements
d) testing
e) preliminary practice coding
d) testing
16
New cards
Write a statement that prints Hello, world to the screen.
a) System.out.println("Hello, world")
b) System.out.println("Hello, world");
c) system.out.println("Hello, world");
d) System.out.println('Hello, world');
b) System.out.println("Hello, world");
17
New cards
What can be included in a comment?
a) reserved words
b) special characters
c) user output
d) all of the above
d) all of the above
18
New cards
Which of the following is a valid comment?
a) int age; */ the age of the user /*
b) int age; //* the age of the user //*
c) int age; /* the age of the user */
d) int age; /*// the age of the user //*/
c) int age; /* the age of the user */
19
New cards
Which of the following is not a reserved word?
a) main
b) public
c) this
d) static
a) main
20
New cards
Which of the following is a valid Java identifier?
a) _____________
b) Fourth_&_goal
c) Studio#54
d) 2_%_2
a) _____________
21
New cards
Java is case-sensitive.
True
False
True
22
New cards
Comments affect the run-time execution of a program.
True
False
False
23
New cards
A reserved word can be used to name a method.
True
False
False
24
New cards
An identifier can begin with a digit.
True
False
False
25
New cards
In Java, total, ToTal and TOTAL are all different identifiers.
True
False
True
26
New cards
Identifiers can be of any length.
True
False
True
27
New cards
These two snippets of code are identical from the point of view of the compiler:
//snippet 1
public static void main(String [] args) {
System.out.println("Hi!");
}
//snippet 2
public static void main(String [] args){System.out.println("Hi!");}
True
False
True
28
New cards
An interpreter is a program that translates code that is written in one language into equivalent code in another language.
True
False
False
29
New cards
Syntax rules dictate the form of a program. Semantics dictate the meaning of the program statements.
True
False
True
30
New cards
An object should never be encapsulated.
True
False
False
31
New cards
Which of the following are examples of invalid string literals?
a) "Hello World!"
b) "4 score and 7 years ago, our forefathers brought forth..."
c) "z"
d) ""
e) none of the above
e) none of the above
32
New cards
A(n) ________________ is a piece of data that we send to a method.
a) expression
b) escape sequence
c) object
d) parameter
e) service
d) parameter
33
New cards
Which of the following is an example of an invalid assignment or declaration statement?
a) int age = 30;
b) int money, dollars = 0, cents = 0;
c) int years = 1; months = 12; days = 365;
d) int length, meters, centimeters, millimeters;
e) none of the above
c) int years = 1; months = 12; days = 365;
34
New cards
Java has two basic kinds of numeric values: _____________, which have no fractional part, and ___________________ which do.
a) characters, bytes
b) doubles, floating points
c) integers, floating points
d) integers, longs
e) shorts, longs
c) integers, floating points
35
New cards
Consider the expression:
result = 12 + 5 / 2;
What value stored in result after this line is executed?
a) this will result in a compiler error
b) 14
c) 14.5
d) 8.5
e) 9
b) 14
36
New cards
Which of the following is not an arithmetic operation in Java?
a) +
b) -
c) *
d) %
e) These are all arithmetic operations in Java
e) These are all arithmetic operations in Java
37
New cards
In order to make a variable a constant which modifier must be included in its declaration?
a) private
b) final
c) static
d) void
e) public
b) final
38
New cards
Which of the following data types only allows one of two possible values to be assigned?
a) int
b) long
c) char
d) float
e) boolean
e) boolean
39
New cards
Which of the following is an example of an invalid expression in Java?
a) result = firstNum / secondNum % thirdNum;
b) result = ((19 + 4) - 5;
c) result = (14 + 9) * 5;
d) result = firstNum % secondNum;
e) result = a + b;
b) result = ((19 + 4) - 5;
40
New cards
A _______________ is a list of characters in a particular order. Examples include ASCII and Unicode.
a) character literal
b) character set
c) char data type
d) control character
e) none of the above
b) character set
41
New cards
Consider the expression:
result = 15 % 4;
What value stored in result after this line is executed?
a) 0
b) 1
c) 2
d) 3
e) 4
d) 3
42
New cards
Which of the following lines allows a programmer to use the Scanner class in a Java program?
a) import java.util.Scanner;
b) using Scanner;
c) include Scanner;
d) include java.util.Scanner;
e) any of the above will allow the programmer to use the Scanner class
a) import java.util.Scanner;
43
New cards
Consider the following snippet of code:
System.out.println("30 plus 25 is " + 30 + 25);
What is printed by this line?
a) 30 plus 25 is 3025
b) this snippet of code will result in a compiler error
c) 30 plus 25 is 25
d) 30 plus 25 is 55
e) 30 plus 25 is 30
a) 30 plus 25 is 3025
44
New cards
Consider the following snippet of code:
int firstNum = 25;
int seconNum = 3;
double result = 25/3;
System.out.println(result);
What is output by this code?
a) 8
b) 8.3
c) 8.333333333
d) This snippet of code will result in a compiler error
e) 8.0
e) 8.0
45
New cards
Information is most likely to be lost in what kind of data conversion?
a) A widening conversion
b) A narrowing conversion
c) promotion
d) assignment conversion
e) no information will be lost in any of the conversions listed above
b) A narrowing conversion
46
New cards
The print and the println methods are identical and can be used interchangeably.
True
False
False
47
New cards
In order for a string literal may span multiple lines in the program code.
True
False
False
48
New cards
Java is a strongly-typed language.
True
False
True
49
New cards
Variables declared with the final modifier cannot have new values assigned to them.
True
False
True
50
New cards
The byte type can be assigned a larger range of numbers than the int type.
True
False
False
51
New cards
Java uses the ASCII character set to represent character data.
True
False
False
52
New cards
In Java, all floating point literals are assumed to be of type float.
True
False
False
53
New cards
The type of result produced by a mathematical expression depends on the types of the operands.
True
False
True
54
New cards
Promotion is a widening data conversion that is explicitly requested by the programmer.
True
False
False
55
New cards
The Scanner class must be imported using the import statement before it can be used in a program.
True
False
True
56
New cards
Write a String constant consisting of exactly one character - A.
a) System.out.println(A)
b) System.out.print('A')
c) System.out.print("A");
d) system.out.println("A")
c) System.out.print("A");
57
New cards
Write a String constant that is the empty string.
a) System.out.print("");
b) System.out.print( );
c) System.out.print('');
d) none of the above
a) System.out.print("");
58
New cards
The character escape sequence to force the cursor to advance forward to the next tab setting is:
a) \\t
b) \t
c) \T
d) \tab
b) \t
59
New cards
Declare an integer constant, DAYS_IN_MAY , whose value is 31.
a) final int DAYS_IN_YEAR = 31;
b) final INT DAYS_IN_MAY = 31;
c) final int DAYS_IN_MAY = 31;
d) final String DAYS_IN_MAY = "31";
c) final int DAYS_IN_MAY = 31;
60
New cards
Writing a floating point literal corresponding to the value of 0.
a) 0f
b) 0.0
c) 0.0f
d) all of the above
d) all of the above
61
New cards
The ________________ operator is used to instantiate an object.
a) static
b) new
c) +
d) -
e) none of the above
b) new
62
New cards
A special method that is invoked to set up an object during instantiation is called a ___________________.
a) creator
b) destructor
c) constructor
d) new method
e) dot operator
c) constructor
63
New cards
Which of the following is an invalid way to instantiate a String object?
a) String title = new String("Java Software Solutions");
b) String name = "John Lewis";
c) String empty = "";
d) String alsoEmpty = new String("");
e) all of the above are valid
e) all of the above are valid
64
New cards
Assume that we have a Random object referenced by a variable called generator. Which of the following lines will generate a random number in the range 5-20 and store it in the int variable randNum?
a) randNum = generator.nextInt(15) + 5;
b) randNum = generator.nextInt(15) + 6;
c) randNum = generator.nextInt(16) + 5;
d) randNum = generator.nextInt(16) + 6;
e) none of the above
c) randNum = generator.nextInt(16) + 5;
65
New cards
Which of the following classes include the getCurrencyInstance() method?
a) String
b) NumberFormat
c) DecimalFormat
d) Math
e) none of the above
b) NumberFormat
66
New cards
Which of the following expressions correctly compute 5 + 2^6?
a) result = 5 + 2^6;
b) result = 5 + 2*exponent(6);
c) result = 5 + 2*Math.exponent(6);
d) result = 5 + Math.pow(2, 6);
e) none of the above
d) result = 5 + Math.pow(2, 6);
67
New cards
Consider the following snippet of code:
Random generator = new Random();
int randNum = generator.nextInt(20) + 1;
Which of the following will be true after these lines are executed?
a) randNum will hold a number between 1 and 20 inclusive.
b) randNum will hold a number between 0 and 20 inclusive.
c) randNum will hold a number between 1 and 21 inclusive.
d) these lines will not be executed because a compiler error will result.
e) none of the above
a) randNum will hold a number between 1 and 20 inclusive.
68
New cards
Which of the following represents the proper way to create a NumberFormat object that formats numbers as percentages?
a) NumberFormat fmt = new NumberFormat(%);
b) NumberFormat fmt = new NumberFormat("%");
c) NumberFormat fmt = NumberFormat.getPercentInstance();
d) NumberFormat fmt = new PercentNumberFormat();
e) none of the above
c) NumberFormat fmt = NumberFormat.getPercentInstance();
69
New cards
Which of the following is a correct declaration of enumerated type for the suits of a deck of cards?
a) enum Suit = { hearts, spades, diamonds, clubs }
b) enum Suit {hearts, spades, diamonds, clubs };
c) enumerated type Suit = { hearts, spades, diamonds, clubs };
d) enumerated type Suit = {hearts, spades, diamonds, clubs };
e) enum Suit {hearts, spades, diamonds, clubs }
b) enum Suit {hearts, spades, diamonds, clubs };
70
New cards
____________________ is the automatic conversion between a primitive value and a corresponding wrapper object.
a) Static invocation
b) Aliasing
c) Number formatting
d) Autoboxing
e) Generating
d) Autoboxing
71
New cards
Which of the following best describes what happens when an object no longer has any references pointing to it?
a) The object is overwritten the next time the new operator is called using the same class.
b) The object is immediately deleted from memory.
c) The object is overwritten the next time the new operator is called.
d) The object stays in memory for the remainder of the programs execution.
e) The object is marked as garbage and its associated memory is freed when the garbage collector runs.
e) The object is marked as garbage and its associated memory is freed when the garbage collector runs.
72
New cards
When an object variable is declared but it is not assigned a value, it is called a ______________________.
a) empty reference
b) zero reference
c) null reference
d) void reference
e) static reference
c) null reference
73
New cards
Suppose we have a String object referenced by a variable called listing. Suppose we want a new String object that consists of the first 5 characters in listing. Which of the following lines of code will achieve this?
a) String prefix = listing.front(5);
b) String prefix = listing.front(6);
c) String prefix = listing.substring(1,5);
d) String prefix = listing.substring(0,5);
e) String prefix = listing.firstChars(5);
d) String prefix = listing.substring(0,5);
74
New cards
When two references point to the same object, ________________________________ .
a) a run-time error will occur.
b) a compiler error will occur.
c) the references are called aliases of each other.
d) the object will be marked for garbage collection.
e) the references are called null references.
c) the references are called aliases of each other.
75
New cards
The String class _______________________________ .
a) is part of the java.lang package.
b) is part of the java.util.package.
c) is a wrapper class.
d) none of the above.
e) all of the above.
a) is part of the java.lang package.
76
New cards
Multiple reference variables can refer to the same object.
True
False
True
77
New cards
The new operator is used to access an objects methods.
True
False
False
78
New cards
A variable that is declared as a primitive type stores the actual value of the associated data. A variable that is declared as an object type stores a pointer to the associated object.
True
False
True
79
New cards
When there are no references to an object, the object is marked as garbage and is automatically removed from memory using Java's automatic garbage collection feature.
True
False
True
80
New cards
String objects can be changed after instantiation.
True
False
False
81
New cards
All of the classes contained in the java.util package are automatically included in every Java program.
True
False
False
82
New cards
When called with integer parameter n, the nextInt() method of the Random class will return a randomly generated integer between 0 and n.
True
False
False
83
New cards
The Math class is part of the java.lang package.
True
False
True
84
New cards
Enumerated types allow a programmer to treat primitive data as objects.
True
False
False
85
New cards
The System.out.printf() method is an alternative way to output information in Java.
True
False
True
86
New cards
Assume there is a class AirConditioner that supports the following behaviors: turning the air conditioner on and off, and checking if the air conditioner is on or off. The following methods provide this behavior: turnOn and turnOff , setTemp , and isOn , which accepts no argument and returns a boolean indicating whether the air conditioner is on or off. Assume there is a reference variable myAC to an object of this class, which has already been created.
a) myAC.isOn()
b) status = myAC.isOn( );
c) myAC.status();
d) status = myAC.isOn
b) status = myAC.isOn( );
87
New cards
Assume there is a class AirConditioner that supports the following behaviors: turning the air conditioner on and off, and setting the desired temperature. The following methods provide this behavior: turnOn and turnOff , and setTemp , which accepts an int argument and returns no value. Assume there is a reference variable myAC to an object of this class, which has already been created. Use the reference variable, to invoke a method that tells the object to set the air conditioner to 72 degrees.
a) myAC.turnOn();
myAC.setTemp(72);
b) myAC.setTemp( 72 );
c) myAc.setTemp(72);
d) myAC.turnOn(72);
b) myAC.setTemp( 72 );
88
New cards
Assume that dateManager is a reference to an object that has a method named printTodaysDate , that accepts no arguments and returns no value. Write a statement that calls printTodaysDate .
a) dataManager.printTodaysDate();
b) printTodaysDate();
c) dateManager.printTodaysDate( );
d) dateManager.printTodaysDate;
c) dateManager.printTodaysDate( );
89
New cards
Assume that logger is a reference to an object that has a method named printErrorDescription , that accepts one int argument and returns no value. Write a statement that invokes the method printErrorDescription , passing it the value 14 .
a) logger.printErrorDescription(14);
b) printErrorDescription.logger(14);
c) printErrorDescription(14);
d) printErrorDescription(14);
a) logger.printErrorDescription(14);
90
New cards
Assume that dataTransmitter is a variable that refers to an object that provides a method, sendSignal that takes no arguments. Write the code for invoking this method.
a) dateTransmitter.sendSignal();
b) dataTransmitter.sendSignal();
c) dataTransmitter.sendSignal;
d) sendSignal.dataTransmitter();
b) dataTransmitter.sendSignal();
91
New cards
Which of the following statements best describes the flow of control in the main method of a Java program that has no conditionals or loops?
a) Program statements are all executed at the same time.
b) Program statements are executed according to their priority, which is specified by the programmer.
c) Program statements are executed linearly, with earlier statements being executed first.
d) Some program statements are executed at the same time, and others are executed in a linear manner.
e) Program statements are executed linearly, with later statements being executed first.
c) Program statements are executed linearly, with earlier statements being executed first.
92
New cards
Which of the following best describes this code snippet?
if (count != 400)
System.out.println("Hello World!");
a) If the variable count is not equal to 400, "Hello World" will be printed.
b) If the variable count is exactly equal to 400, "Hello World" will be printed.
c) This code will not compile.
d) If the variable count is close to, but not greater than, 400, "Hello World" will be printed.
e) If the variable count is exactly equal to 399 or 401, "Hello World" will be printed.
a) If the variable count is not equal to 400, "Hello World" will be printed.
93
New cards
Which of the following is not a valid relational operator in Java
a) !=
b) >
c) <>
d)
c) <>
94
New cards
Let a and b be valid boolean expressions. Which of the following best describes the result of the expression a || b?
a) It will evaluate to true if a evaluates to true and b evaluates to true. It will evaluate to false otherwise.
b) It will evaluate to false if a evaluates to false and b evaluates to false. It will evaluate to true otherwise.
c) It will evaluate to true if a evaluates to false and b evaluates to false. It will evaluate to true otherwise.
d) It will evaluate to true if a evaluates to false or b evaluates to false. It will evaluate to true otherwise.
e) None of the above statements correctly describes the evaluation of the expression.
b) It will evaluate to false if a evaluates to false and b evaluates to false. It will evaluate to true otherwise.
95
New cards
Which of the following expressions best represents the condition "if the grade is between 70 and 100"?
a) if (75 < grade < 100)
b) if (75 < grade && grade < 100)
c) if (75 < grade || grade < 100)
d) if (grade != 75 && grade != 100)
e) if (75 > grade || grade < 100)
b) if (75 < grade && grade < 100)
96
New cards
Which of the following logical operators has the highest precedence?
a) ||
b) &&
c) <
d) >
e) !
e) !
97
New cards
Suppose we wanted to process a text file called "input.txt" using the Scanner object. Which of the following lines of code correctly creates the necessary Scanner object?
a) Scanner inputFile = new Scanner(new InputFile(input.txt));
b) Scanner inputFile = new Scanner(new InputFile("input.txt"));
c) Scanner inputFile = new Scanner(new File("input.txt"));
d) Scanner inputFile = new Scanner("input.txt");
e) Scanner inputFile = new Scanner(new File(input.txt));
c) Scanner inputFile = new Scanner(new File("input.txt"));
98
New cards
A _______________ loop always executes its loop body at least once.
a) while
b) There are no loop structures with this property in Java.
c) repeat
d) for
e) do
e) do
99
New cards
What happens if a case in a switch statement does not end with a break statement?
a) The case will never be executed.
b) The program will not compile.
c) The switch statement will execute the next case statement as well.
d) The switch statement will never execute.
e) It will cause an infinite loop.
c) The switch statement will execute the next case statement as well.
100
New cards
Suppose we want to condition an if statement on whether two String objects, referenced by stringOne and stringTwo, are the same. Which of the following is the correct way to achieve this?
a) if(stringOne == stringTwo)
b) if(stringOne.compareTo(stringTwo))
c) if(stringOne === stringTwo)
d) if(stringOne != stringTwo)
e) if(stringOne.equals(stringTwo))
e) if(stringOne.equals(stringTwo))