Flashcards
Java - Lecture 2

Cards in this deck (36)
- 1Which Java features are the most important ones related to OOP?-Abstraction
-Encapsulation
-Inheritance
-Polymorphism - 2Keywords reserved in Java syntaxabstract
boolean
break
byte
case
catch
char
class
const
continue
default
do
double
else
extends
final
finally
float
for
goto
if
implements
import
instanceof
int
interface
long
native
new
package
private
protected
public
return
short
static
strictfp
super
switch
synchronized
this
throw
throws
transient
try
void
volatile
while - 3What are comments?- descriptions that are adopted to a program to make a code easier to understand
- compiler ignores comments & hence its only for documentation of the program - 4Block Style commentsbegin with /* & terminate with */ that spans multiple lines
- 5Line Style commentsbegin with //and terminate at the end of the line
- 6Documentation Stylebegin with /** and terminate with */
- 7Variablesused for data that changes during program execution
-> always have a name, type and scope
-> names assigned by programmer; names -> identifiers - 8Identifiersmust be unique within a scope of the Java program
- 9data typeindicates the kind of value a variable can store
- 10integerbyte, short, int, and long
- 11Floating pointfloat and double
- 12Characterchar
- 13Booleanvariable with a value of true or false
- 14byteDefault value: 0
Range: -127 to +128 - 15shortDefault value: 0
Range: -32768 to +32767 - 16intDefault value: 0
- 17longDefault value: 0L
- 18floatDefault value: 0.0f
- 19doubleDefault value: 0.0d
- 20charDefault value: '\u0000'
Range: 0 to 65535 - 21String objectDefault value: null
- 22What is an Object?instance of a class created using a new operator. The operator returns a reference to a new instance of a class. This reference can be assigned to a reference variable of the class.
THE PROCESS of creating objects from a class is called INSTANTIATION - 23What is an interface?it is a contract in the form of collection of method & constant declarations.
When a class implements an interface it promises to implement all of the methods declared in that interface. - 24Instance Members-each object will have its own copies of the fields defined in its class : called instance variables (represent an object in its state)
-The methods of an object define its behaviour called instance method. - 25Static Members-static variable: is initialized when the class is loaded
-static methods
--> static members can be accessed either by using the class name or by using the object reference - 26Assignment operators=
it has the following syntax:
=
if the value already exists in the variable it is overwritten by the assignment operator - 27Arithmetic operators- ; + ; * ; / ; % ; ++ ; --
subtraction , addition , multiplication , division , modulo ( remainder) , increment ( add 1), decrement (subtract 1) and negotiation - 28Relational operators-are used to compare 2 or more objects
greater than ( > )
less than ( < )
greater than or equal ( >= )
less than or equal ( <= )
equal ( == )
not equal ( != )
--> evaluation results in a boolean value
(lower that arithmetic operators but higher than assignemnt operators) - 29Logical Operators ( in text form )AND ( & )
conditional AND ( && )
OR ( | )
conditional OR ( | )
exclusive OR ( ^ )
NOT ( ! )
each argument to a logical operator must be a boolean data type and the result is always a boolean data type - 30Logical operators

- 31Bitwise Operators ( text form )Java provides Bit wise operators to manipulate the contents of variables at the bit level. These variables must be of numeric data type
(char, short, int, long)
- there are seven bitwise operators in Java
AND
OR
Exclusive OR
Complement
Left-shift
Signed Right-Shift
Unsigned Right-Shift - 32Bitwise Operators

- 33Compound Operatorsperform shortcuts in common programming operations (11 compound assignment operators in JAVA)
Syntax: argument + 1operator = argument 2
The above statement is the same as
argument1 = argument 1 operator argument2 - 34Conditional operators-only ternary operator ( takes 3 arguments)
-evaluates the first argument and if true evaluates the 2nd argument
-if the first argument evaluates to false, then the 3rd argument is evaluated
-conditional operator is the expression equivalent to the if-else statement
- conditional expression can be nested and the conditional operator associates from right to left :
(a?b?c?d:e:f:g) evaluates as
(a?(b?(c?d:e):f):g) - 35operators precedence ( in text form )-operators at the top of the table are applied before operators lower down in the table
- operators with the same precedence are applied from left to right - 36operators precedence

Information
- Description
- Object Oriented Programming Flashcards on Java - Lecture 2, created by dieollekrissi on 23/06/2014.
- Created by
- dieollekrissi
- Views
- 39
- Rating