CSIT 210

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 1189

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

1190 Terms

1

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, c

New cards
2

The Java compiler translates Java source code into _____________ .

a.

assembly code

b.

C++

c.

Java bytecode

d.

an object-oriented language

e.

machine code

c. Java bytecode

New cards
3

Classes can be created from other classes by using _______________ .

a.

machine code

b.

attributes

c.

polymorphism

d.

encapsulation

e.

inheritance

e. inheritance

New cards
4

Which of the following is not a valid Java identifier?

a.

thirdNumber

b.

answer_7

c.

2ndlevel

d.

highest$

e.

anExtremelyLongIdentifierIfYouAskMe

c. 2ndlevel

New cards
5

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

New cards
6

Which of the following describes the act of ensuring that a program solves the intended problem in all cases?

a.

implementing the design

b.

creating a design

c.

establishing the requirements

d.

testing

e.

preliminary practice coding

d. testing

New cards
7

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');

c. System.out.println("Hello, world");

New cards
8

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

New cards
9

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 //

a. int age; / the age of the user /

New cards
10

Which of the following is not a reserved word?

a.

static

b.

this

c.

public

d.

main

d. main

New cards
11

_____________ consists of specific words and symbols to express a problem solution.

a.

An application

b.

A computer

c.

Hardware

d.

Software

e.

A programming language

e. A programming language

New cards
12

Which of the following is a valid Java identifier?

a.

Fourth_&_goal

b.

2_%_2

c.

Studio#54

d.

_____________

d. _____________

New cards
13

Java is _____________________.

a.

a spoken-language

b.

a functional language

c.

an object-oriented language

d.

a fourth-generation language

e.

a procedural language

c. an object-oriented language

New cards
14

In Java, an identifier that is made up by the programmer can consist of ___________________.

a.

only numbers

b.

numbers, letters, the underscore ( _ ), and the dollar sign ( $ )

c.

only letters

d.

any characters

e.

only letters, the underscore ( _ ), and the dollar sign ( $ )

b. numbers, letters, the underscore ( _ ), and the dollar sign ( $ )

New cards
15

In order for a program to run on a computer, it must be expressed in ______________________.

a.

a high-level language

b.

an object-oriented language

c.

an assembly language

d.

a machine language

e.

a fourth generation language

d. a machine language

New cards
16

A syntax error is a _____________________.

a.

a run-time error

b.

a bug

c.

a compile-time error

d.

an exception

e.

a logical error

c. a compile-time error

New cards
17

Which of the following is not one of the four basic software development activities?

a.

implementing the design

b.

establishing the requirements

c.

preliminary practice coding

d.

testing

e.

creating a design

c. preliminary practice coding

New cards
18

Software requirements specify ____________________.

a.

a programming schedule

b.

how a solution should be implemented

c.

what a program should accomplish

d.

which programming language the developer should use

e.

how objects should be encapsulated

c. what a program should accomplish

New cards
19

The _____________ of an object define it define its potential behaviors.

a.

methods

b.

attributes

c.

name

d.

white spaces

e.

variables

a. methods

New cards
20

Which of the following is considered a logical error?

a.

typing a curly bracket when you should have typed a parenthesis

b.

dividing by zero

c.

multiplying two numbers when you meant to add them

d.

misspelling an identifier

e.

forgetting a semicolon at the end of a programming statement

c. multiplying two numbers when you meant to add them

New cards
21

An object should never be encapsulated.

True

False

False

New cards
22

Java is case-sensitive.

True

False

True

New cards
23

Comments affect the run-time execution of a program.

True

False

False

New cards
24

A reserved word can be used to name a method.

True

False

False

New cards
25

An identifier can begin with a digit.

True

False

False

New cards
26

In Java, total, ToTal and TOTAL are all different identifiers.

True

False

True

New cards
27

Identifiers can be of any length.

True

False

True

New cards
28

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

New cards
29

An interpreter is a program that translates code that is written in one language into equivalent code in another language.

True

False

False

New cards
30

Syntax rules dictate the form of a program. Semantics dictate the meaning of the program statements.

True

False

True

