Introduction to Java Programming Flashcards
It marks the beginning of a comment
//
Is associated with the beginning of the class definition. All of the programming statements that are part of the class are enclosed in this.
{}
Marks the beginning of a single line comment
// //(Double slash)
Marks the beginning of a multiple line comment
/* */
Used in a method header
{ } (Opening and closing braces)
Encloses a string of characters, such as a message that is to be printed on the screen
” “ (Quotation marks)
Marks the end of a complete programming statement
; (Semicolon)
Is part of the Java API. It has member objects and methods for performing system-level operations, such as sending output to the console.
The System class
is a member of the System class. It provides methods for sending output to the screen.
The out object
are members of the out object. They actually perform the work of writing characters on the screen.
The print and println methods
It displays output on the screen and does not advance the cursor to the next line after its message is displayed
print method
It displays its message, it advances the cursor to the beginning of the next line
println method
Advances the cursor to the next line for subsequent printing
\n (Newline)
Causes the cursor to skip over to the next tab stop
\t (Horizontal tab)
Inserts a backspace into the text at this point.
\b (Backspace)
Causes the cursor to go to the beginning of the current line not the next line
\r (Return)
Causes a backslash to be printed
\ (Backslash)
Causes a single quotation mark to be printed
\’ (Single quote)
A punctuation mark used in a method header.
\“(Double quote)
Types of programming error
Syntax error, Runtime error, Logical error
It is also called parsing errors
Syntax error
It occurs at compile time in traditional programming languages and at interpret time in interpreter
Syntax error
Any violation of rules and poor understanding of the programming language results to this error.
Syntax error
It is also called exceptions occur during execution (after compilation/ interpretation).
Runtime error
Some examples are, dividing by zero error, insufficient memory for dynamic memory allocation, referencing out-of-range array element.
Runtime error
These are not detected by com-piler while compilation process.
Runtime error
The most difficult type of errors to track down.
Logical error
They occur when you make a mistake in the logic that drives your program and you do not get the result you expected.
Logical error
These errors occur due to incorrect translation of algorithm into the program, poor understanding of the problem and a lack of clarity of hierarchy of operators
Logical error
It is a programmer-defined name that represents some element of a program
Identifiers
Examples of Identifiers
Variable names and class names
Beginning an identifier with a lowercase letter and capitalizing subsequent words within the identifier is a style known as ____?
Camel Casing
describes the type of data that can be stored there, how much memory the item occupies, and what types of operations can be performed on the data.
The Data Type
Integers in the range of −128 to +127
byte
(1 byte)
Integers in the range of −32,768 to +32,767
short
(2 byte)
Integers in the range of −2,147,483,648 to +2,147,483,647
int
(4 byte)
Integers (−9,223,372,036,854,775,808 to +9,223,372,036,854,775,807)
long
(8 byte)
Floating-point numbers in the range of ±3.4 × 10−³⁸ to ±3.4 × 10³⁸, with 7 digits of accuracy
float
(4 byte)
Floating-point numbers in the range of ±1.7 × 10−³⁰⁸ to ±1.7 × 10³⁰⁸, with 15 digits of accuracy
double
(8 byte)
can hold single character only
char
(2 byte)
can hold boolean value which is true or false
boolean
(1 bit)
is a statement that reserves a named memory location
Variable Declaration
It includes byte, short, int and long datatype.
The integer Data Types
The floating-point numbers include fractional values and whole number.
The Floating-point Data Types
is used to store characters.
The char Data Type
can hold one character at a time.
The char Data Type
Character literals are enclosed in single quotation marks.
The char Data Type
Every character have an equivalent number based in ASCII code.
The char Data Type
Characters are internally represented by numbers. Each printable character, as well as many non-printable characters, is assigned a unique number.
Unicode
How many bytes does the Unicode require for memory?
two bytes
lets you manually convert a value, even if it means that a narrowing conversion will take place.
Type Casting
are unary operators that appear as a data type name enclosed in a set of parentheses.
Type Casting
This line is known as a method header. It marks the beginning of a method.
public static void main(String[] args)
Can be thought of as a group of one or more programming statements that collectively has a name.
Method
When you declare a variable but do not assign a value to it.
Uninitialized Variable
An uninitialized variable contains an unknown value called?
Garbage Value
When the + operator is used with strings (“hello” + “world”) it is called the?
String Concatenation Operator
Means to append
Concatenate
When the + operator is used with two numbers as operand the + sign will be used as?
Operator Strings
How many bytes and bits in one byte?
1 byte, 8 bits
How many bytes in short?
2 bytes
How many bytes in int?
4 bytes
How many bytes in long?
8 bytes
How many bytes in float?
4
How many bytes in double?
8 bytes
How many bytes in char?
2 bytes
How many bits in boolean?
1 bit