Values and Data Types Flashcards

1
Q

What is a character set?

A

A character set is a defined list of characters recognized by a language

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

What does a character set consist of?

A
  1. Alphabets: letters, A-Z, a-z
  2. Numerals: digits, 0-9
  3. Special characters: ?, %, }, >, @, etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the alphabets and numerals collectively known as?

A

The alphanumeric character set

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

Name two standard character sets

A

ASCII and Unicode

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

What does ASCII stand for?

A

American Standard Code for Information Exchange

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

What is ASCII?

A

It is a 7-bit set of codes that defines 128 different characters

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

What is the ASCII character set enough to represent?

A

It is enough to represent every uppercase letter, lowercase letter, digit, and special character used in the English Language keyboard.

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

What is Unicode?

A

It is an international character set designed to represent all the characters found in languages around the world, such as English, Hindi, Japanese, Chinese, French, Geman

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

How many bits can Unidode use to represent a character?

A

8 to 32 bits

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

Which character encoding does Java use?

A

The Unicode character coding

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

How is a specific Unicode character expressed?

A

By using the escape sequence ‘\u’ followed by its four digit hexadecimal code

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

What is the extended ASCII code?

A

It is an 8-bit character set that defines 256 different characters (2^8 = 256), including the standard 7-bit ASCII characters

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

What are tokens?

A

Tokens are the smallest individual units of a Java program. All characters in a Java program are grouped into symbols called tokens.

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

How many categories of tokens are in Java?

A
  1. Keywords
  2. Literals
  3. Operators
  4. Punctuators
  5. Identifiers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are keywords?

A

Keywords are the words that have a special meaning to the Java compiler

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

What is another name for keywords?

A

Reserved words

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

Why are keywords not available as names for variables or methods?

A

Java compiler reserves keywords for its own use, and hence they are not available

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

Which keywords are currently not used in Java?

A

goto and const

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

Name words you cannot use as variable names despite them not being keywords

A

true, false, null, literal values

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

What are identifiers?

A

They are fundamental building blocks of a program & are used to name different components of a program, such as variables, methods, and objects

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

What are the fundamental building blocks of a program?

A

Identifiers

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

What are Java identifiers naming conventions?

A
  1. An identifier can consist of any combination of letters, digits, underscore character, dollar sign
  2. It cannot begin with a digit
  3. It may be of any length
  4. Both uppercase and lowercase letters can be used in naming an identifier
  5. Java is case sensitive, which means that two identifier names that differ only in uppercase and lowercase characters are considered to be different identifiers
  6. An identifier cannot be a keyword or a boolean literal or a null literal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What are literals?

A

They are a sequence of characters that represent values in a program and are stored in variables. Literals are made out of digits, letters, and other characters

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

Name the types of literals Java supports

A
  1. Numeric -> Integer and Real
  2. Non Numeric -> Character and String
  3. Boolean
  4. Null
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What are numeric literals?

A

Values that may consist of digits (0-9), a decimal point (.), a positive (+) or negative (-) sign

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

Name the 2 types of numeric literals

A

Integer Literals

Real Literals

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

What are integer literals?

A

Values that represent whole numbers only. They can be positive or negative values.

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

What is not allowed in integer literals?

A

Space, comma, and a decimal point not allowed

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

Give another name for real literals

A

Floating-point literals

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

What are real literals?

A

They represent values with a decimal point

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

Name the two ways in which real literals can be written

A

In fractional or exponential form

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

How is a real literal in the fractional form written?

A

It consists of signed or unsigned digits, including a decimal point between the digits. Eg. - +233.06

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

How is a real literal in the exponential form written?

A

It consists of two components: mantissa and exponent. Eg. -> 7.04*10^34 can be written as 7.04E34

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

What is the mantissa?

A

Component before E, in a real literal in exponential form

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

What is the exponent?

A

Component after E, in a real literal in exponential form

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

What would make a real literal invalid in exponential form?

A
  1. No digit specified after E
  2. The exponent is not an integer value
  3. No digit before E
  4. Comma
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

What would make a real literal invalid in fractional form?

A
  1. No decimal point
  2. No digit after the decimal point
  3. No digit before the decimal point
  4. Two decimal points
  5. Comma
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

What are the two non-numeric literals?

A

Character literals

String literals

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

What are character literals?

A

Literals of this type represent exactly one character enclosed in single quotes

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

What are Boolean Literals?

A

The logical values true and false are the boolean literals

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

What do true and false represent during logical evaluation?

