Some SCJP Notes
Java Rules
class level variables are inited to default values
&& or ||
are called Short circuit because
they do not evaluate the next expression if the condtion is false
array length is 0 based
String length is 1 based
**SWITCH CASE
ALL *case* statements,
that are palced after the first case statment that evalautes to
*true* , will evaluates to true
i.e
switch (i)
{
case 1 :
case 2:
// assume this evalutes //to true
case 3:
case default :
//evalautes to // true
}
1) -source 1.4 to enable assertions
2) assert :false makes disables assertiosn at runtime
3) The assertion statement is defined in the form of Expression1 : Expression2; where Expression1 is a boolean expression and Expression2 is an expression that has a value
4)Assertion are not to be used for argument checking in public methods as it is typically part of the published specifications of a method, and these specifications must be obeyed whether or not assertions are enabled or disabled.
It is aslo not be used do any work that your application requires for correct operation.
5) Switch can use only short and INT
!!!!!EXAM WATCH
ONE LINE statments after WHILE or FOR
!!!!!!!!EXAM WATCH
SWITCH inside a (WHILE or FOR) that does NOT use the LOOP counter
6) Local variable get stored on the stack ,Other objects on the STACK
7) An object is can garbage colelcted When an object becomes unreachable by any code NOT JUST OUT OF SCOPE because there can be objects in the outer loop that could be referecing it .
!!EXAM WATCH
all primitives are a java keywords
String is an OBJECT and is not a keyword.
!!Exam watch
double cant be used with << opertor
9 )if you yeald a thread it is stopped and goes into ready state
10) you can not start a dead thread
!! EXAM WATCH ....
SHORT does not have a declararion such as
Short k = 35 S ; /// S ??? where did youget that
7) inteface def constants must public static and final
all methods of the if needs to be declared by the NOn abstract class.
8)default type of decimal in java is double
9) benefit of encapslation is to that the implementation of a class can be changed without breaking code that uses it.
10) + and - are unary operators
11) use left to right eval for ++ -- opertators .
12) Objective of oops is encapsulation, inheritance, polymorphism
!!!EXAM WATCH
An unsigned right shift >>> by a smaller positive amount (< total of bits of type) of a
small negative number will result in a large positive number.
!!!EXAM WATCH
While assigning one type to the other the value should be in range and the precision of the type should not be lost.
Precision includes sign and decimals.
!!!EXAM WATCH
Construction of a sub class whose Parent Does Not have a Public-Default-Constructor.
CompileTime Error
13) The default contstructors modifier is the same as the access to the class
14) Transient and Static Vaiable are not Serializable
15) String Class overrides the equals menthod. StringBuffer does NOT.
15) Constructors and Static methods can not be overridden
16) Static and private methods do not participate in polymorphism .
Private - > Not Accessible .Static -> Can not be overriden
17) The constructor of the base class is executed first.
18) writing your own DEFAULT CONSTRRUCTOR has NO EFFECT.
19) Nested classes can not be transient.
20) Strangely enough you can define an inner class in an interface.
e.g
interface IFace {
public class X { //It is not member inner class
void method_Of_X() {
System.out.println("Without static modifier, it is still static nested class.");
}
}
21) anonymous class has one and only one constructor.
You cannot explicitly define constructors for anonymous class, but compiler generates
an constructor for it with the same signature as its parent constructor called.
22) Evaluations in java is from left to right . Beware of the i++ and the ++i operators.
23) Math class and Arrays are not serialzeable
24) Class level variables are inited to default values
25)
&& or ||
are called Short circuit because
they do not evaluate the next expression if the condtion is false
26)Length of strings and arrays are 1 based and the array indexes satrt from 0.
!!!EXAM WATCH
**SWITCH CASE
ALL *case* statements,
that are palced after the first case statment that evalautes to
*true* , will evaluates to true
i.e
switch (i)
{
case 1 :
case 2:
// assume this evalutes //to true
case 3:
case default :
//evalautes to // true
}
0 comments:
Post a Comment