Values and Data Types Flashcards
What is a character set?
A character set is a defined list of characters recognized by a language
What does a character set consist of?
- Alphabets: letters, A-Z, a-z
- Numerals: digits, 0-9
- Special characters: ?, %, }, >, @, etc.
What are the alphabets and numerals collectively known as?
The alphanumeric character set
Name two standard character sets
ASCII and Unicode
What does ASCII stand for?
American Standard Code for Information Exchange
What is ASCII?
It is a 7-bit set of codes that defines 128 different characters
What is the ASCII character set enough to represent?
It is enough to represent every uppercase letter, lowercase letter, digit, and special character used in the English Language keyboard.
What is Unicode?
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 many bits can Unidode use to represent a character?
8 to 32 bits
Which character encoding does Java use?
The Unicode character coding
How is a specific Unicode character expressed?
By using the escape sequence ‘\u’ followed by its four digit hexadecimal code
What is the extended ASCII code?
It is an 8-bit character set that defines 256 different characters (2^8 = 256), including the standard 7-bit ASCII characters
What are tokens?
Tokens are the smallest individual units of a Java program. All characters in a Java program are grouped into symbols called tokens.
How many categories of tokens are in Java?
- Keywords
- Literals
- Operators
- Punctuators
- Identifiers
What are keywords?
Keywords are the words that have a special meaning to the Java compiler
What is another name for keywords?
Reserved words
Why are keywords not available as names for variables or methods?
Java compiler reserves keywords for its own use, and hence they are not available
Which keywords are currently not used in Java?
goto and const
Name words you cannot use as variable names despite them not being keywords
true, false, null, literal values
What are identifiers?
They are fundamental building blocks of a program & are used to name different components of a program, such as variables, methods, and objects
What are the fundamental building blocks of a program?
Identifiers
What are Java identifiers naming conventions?
- An identifier can consist of any combination of letters, digits, underscore character, dollar sign
- It cannot begin with a digit
- It may be of any length
- Both uppercase and lowercase letters can be used in naming an identifier
- Java is case sensitive, which means that two identifier names that differ only in uppercase and lowercase characters are considered to be different identifiers
- An identifier cannot be a keyword or a boolean literal or a null literal
What are literals?
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
Name the types of literals Java supports
- Numeric -> Integer and Real
- Non Numeric -> Character and String
- Boolean
- Null
What are numeric literals?
Values that may consist of digits (0-9), a decimal point (.), a positive (+) or negative (-) sign
Name the 2 types of numeric literals
Integer Literals
Real Literals
What are integer literals?
Values that represent whole numbers only. They can be positive or negative values.
What is not allowed in integer literals?
Space, comma, and a decimal point not allowed
Give another name for real literals
Floating-point literals
What are real literals?
They represent values with a decimal point
Name the two ways in which real literals can be written
In fractional or exponential form
How is a real literal in the fractional form written?
It consists of signed or unsigned digits, including a decimal point between the digits. Eg. - +233.06
How is a real literal in the exponential form written?
It consists of two components: mantissa and exponent. Eg. -> 7.04*10^34 can be written as 7.04E34
What is the mantissa?
Component before E, in a real literal in exponential form
What is the exponent?
Component after E, in a real literal in exponential form
What would make a real literal invalid in exponential form?
- No digit specified after E
- The exponent is not an integer value
- No digit before E
- Comma
What would make a real literal invalid in fractional form?
- No decimal point
- No digit after the decimal point
- No digit before the decimal point
- Two decimal points
- Comma
What are the two non-numeric literals?
Character literals
String literals
What are character literals?
Literals of this type represent exactly one character enclosed in single quotes
What are Boolean Literals?
The logical values true and false are the boolean literals
What do true and false represent during logical evaluation?
On/off, yes/no, presence/absence of something
What is the null literal?
This is a special kind of literal which is represented by the keyword null or escape sequence ‘\0’
What are punctuators?
Symbols used for grouping and separating the code
Give another name for punctuators
Separators
Name some punctuators
; , {} () [] .
What is the use of semicolon?
Used to separate statements
What is the use of comma?
Used to separate consecutive identifiers in a variable declaration
What is the use of {}?
Used to define a block of code in a Java program. They are also used to initialize the values of arrays
What is the use of ()?
Parenthesis is used to define methods. They are also used to define the precedence of operators in an expression and conditions in control structures
What is the use of []?
Used to declare arrays and refer to values at a particular index
What is the use of .?
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
What are operators?
Operators are symbols that are used to perform arithmetic or logical operations in a given expression.