Java – Part 11 Index Java – Part 13
*Memory Allocation(primitive/object/array)
*Object meta data => consists of the information about the object.
- Class Pointer => a pointer to the class
- Flags => state of object hash code etc.,
- Locks => Synchronization locks.
*Array Object => this is also a kind of object, but its having one more additional meta data info i.e., the size of the array.
- class pointer
- flags
- locks
- size
*For single valued primitive data types arrays are expensive in terms of memory.
*The data in the string object is the array of characters.
*Runtime Data Areas.
- Heap
- Method area
- Type information
- Constant pool
- Field information
- Method information
- Class variables
- Reference to class loader
- Method table
- PC registers
- Java stacks
- Native method stacks
*Decimal integer => 0->9
*Octal integer => 0->7 ==>prefixed with ‘0’
*Hexadecimal integer =>0->F(A-10,B-11,C-12,D-13,E-14,F-15) ==>prefixed with ox/oX
*Real constants may not have digits before & after the decimal points(.)
*215.65 ==> 2.1565@2 ==> 2.1565E2 ==>Mantissa @ Exponent
*Mantissa =>real/integer
*Exponent =>real optional +/-
*Embeded whitespace is not allowed in any numeric constant.
*Escape Sequences (total 8)==> b, f, n, r, t, \, “, /
*We can make integers long by appending “l” or “L” to the end of the numbers.
*Floating point are by default double we can make it float by appending “F” or “f”
*Floating point support “NAN“.
*All keywords are lower type strings.
*3 types of variables
- Instance variables
- Class variables
- Local variables
*Operators
- Arithematic operators
- Relational operators
- Logical operators
- Assignment operators
- Increment/decrement operators
- Bitwise operators
- Conditional operators
- Special operators.
*Bitwise operators may not be applied to float & double.
*Bitwise, Bitwise shift, one’s complement operators work only on “integer” types.
*Access Specifiers.
- public
- private
- protected.
*Method arguments treated as local variable & will be having only one specifier “final”
*class with abstract and without abstract methods ==>ok
*class without abstract and with abstract methods ==>not ok.
*synchronized, native applied only to the methods.
*strictfp applied only to the class, methods[IEEE754] =>not dependent on platform.
*Constructors can’t be static, final and abstract.
*char assigned to any integer type larger than “short”.
*transient and volatile can be applied only to instance variables.
*Enum can only be declared public/default like inner class.
*In Switch, case constant must be compile time constant.
*You need to have only one “test expression” in the for loop.
*continue should be used in loop only.
*Force exit of a program
- break
- return
- System.exit()
- Exception
*Labelled continue & break statements must be inside the loop that has the same label name otherwise the code won’t compile.
*The Thread is considered to be alive after its call to start() method.
*We can’t tell one thread to block another thread.
*suspend(), resume(), stop() ==>deprecated, better not to use.
*yield() method won’t ever cause a Thread to go to the waiting/sleeping/blocking state, yield() method causes the thread to go from running to runnable.
*wait(), notify(), notifyAll() must be called from within a synchronized context.
*You can’t put access specifiers to local variables, only you can put final for local variables.
*variables can be
- final
- transient
- abstract
- static
- synchronized
- native
- private
- public
- protected
*Classes can be
- public
- abstract
- final
- strictfp
*Methods can be
- public
- protected
- private
- final
- static
- synchronized
*Instance variables
- public
- protected
- private
- final
- transient
- static
- volatile
*static can be given to methods, variables, top level nested classes.
*You can’t specify the size when declaring the anonymous array.
*Divide by zero(0)
- /0 => Integers ->runtime exception
- /0 => Floats => +ve/-ve infinite.
*remainder operator(%) result in ArithmeticException if right operand is zero
*Identifiers must start with a letter a currency character($) or a connecting character(_)
*There is no limit to the number of characters an identifier can contain. Identifiers are case sensitive.
*All interface methods are implicitly public & abstract.
*All variables defined within the interfaces are public static final.
*Interface methods must not be static.
*Interface methods can’t be
- final
- static
- strictfp
- native
*Outside the package can’t use a super class reference to access a protected member. For subclass outside the package the protected member can be accessed only through inheritance.
*It is never legal to include the size of the array in the declaration eg., int [5] scores;
*abstract methods can’t be
*final reference variable must be initialized before the constructor completes
*static members doesn’t have the direct access to non-static members.
*An enum declared outside the classes can’t be marked
- static
- final
- abstract
- private
- protected
*octal , hexa , decimal and binary representations.
Java – Part 11 Index Java – Part 13