New cards
31

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

New cards
32

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

New cards
33

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;

New cards
34

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 55

b.

30 plus 25 is 3025

c.

30 plus 25 is 30

d.

30 plus 25 is 25

e.

this snippet of code will result in a compiler error

b. 30 plus 25 is 3025

New cards
35

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.3

b.

8.333333333

c.

This snippet of code will result in a compiler error

d.

8

e.

8.0

e. 8.0

New cards
36

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

New cards
37

Write a String constant consisting of exactly one character - A.

a.

System.out.print("");

b.

System.out.print( );

c.

System.out.print('');

d.

none of the above

a. System.out.print("");

New cards
38

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("");

New cards
39

The character escape sequence to force the cursor to advance forward to the next tab setting is:

a.

\t

b.

\tab

c.

\T

d.

\\t

a. \t

New cards
40

Declare an integer constant, DAYS_IN_MAY , whose value is 31.

a.

final int DAYS_IN_MAY = 31;

b.

final String DAYS_IN_MAY = "31";

c.

final int DAYS_IN_YEAR = 31;

d.

final INT DAYS_IN_MAY = 31;

a. final int DAYS_IN_MAY = 31;

New cards
41

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

New cards
42

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

New cards
43

A(n) ________________ is a piece of data that we send to a method.

a.

service

b.

expression

c.

escape sequence

d.

object

e.

parameter

e. parameter

New cards
44

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;

New cards
45

Java has two basic kinds of numeric values: _____________, which have no fractional part, and ___________________ which do.

a.

shorts, longs

b.

characters, bytes

c.

integers, floating points

d.

doubles, floating points

e.

integers, longs

c. integers, floating points

New cards
46

Consider the expression:

result = 12 + 5 / 2;

What value stored in result after this line is executed?

a.

8.5

b.

14

c.

14.5

d.

this will result in a compiler error

e.

9

b. 14

New cards
47

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

New cards
48

In order to make a variable a constant which modifier must be included in its declaration?

a.

public

b.

private

c.

void

d.

final

e.

static

d. final

New cards
49

Which of the following data types only allows one of two possible values to be assigned?

a.

long

b.

char

c.

int

d.

boolean

e.

float

d. boolean

New cards
50

Which of the following is an example of an invalid expression in Java?

a.

result = firstNum % secondNum;

b.

result = firstNum / secondNum % thirdNum;

c.

result = a + b;

d.

result = (14 + 9) * 5;

e.