A

On/off, yes/no, presence/absence of something

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

What is the null literal?

A

This is a special kind of literal which is represented by the keyword null or escape sequence ‘\0’

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

What are punctuators?

A

Symbols used for grouping and separating the code

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

Give another name for punctuators

A

Separators

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

Name some punctuators

A

; , {} () [] .

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

What is the use of semicolon?

A

Used to separate statements

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

What is the use of comma?

A

Used to separate consecutive identifiers in a variable declaration

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

What is the use of {}?

A

Used to define a block of code in a Java program. They are also used to initialize the values of arrays

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

What is the use of ()?

A

Parenthesis is used to define methods. They are also used to define the precedence of operators in an expression and conditions in control structures

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

What is the use of []?

A

Used to declare arrays and refer to values at a particular index

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

What is the use of .?

A

The period operator in Java is used to access member variables and methods. It is also used to differentiate the package names from sub-packages and class names

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

What are operators?

A

Operators are symbols that are used to perform arithmetic or logical operations in a given expression.

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

Name the main categories of operators in Java

A
  1. Unary operators
  2. Assignment Operator
  3. Arithmetic Operators
  4. Relational Operators
  5. Increment/Decrement Operators
  6. Logical Operators
  7. Bitwise Operators
  8. Conditional/Ternary Operators
54
Q

What is an escape sequence?

A

It is a set of non-graphical characters that has a special meaning to the Java compiler.

55
Q

What is the structure of an escape sequence?

A

In an escape sequence, a character is preceded by a backslash ()

56
Q

What does the usage of the backslash result in?

A

When you print a certain character, the same character is displayed on the screen, but when it is prefixed with ‘', it is read as an escape sequence

57
Q

What is the use of escape sequence ‘\n’?

A

Inserts a new line in the text at this point (shifts control to next line)

58
Q

What is the use of escape sequence ‘\t’?

A

Inserts a tab in the text at this point

59
Q

What is the use of escape sequence ‘\’?

A

Inserts a backslash character in the text at this point

60
Q

What is the use of escape sequence ‘ " ‘?

A

Inserts a double quote character in the text at this point

61
Q

What is the use of escape sequence ‘ ' “?

A

Inserts a single quote character in the text at this point

62
Q

What is the use of escape sequence ‘\r’?

A

Inserts a carriage return in the text at this point (same as pressing the Enter key)

63
Q

What is the use of escape sequence ‘\?’?

A

Inserts a question mark in the text at this point

64
Q

What is the use of escape sequence ‘\a’?

A

Inserts an audible bell (beep sound)

65
Q

What is the use of escape sequence ‘\0’?

A

Represents a null character

66
Q

Name the two categories of data types

A

Primitive Data Types

Non-Primitive Data Types

67
Q

What are primitive data types?

A

The fundamental data types that are an integral part of the Java programming language

68
Q

Give other names for primitive data types

A

Intrinsic or built-in data types

69
Q

How many primitive data types are in Java?

A
  1. byte
  2. short
  3. int
  4. long
  5. char
  6. float
  7. double
  8. boolean
70
Q

What are non-primitive data types?

A

The data types that are derived from primitive data types are called non-primitive.

71
Q

Give other names for non-primitive data types

A

Reference types, composite data types, derived types

72
Q

How many non-primitive data types are in Java?

A

Classes, arrays, interfaces

73
Q

What are integer data types?

A

They are used to store whole numbers

74
Q

Which four categories are integer data types divided into?

A

byte, short, int, long

75
Q

What is the size of byte data type?

A

8 bits (1 byte)

76
Q

What is the size of the short data type?

A

16 bits (2 bytes)

77
Q

What is the size of the int data type?

A

32 bits (4 bytes)

78
Q

What is the size of the long data type?

A

64 bits (8 bytes)

79
Q

What is the range of byte data type?

A

-128 to 127 (-2^7 to 2^7 - 1)

80
Q

What is the range of short data type?

A

-32,768 to 32,767 (-2^7 to 2^7 - 1)

81
Q

What is the range of int data type?

A

-2 billion to +2 billion (approx.) (-2^31 to 2^31 - 1 )

82
Q

What is the range of long data type?

A

-9E18 to +9E18 (approx.) (-2^63 to 2^63 - 1)

83
Q

What can the floating-point data type be divided into?

A

Float and double data type

84
Q

What is the size of the float data type?

A

32 bits (4 bytes)

85
Q

What is the range of float data type?

A

