Module 1 (Prelim) Flashcards

1.1 Overview 1.2 Comparing Procedural and Object Oriented Programming Concepts 1.3 Creating Java 1.4 Using Data 1.5 Arithmetic Operators 1.6 Understanding Type Conversion

1
Q

Sets of operations executed in sequence

A

Procedural programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Named computer memory locations that hold values

A

Variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Two popular approaches to writing computer programs are

A
  • procedural programming
  • object-oriented programming
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Individual operations grouped into logical units

A

Procedures

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

is an extension of procedural programming in which you take a slightly different approach to writing computer programs.

A

Object-Oriented Programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Writing object-oriented programs involves: (3)

A
  • Creating classes, which are blueprints for objects
  • Creating objects, which are specific instances of those classes
  • Creating applications that manipulate or use those objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Understanding object-oriented programming requires grasping three basic concepts:

A
  • Encapsulation as it applies to classes as objects
  • Inheritance
  • Polymorphism
  • Abstraction (just in case)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

a term that describes a group or collection of objects with common properties.

A

Class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

describes what attributes its objects will have and what those objects will be able to do.

A

class definition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

are the characteristics that define an object; they are PROPERTIES of the object.

A

Attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

An ___________ is a specific, concrete INSTANCE of a class.

A

object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Creating an instance is called _______

A

instantiation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

is a set of written instructions that tells the computer what to do

A

Computer Program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Machine language is a ___________ programming language

A

low-level

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

allows you to use a vocabulary of reasonable terms

A

high-level programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

set of rules for the language

A

syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

translates language statements into machine code

A

compiler/interpreter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

misuse / misspelled programming language

A

syntax error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

freeing program from errors

A

debugging

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Understanding Classes, Objects, and Encapsulation:
Which stands for class, object, and properties for the example below?

Dog:
Breed:
Gender and age:

A

Dog: class
Breed: object
Gender and age: properties

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

The values of the properties of an object are referred to as the object’s ___________

A

state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Besides defining properties, classes define ___________ their objects can use.

A

methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

is a self-contained block of program code that carries out some action, similar to a procedure in a procedural program.

A

method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

if objects are similar to nouns, then methods are similar to verbs. (True or False)

A

T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

In object-oriented classes, attributes and methods are encapsulated into _________

A) class
B) objects
C) properties

A

B) objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Encapsulation refers to two closely related object-oriented notions:

A
  • Encapsulation is the enclosure of data and methods within an object.
  • Encapsulation also refers to the concealment of an object’s data and methods from outside sources.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

is the enclosure of data and methods within an object.

A

Encapsulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

allows you to treat all of an object’s methods and data as a single entity. Just as an actual dog contains all of its attributes and abilities, so would a program’s Dog object.

A

Encapsulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

also refers to the concealment of an object’s data and methods from outside sources.

A

Encapsulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

lets you hide specific object attributes and methods from outside sources and provides the security that keeps data and methods safe from inadvertent changes.

A

Encapsulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Concealing data is sometimes called _________, and concealing how methods work is _________

A
  • information hiding
  • implementation hiding.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

the ability to create classes that share the attributes and methods of existing classes, but with more specific features.

A

inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

means “many forms”—it describes the feature of languages that allows the same word or symbol to be interpreted correctly in different situations based on the context.

A

polymorphism

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

In a GUI application, it is convenient to remember one method name, such as _________or _________, and have it work correctly no matter what type of object you are modifying.

A

setColor
setHeight

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Define a Java class using any name or _________

A

identifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

Requirements for identifiers: (5)

A
  • Must begin with one of the following:
    * Letter of the English alphabet
    * Non-English letter (such as α or π)
    * Underscore
    * Dollar sign
  • Cannot begin with a digit
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Identifiers can only contain: (4)

A

Letters
Digits
Underscores
Dollar signs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

Single-line comments in Java ________

A) starts with //
B) starts with /* and ends with */
C) starts with #
D) starts with // and ends with //

A

A) starts with //

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

Multi-line comments in Java ________