result = ((19 + 4) - 5;

e. result = ((19 + 4) - 5;

New cards
51

The Scanner class must be imported using the import statement before it can be used in a program.

True

False

True

New cards
52

The print and the println methods are identical and can be used interchangeably.

True

False

False

New cards
53

In order for a string literal may span multiple lines in the program code.

True

False

False

New cards
54

Java is a strongly-typed language.

True

False

True

New cards
55

Variables declared with the final modifier cannot have new values assigned to them.

True

False

True

New cards
56

The byte type can be assigned a larger range of numbers than the int type.

True

False

False

New cards
57

Java uses the ASCII character set to represent character data.

True

False

False

New cards
58

In Java, all floating point literals are assumed to be of type float.

True

False

False

New cards
59

The type of result produced by a mathematical expression depends on the types of the operands.

True

False

True

New cards
60

Promotion is a widening data conversion that is explicitly requested by the programmer.

True

False

False

New cards
61

____________________ is the automatic conversion between a primitive value and a corresponding wrapper object.

a.

Number formatting

b.

Autoboxing

c.

Aliasing

d.

Generating

e.

Static invocation

b. Autoboxing

New cards
62

Which of the following best describes what happens when an object no longer has any references pointing to it?

a.

The object is marked as garbage and its associated memory is freed when the garbage collector runs.

b.

The object is immediately deleted from memory.

c.

The object stays in memory for the remainder of the programs execution.

d.

The object is overwritten the next time the new operator is called.

e.

The object is overwritten the next time the new operator is called using the same class.

a. The object is marked as garbage and its associated memory is freed when the garbage collector runs.

New cards
63

When an object variable is declared but it is not assigned a value, it is called a ______________________.

a.

null reference

b.

static reference

c.

zero reference

d.

void reference

e.

empty reference

a. null reference

New cards
64

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);

New cards
65

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.

New cards
66

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.

New cards
67

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.

status = myAC.isOn

b.

status = myAC.isOn( );

c.

myAC.status();

d.

myAC.isOn()

b. status = myAC.isOn( );

New cards
68

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(72);

b.

myAC.setTemp( 72 );

c.

myAC.turnOn();

myAC.setTemp(72);

d.

myAc.setTemp(72);

b. myAC.setTemp( 72 );

New cards
69

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.

dateManager.printTodaysDate( );

b.

printTodaysDate();

c.

dateManager.printTodaysDate;

d.

dataManager.printTodaysDate();

a. dateManager.printTodaysDate( );

New cards
70

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.

printErrorDescription(14);

b.

printErrorDescription.logger(14);

c.

logger.printErrorDescription(14);

d.

printErrorDescription(14);

c. logger.printErrorDescription(14);

New cards
71

The ________________ operator is used to instantiate an object.

a.

static

b.

new

c.

+

d.

-

e.

none of the above

b. new

New cards
72

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.

dataTransmitter.sendSignal();

b.

dataTransmitter.sendSignal;

c.

sendSignal.dataTransmitter();

d.

dateTransmitter.sendSignal();

a. dataTransmitter.sendSignal();

New cards
73

A special method that is invoked to set up an object during instantiation is called a ___________________.

a.

destructor

b.

creator

c.

dot operator

d.

constructor

e.

new method

d. constructor

New cards
74

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

New cards
75

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;

New cards
76

Which of the following classes include the getCurrencyInstance() method?

a.

String

b.

NumberFormat

c.

DecimalFormat

d.

Math

e.

none of the above

b. NumberFormat

New cards
77

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);

New cards
78

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.

New cards
79

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();

New cards
80

Which of the following is a correct declaration of enumerated type for the suits of a deck of cards?

a.

enumerated type Suit = {hearts, spades, diamonds, clubs };

b.

enum Suit {hearts, spades, diamonds, clubs };

c.

enumerated type Suit = { hearts, spades, diamonds, clubs };

d.

enum Suit {hearts, spades, diamonds, clubs }

e.

enum Suit = { hearts, spades, diamonds, clubs }

d. enum Suit {hearts, spades, diamonds, clubs }

New cards
81

The System.out.printf() method is an alternative way to output information in Java.

True

False

True

New cards
82

Multiple reference variables can refer to the same object.

True

False

True

New cards
83

The new operator is used to access an objects methods.

True

False

False

New cards
84

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

New cards
85

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

New cards
86

String objects can be changed after instantiation.

True

False

False

New cards
87

All of the classes contained in the java.util package are automatically included in every Java program.

True

False

False

New cards
88

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

New cards
89

The Math class is part of the java.lang package.

True

False

True

New cards
90

Enumerated types allow a programmer to treat primitive data as objects.

True

False

False

New cards
91

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?

Program statements are executed linearly, with earlier statements being executed first

New cards
92

Which of the following best describes this code snippet?

if (count != 400)

System.out.println("Hello World!");

If the variable count is not equal to 400, "Hello World" will be printed.

New cards
93

Which of the following is not a valid relational operator in Java

<>

New cards
94

Let a and b be valid boolean expressions. Which of the following best describes the result of the expression a || b?

It will evaluate to false if a evaluates to false and b evaluates to false. It will evaluate to true otherwise

New cards
95

Which of the following expressions best represents the condition "if the grade is between 70 and 100"

if (75 < grade && grade < 100)

New cards
96

Which of the following logical operators has the highest precedence?

!

New cards
97

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?

Scanner inputFile = new Scanner(new File("input.txt"));

New cards
98

A _______________ loop always executes its loop body at least once.

do

New cards
99

What happens if a case in a switch statement does not end with a break statement?

The switch statement will execute the next case statement as well.

New cards
100

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?

if(stringOne.equals(stringTwo))

New cards
robot