1.4e—045 to 3.4e+038

86
Q

What is the precision of the float data type?

A

Up to 7 significant decimal digits

87
Q

What is the size of double data type?

A

64 bits (8 bytes)

88
Q

What is the range of double data type?

A

4.9e—324 to 1.8e+308

89
Q

What is the precision of double data type?

A

Up to 15 significant decimal digits

90
Q

What does the float data type store?

A

Low precision digits, such as temperature, salary, and percentage

91
Q

What does the double data type store?

A

High precision digits, such as scientific readings, the location of celestial bodies, and their distances.

92
Q

What is the default data type of floating-point literal?

A

double

93
Q

What do you need to do to designate a literal constant of the type float?

A

You must append the letter f or F. For eg., 6.7f or 6.7F

94
Q

What is the size of the data type char?

A

16 bits (2 bytes)

95
Q

What is the range of the data type char?

A

0-65535

96
Q

Name a data type that supports the Unicode character set

A

char data type

97
Q

What is the size of the boolean data type?

A

8 bits (1 byte) but uses only one bit

98
Q

What is the range of the boolean data type?

A

true or false

99
Q

Short description of boolean data type

A

Binary and boolean values

100
Q

What is a variable?

A

It is an identifier that denotes a location in computer memory to store a data value. The variable may take different values at different times during the execution of the program

101
Q

What is the condition for a variable to be used in a Java program?

A

It must be declared first

102
Q

What does the computer do when it encounters a variable declaration?

A
  1. Sets aside memory for the variable

2. Associates variable name with memory location

103
Q

Give the syntax of a simple variable declaration

A

data-type variable-name;

104
Q

What does variable initialization mean?

A

Assigning a value to the variable

105
Q

What is the default value of byte data type?

A

0

106
Q

What is the default value of short data type?

A

0

107
Q

What is the default value of int data type?

A

0

108
Q

What is the default value of long data type?

A

0L

109
Q

What is considered to be a good programming practice in case of declaration?

A

Not depending on the default value of the declared variable and initializing it instead

110
Q

What is the default value of float data type?

A

0.0f

111
Q

What is the default value of double data type?

A

0.0d

112
Q

What is the default value of char data type?

A

‘\u0000’

113
Q

What is the default value of boolean data type?

A

false

114
Q

What is the default value of non-primitive type?

A

null

115
Q

Which keyword is used to make the variable a constant?

A

final

116
Q

What does the modifier final do?

A

In Java, the modifier final can be used in the variable declaration to ensure that the value stored in the variable cannot be changed after the variable has been initialized

117
Q

What will the compiler show if an assignment operator tries to assign a value to a variable that has ‘final’ in front of it?

A

Syntax error

118
Q

What are the advantages of using constants?

A
  1. With an underscore, they improve the readability and understandability of the program
  2. Any unintentional changes to such variables are flagged by the compiler
  3. Later, if there is a change in the value of such a variable, you just need to modify its value at one place and all the occurrences will be taken care of automatically
119
Q

_ do not change their value; _ can change their value

A

Constants, variables

120
Q

What is the purpose of comments?

A

To document the code and provide additional information that is not readily available in it, so that even a layperson can understand the written code

121
Q

Where can comments not appear?

A

In the middle of an identifier, a reserved word or a literal constant

122
Q

Name the three styles of comments in Java

A
  1. Single Line Comment
  2. Multiline Comment
  3. Documentation Comment
123
Q

What is a single line comment?

A

It begins with a double slash (//) and continues to the end of the line

124
Q

What does the compiler do if it encounters a double slash?

A

It ignores any text following it

125
Q

What is a multiline comment?

A

It starts with initiating slash-asterisk (/) and ends with terminating asterisk-slash (/). There must be no space between the asterisk and the slash

126
Q

What is a documentation comment?

A

It is a special comment that looks like a multiline comment, but it is generally used to generate external documentation about the source code

127
Q

What does a documentation comment look like?

A

It starts with a forward slash followed by two asterisks (/**) and ends with an asterisk followed by a forward slash (*/)

128
Q

What is documentation comment also called?

A

Javadoc

129
Q

Name the points to remember while using comments

A
  1. Keep your comments clear and concise
  2. Arrange them in the code in an easy to see way
  3. Don’t make them too long or all over the statements
130
Q

What are constants?

A

Memory locations whose values cannot be changed

131
Q

Give another name for constants

A

Symbolic constants

132
Q

The ASCII codes of A-Z are represented by decimal range?

A

65-90