OCA Notes

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

import static can import static class .

static method can't access non-static variable and non static methods

main method cannot return types. it has to be void. if return is the case, then it
will throw and error at runtime

20.0 is NOT float. float has to have suffix f or cast it as float. Decimal pt
number is double by default

charAt() can take a char value as an argument> Yes, it can because it takes an int
and char will be implicitly promoted to int.

float can store negative value, it will be implicit widening conversion

no reverse() method in String class. only in StringBuilder

floating point cannot have suffix (d or f) while form of number is aside from
decimal

trim() only removes white space from front and end of string

b1 = i1 == i2 will be evaluated as b1 = (i1 == i2) because == has higher precedence


than =. Note: precedence is a thing

precedence of / and * is same (and is higher than + and -) and since the expression
is evaluated from left to right

////// A char value can ALWAYS be assigned to an int variable, since the int type
is wider than the char type.///

///char can store int variable but it HAS TO BE CONSTANT (final)

ABOUT SWITCH CASE


1.Every case constant expression associated with a switch statement must be
assignable to the type of the switch Expression.

2. No two of the case constant expressions associated with a switch statement may
have the same value.

3. 3. At most, one default label may be associated with the same switch statement.
(It is valid to not have default label at all.)

a byte's range is -128 to 127

long, float, double, and boolean can NEVER BE USED AS A SWITCH variable.

.subList(1,1) will return empty

in a for loop, ; ; ; is valid or ; ; i++ is valid, count it carefully though

When the return type of the overridden method (i.e. the method in the base/super
class) is a primitive, the return type of the overriding method (i.e. the method in
the sub class) must match the return type of the overridden method.

an abstract method cannot be overriden

default constructor takes no agument


there is no unsigned keyword in java

static meethods cannot be overriden (they are shadowed), same goes for private &
final methods. Abstract methods can be overriden.

a variable in main, can shadow the SAME variable (name) in global variable.

You might also like