Module 2: Basic Elements of Java Flashcards

1
Q

Are user-defined names for methods, variables, constants, and classes

A

Identifiers

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

Rules in Naming Identifiers

A
  1. The first character of your identifier should start with a letter of the alphabet, an underscore (_), or a dollar sign ($).
  2. Identifier must contain no spaces.
  3. Identifier must contain no special characters.
  4. Keywords are Reserved words, thus it should not be used as Identifier
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Create identifiers that are _____.

A

descriptive of their purpose

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

If your identifier is composed of several words (65,535 characters is the maximum length per identifier), _____ is a good programming practice.

A

capitalizing the first letter of each word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  • Specify the different sizes and values that can be stored in the variable variable
  • Defines the values that a variable can take
A

Data Types

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

Two Types of Data Types

A
  1. Primitive Data Type

2. Reference Data Type (Non-Primitive Data Type)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  • The building blocks of data manipulation.

- Basic data types available in Java language.

A

Primitive Data Type

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

Include Classes, Interfaces, and Arrays

A

Reference Data Type (Non-Primitive Data Type)

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

8 Primitive Data Types

A
  1. boolean
  2. byte
  3. char
  4. short
  5. int
  6. long
  7. float
  8. double
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Primitive Data Type:

true or false

A

boolean

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

Primitive Data Type:

two’s (2) compliment integer

A

byte, short, int, and long

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

Primitive Data Type:

unicode character

A

char

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

Primitive Data Type:

IEEE 754 floating point

A

float and double

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

Default value of boolean

A

false

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

Default value of byte

A

0

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

Default value of char

A

\u0000

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

Default value of short

A

0

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

Default value of int

A

0

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

Default value of long

A

0

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

Default value of float

A

0.0

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

Default value of double

A

0.0

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

Range of Values of boolean

A

true, false

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

Range of Values of byte

A

-128 to 127

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

Range of Values of char

A

Character representation of ASCII values 0 to 255

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

Range of Values of short

A

-32,768 to 32,767

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

Range of Values of int

A

-2,147,483,648 to 2,147,483,647

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

Range of Values of long

A

-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

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

Range of Values of float

A

up to 7 decimal digits

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

Range of Values of double

A

up to 16 decimal degits

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

Are identifiers whose values can be changed

A

Variables

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

The general syntax for declaring a variable is:

A

;

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

To declare a variable with an initial value, the syntax is:

A

=;

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

Are identifiers whose values never change once declared

A

Constants

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

The general syntax for declaring constants is:

A

final = ;

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

The process of assigning a value or variable of a specific type to a variable of another type

A

Type Casting

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

Type Casting is a method or process that _____ into _____ in both ways manually and automatically.

A

converts a data type; another data type

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

The _____ is done by the compiler and _____ performed by the programmer

A

automatic conversion; manual conversion

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

Two Types of Castings

A
  1. Widening Type Casting

2. Narrowing Type Casting

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

Converting a lower data type into a higher one

A

Widening Type Casting

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

Widening Type Casting is also known as _____

A

Implicit Conversion or Casting Down

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

Converting a higher data type into a lower one

A

Narrowing Type Casting

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

Narrowing Type Casting is also known as _____

A

Explicit Conversion or Casting Up

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

If we do not perform casting in Narrowing Type Casting then the compiler reports a _____.

A

compile-time error

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

In the case of Narrowing Type Casting, the higher data types (having larger size) are converted into lower data types (having smaller size). Hence there is the _____. This is why this type of conversion does not happen automatically.

A

loss of data

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

Are symbols that perform logical or mathematical functions on operands such as variables, constants, and objects

A

Operators

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

Java divides the operators into the following groups:

A
  • Arithmetic
  • Unary
  • Shorthand Assignment
  • Relational/Comparison
  • Logical/Conditional
  • Bitwise
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

Are used to perform common mathematical operations

A

Arithmetic Operators

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

Are used to increasing or decreasing the value of an operand

A

Unary Arithmetic Operators

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

Adds 1 to the value of a variable

A

Increment Operator

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

Decreases 1 from a value of a variable.

A

Decrement Operator

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

Symbol for Pre-increment

A

++a

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

Symbol for Pre-decrement

A

–a

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

Symbol for Post-increment

A

a++

54
Q

Symbol for Post-decrement

A

a–

55
Q

Add 1 to the value of a first then use the value of a

A

Pre-increment

56
Q

Subtract 1 to the value of a first then use the value of a

A

Pre-decrement

57
Q

Use first the value of a then add 1 to its value

A

Post-increment

58
Q

Use first the value of a then subtract 1 to its value

A

Post-decrement

59
Q

This operator can be used to connect Arithmetic operator with an Assignment operator

A

Shorthand Assignment Operators

60
Q

Assignment with Addition

A

+=

61
Q

Assignment with Subtraction

A

-=

62
Q

Assignment with Multiplication

A

*=

63
Q

Assignment with Division

A

/=

64
Q

Assignment with Modulus

A

%=

65
Q

Equivalent Expression for +=

A

a = a + 20

Example: a+= 20

66
Q

Equivalent Expression for -=

A

z = z - w++

Example: z -= w++

67
Q

Equivalent Expression for *=

A

d = d * k

Example: d *= k

68
Q

Equivalent Expression for /=

A

y = y / 1

Example: y /= n+1

69
Q

Equivalent Expression for %=