A) starts with //
B) starts with /* and ends with */
C) starts with #
D) starts with // and ends with //

A

B) starts with /* and ends with */

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

Identifiers can be a Java reserved keyword
(True or False)

A

F

Cannot be a Java reserved keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

The line “public class ClassName” is the __________ in the program structure below:

public class ClassName
{
public static void main(String[] args)
{
Statement(s);
}
}

A) class definition/ class header
B) main method header
C) body of the main method
D) access specifier
E) keyword that defines ClassName as class
F) name of the class

A

A) class definition/ class header

42
Q

The line “ public static void main(String[] args) “ is the __________ in the program structure below:

public class ClassName
{
public static void main(String[] args)
{
Statement(s);
}
}

A) class definition/ class header
B) main method header
C) body of the main method
D) access specifier
E) keyword that defines ClassName as class
F) name of the class

A

B) main method header

43
Q

The line “ Statement(s); “ is the __________ in the program structure below:

public class ClassName
{
public static void main(String[] args)
{
Statement(s);
}
}

A) class definition/ class header
B) main method header
C) body of the main method
D) access specifier
E) keyword that defines ClassName as class
F) name of the class

A

C) body of the main method

44
Q

defines the circumstances under which a class can be accessed and the other classes that have the right to use a class.

A

access specifier

45
Q

is the most liberal type of access specifier.

A

Public access

46
Q

The term “public” in “public class ClassName” is the __________ in the program structure below:

public class ClassName
{
public static void main(String[] args)
{
Statement(s);
}
}

A) class definition/ class header
B) main method header
C) body of the main method
D) access specifier
E) keyword that defines ClassName as class
F) name of the class

A

D) access specifier

47
Q

The term “class” in “public class ClassName” is the __________ in the program structure below:

public class ClassName
{
public static void main(String[] args)
{
Statement(s);
}
}

A) class definition/ class header
B) main method header
C) body of the main method
D) access specifier
E) keyword that defines ClassName as class
F) name of the class

A

E) keyword that defines ClassName as class

48
Q

The term “ClassName” in “public class ClassName” is the __________ in the program structure below:

public class ClassName
{
public static void main(String[] args)
{
Statement(s);
}
}

A) class definition/ class header
B) main method header
C) body of the main method
D) access specifier
E) keyword that defines ClassName as class
F) name of the class

A

F) name of the class

49
Q

static is a reserved keyword (True of False)

A

T

50
Q

Means the method is accessible and usable even though no objects of the class exist

A

static

51
Q

void is used in the class header
(True of False)

A

F

void is used in the main() main method header

52
Q

Does not indicate the main() method is empty

A

void

53
Q

Indicates the main() method does not return a value when called

A

void

54
Q

Does not mean that main() doesn’t produce output

A

void

55
Q

The “First Java Application” in “System.out.println(“First Java Application”);” is the __________ in the program structure below:

public class ClassName
{
public static void main(String[] args)
{
System.out.println(“First Java Application”);
}
}

A) property of System class
B) class
C) literal string that is the argument to the method
D) method

A

C) literal string that is the argument to the method

56
Q

Method names are always followed by:

A) ()
B) []
C) “”

A

A) ()

57
Q

Every java statements ends with a ______

A

;

semi-colon

58
Q

The term “System” in “System.out.println(“First Java Application”);” is the __________ in the program structure below:

public class ClassName
{
public static void main(String[] args)
{
System.out.println(“First Java Application”);
}
}

A) property of System class
B) class
C) literal string that is the argument to the method
D) method

A

B) class

59
Q

The term “out” in “System.out.println(“First Java Application”);” is the __________ in the program structure below:

public class ClassName
{
public static void main(String[] args)
{
System.out.println(“First Java Application”);
}
}

A) property of System class
B) class
C) literal string that is the argument to the method
D) method

A

A) property of System class

60
Q

The term “println” in “System.out.println(“First Java Application”);” is the __________ in the program structure below:

public class ClassName
{
public static void main(String[] args)
{
System.out.println(“First Java Application”);
}
}

