Java – Part 12

Java – Part 11 Index    Java – Part 13
*Memory Allocation(primitive/object/array)

memoryallocation

*Object meta data => consists of the information about the object.

  1.  Class Pointer => a pointer to the class
  2.   Flags => state of object hash code etc.,
  3.   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.

  1. class pointer
  2. flags
  3. locks
  4. 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.

  1. Heap
    1. Method area
      1. Type information
      2. Constant pool
      3. Field information
      4. Method information
      5. Class variables
      6. Reference to class loader
      7. Method table
    2. PC registers
    3. Java stacks
    4. 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

  1. Instance variables
  2. Class variables
  3.  Local variables

*Operators

  1. Arithematic operators
  2. Relational operators
  3. Logical operators
  4. Assignment operators
  5. Increment/decrement operators
  6. Bitwise operators
  7. Conditional operators
  8. 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.

  1. public
  2. private
  3. 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

  1. break
  2. return
  3. System.exit()
  4. 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.

ThreadLive

*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
  • private

*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.

decimalhexa

Java – Part 11 Index    Java – Part 13

2 thoughts on “Java – Part 12

Leave a comment