A

x = x % y

Example: x %= y

70
Q

Are used to compare two values

A

Relational/Comparison Operators

71
Q

Comparison Operators are mainly used when applying _____ in the program

A

control statements

72
Q

The output of the relational operator is _____, and in Java, _____ is a non-numeric value that is not related to zero or one

A

(true/false) boolean value; true or false

73
Q

Are those operators which are used to form compound conditions by combining two or more conditions or relations

A

Logical/Conditional Operators

74
Q

Logical/Conditional Operators is also called _____.

A

Boolean Logical Operators

75
Q

Logical/Conditional Operators operates on two Boolean values, which return _____.

A

Boolean values as a result

76
Q

Symbol for Logical NOT

A

!

77
Q

Symbol for Logical OR

A

||

78
Q

Symbol for Logical AND

A

&&

79
Q

Is a Unary Operator, it operates on single operands. It reverses the value of operands, if the value is true, then it gives false, and if it is false, then it gives true

A

Logical NOT

80
Q

Is only evaluated as true when one of
its operands evaluates true. If either or both expressions
evaluate to true, then the result is true

A

Logical OR Operator

81
Q

If both operands are true then only “______”

evaluate true

A

Logical AND Operator

82
Q

Negates the value of the operand

A

The NOT! (!) Operator

83
Q

Operator is a binary operator that returns true if at least one of its operands is true

A

The OR (||) Operator

84
Q

Is a binary operator that returns true only when both operands are true. Otherwise, it
will return false

A

The AND (&&) Operator

85
Q

Is a binary operator that returns true when both operands have different values.
Otherwise, it will return false

A

Bitwise Exclusive OR or XOR (^) Operator

86
Q

Determines the order in which the operators in an expression are evaluated.

A

Operator Precendence

87
Q

Operators with _____ are evaluated _____.

A

higher precedence; before operators with lower precedence

88
Q

Precedence of Postfix

A

expr++ | expr– | ( )

89
Q

Precedence of Unary

A

++ expr | –expr | ! | ~

90
Q

Precedence of Multiplicative

A
  • / %
91
Q

Precedence of Additive

A

+ -

92
Q

Precedence of Relational

A

< > <= >=

instanceof

93
Q

Precedence of Equality

A

== !=

94
Q

Precedence of Bitwise XOR

A
95
Q

Precedence of Logical AND

A

&&

96
Q

Precedence of Logical OR

A

||

97
Q

Precedence of Ternary

A

? :

98
Q

Precedence of Assignment

A

= += -= *= /= %=

99
Q

The operands of operators are evaluated from

A

left to right

100
Q

Every operand of an operator (except the conditional operators &&, ||, and ? :) are evaluated completely _____ any part of the operation itself is performed

A

before

101
Q

The _____ are evaluated completely before any part of the

_____ is evaluated

A

left-hand operand of a binary operator; right-hand operand

102
Q

_____ get’s preference over _____.

A

Order of evaluation given by parenthesis (); operator precedence

103
Q

The _____ evaluates the incremented value while _____ evaluates the current value, then increments/decrements by one

A

prefix version of ++ or –; postfix version of ++ or –

104
Q

_____ are evaluated from left to right except _____.

A

All binary operators; assignment operator

105
Q

Use to print a string literal on the same line

A

Print Method

106
Q

The position of the cursor remains on _____ after a string literal is printed on the monitor

A

the same line

107
Q

The _____ are written continuously without a break.

A

string literals

108
Q

Use to print a string literal on the next line

A

println Method

109
Q

A character preceded by a backslash () is an _____ and has special meaning
to the compiler

A

escape sequence

110
Q

Escape Character:

  • Inserts a tab
A

\t

111
Q

Escape Character:

  • Inserts a backspace
A

\b

112
Q

Escape Character:

  • Inserts a new line
A

\n

113
Q

Escape Character:

  • Carriage return
A

\r

114
Q

Escape Character:

  • Form feed
A

\f

115
Q

Escape Character:

  • Inserts a single quote
A

'

116
Q

Escape Character:

  • Inserts a double quote
A

"

117
Q

Escape Character:

  • Inserts a backslash
A

\

118
Q

Is widely used to parse text for strings and primitive types using a
regular expression.

A

Java Scanner class

119
Q

The _____ is used to _____, and it is found in the java.util package

A

Scanner class; get user input

120
Q

By the help of _____ in Java, we can get input from the user in primitive types such as int, long, double, byte, float, short, etc.

A

Scanner

121
Q

Reads a boolean value from the user

A

nextBoolean()

122
Q

Reads a byte value from the user

A

nextByte()

123
Q

Reads a double value from the user

A

nextDouble()

124
Q

Reads a float value from the user

A

nextFloat()

125
Q

Reads a int value from the user

A

nextInt()

126
Q

Reads a String value from the user

A

nextLine()

127
Q

Reads a long value from the user

A

nextLong()

128
Q

Reads a short value from the user

A

nextShort()

129
Q

What is the maximum length of of characters per identifier?

A

65,535

130
Q

Java Keywords

A
abstract
char
double
for
instanceof
private
strictfp
throws
boolean
class
else
goto
interface
protected
super
transient
break
const
extends
if
long
public
switch
try
byte
continue
final
implements
naive
return
synchronized
void
case
default
finally
import
new
short
this
volatile
catch
do
float
int
package
static
throw
while