A) property of System class
B) class
C) literal string that is the argument to the method
D) method

A

D) method

61
Q

Save the java class in a file with exactly the same name and __________ extension

A

.java

62
Q

Compiling a Java Class: (3)

A
  • Compile the source code into bytecode
  • Translate the bytecode into executable statements using a Java interpreter
  • Type javac First.java
63
Q

To run a java application from the command line, type __________

A

java FileName

64
Q

when its value cannot be changed while a program is running.

A

constant

65
Q

How to declare named constant:

A

final datatype NAME = value;

66
Q
  • is a named memory location
  • Used to store a value
  • Can hold only one value at a time
  • Its value can change
A

Variable

67
Q

How to declare a variable:

A

datatype varName = value;

68
Q

What is the correct order of the java primitive data types:

short
char
long
float
byte
boolean
int
double

A

byte
short
int
long
float
double
char
boolean

69
Q

Boolean values:

A

True or False

70
Q

Which among these java primitive data types belongs to the integer data types:

byte
short
int
long
float
double
char
boolean

A

byte
short
int
long

71
Q

What are the boolean data types: (6)

A

<
>
==
<=
>=
!=

72
Q

Is a data type that holds any single character

A

char

73
Q

are written between double quotation marks

A

String constants

74
Q
  • A built-in class
  • Stores and manipulates character strings
A

String

75
Q

Constant character values are placed within ________ quotation marks

A

single

76
Q

Begins with a backslash followed by a character and represents a single nonprinting character

A

Escape sequence

77
Q

Escape sequences: (7)

A

\b
\t
\n
\r
"
'
\

78
Q

also called semantic errors

A

logical errors

79
Q

Scanner class makes System.in more flexible (True or False)

A

T

80
Q

Import statement for the Scanner class:

A

import java.util.Scanner;
or
import java.util.*;

81
Q

How to create a Scanner object:

A

Scanner inputDevice = new Scanner(System.in);

82
Q

Scanner breaks input into units called _______; a set of characters that is separated from the next set by whitespace.

A

tokens

83
Q

Scanner class methods: (8)

A

nextDouble()
nextInt()
nextLine()
next()
nextShort()
nextByte()
nextFloat()
nextLong()

84
Q

Arithmetic Operators: (5)

A

*
/
%

85
Q

Two types of division:

A

Integer division
Floating-point division

86
Q

Involves when either or both of the operands are floating-point values. The result is double.

A) Integer division
B) Division
C) Floating-point division

A

C) Floating-point division

87
Q

Involves integer constants or integer variables. The result is an integer and any fractional part of the result is lost.

A) Integer division
B) Division
C) Floating-point division

A

A) Integer division

88
Q

The _______ of an operator controls the order of evaluation of expressions involving the same operator, for example: 3 / 4 / 5

A

associativity

89
Q

Associativity can be:

A
  • left-to-right: the leftmost operator is applied first.
  • Right-to-left: the rightmost operator is applied first.
90
Q

A high precedence means an operator is evaluated (applied) before any lower precedence operators. (True or False)

A

T

91
Q

Which among the choices are of higher precedence in java?

A) + -
B) * /
C) %
D) * / %

A

D) * / %

92
Q

Which among the choices are of lower precedence in java?

A) + -
B) * /
C) %
D) * / %

A

A) + -

93
Q

The type to which all operands in an expression are converted for compatibility

A

Unifying type

94
Q

Order for establishing unifying types between two variables (highest to lowest):

long
double
int
float

A

double
float
long
int

95
Q

Forces a value of one data type to be used as a value of another data type

A

Type casting

96
Q

Using a cast operator is an _______

A

explicit conversion

97
Q

Place desired result type in parentheses

A

Cast operator

98
Q

allows programmers to write instructions in a language that is easier to understand than low-level languages.

A

High-level Programming Language

99
Q

corresponds closely to a computer processor’s circuitry (0s and 1s) are used to write programs that relate to the specific architecture and hardware of a particular type of computer.

A

Low-level Programming Language

100
Q

The program may run but provide inaccurate output

A

Logic errors