Print
Category: Java
Hits: 541

 

Reflective = x ~ x

Transitive = x ~ y && y ~ z == x ~ z

Symmetric = x ~ y == y ~ x

Associative = (x ~ y) ~ z == x ~ (y ~ z)

 

2s Complement:

 

0101 0101 0101 0101 = 21845

1010 1010 1010 1010 = -21846

 

1s Complement:

0101 0101 0101 0101 = 21845

1010 1010 1010 1010 = -21845

 

Overriding – dynamic dispatch

Hiding – hide base class static function with empty function

Overloading – same function name different arguments

Shadowing – hide name of another type in another context

Obscuring – use same name for both variable and function

 

Instantiating BigDecimal with limited precision:

 

Create shared math context

    static MathContext mc = new MathContext(2, RoundingMode.HALF_UP);

Specify math context with all BigDecimal instantiation

 

 

Java 1.5 Enhancements:

Generics

Enhanced for loop - for (String s : map.values())

Autoboxing/Unboxing

Annotations

Varargs

java.util.concurrent.*

Arrays.deepToString (Returns a string representation of the "deep contents")

Integer.BitCount, rotateLeft, reverse…

Static Import

Typesafe Enums

 

Java 6 Enhancements:

Wildcard class path

Enhanced jConsole

 

Annotations:Modifier, three types: marker, single element, and multi-value.

 

Simple annotations: Override, Deprecated, Suppresssarnings.

 

Meta-Annotations: Target, Retention, Documented, Inherited.

 

@Target – define the targeted element in which the annotation is applicable.

ElementType.TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE.

@Retention – scope – RententionPolicy.SOURCE, CLASS, or RUNTIME.

@Documented – processed by javadoc.

 

Example:

for (Method m : Class.forName(args[0]).getMethods()) {

  if (m.isAnnotationPresent(Test.class)) {

    try {

      m.invoke(null);

      passed++;

    } catch (Throwable ex) {

      System.out.printf("Test %s failed: %s %n", m, ex.getCause());

      failed++;

    }

  }

}

 

 

J2EE services

XML- XSL and DOM

JDBC- Data Access

JSP and Servlet

JMS

EJB

JNDI & RMI- directory technology

 

 

AnalysisRequirements: Is it possible? Viable? Validation plan?

System-context: Use case and scenario, integration and synchronization.

Model: Classes and objects and associations.

 

DesignArchitectural: Physical, hardware and software.

Mechanistic: Sequence and collaboration.

Detailed: Classes. Activities and notations.

 

Development

ImplementationIntegration

Validation

Deployment

 

JDBC

 

Type 1  JDBC-ODBC Bridge

Type 2  Native API

Type 3  Middleware vendor API

Type 4  Pure Java

 

 

Container Types:

 

EJB container running on a JEE server manages execution of all EJBs.

Web container manages execution of JSP and servlet.

 

 

Non-function system requirements

 

Scalability

Security

Adaptability

Compatibility

Manageability

Availability

 

 

EAR file =

 

.war file + Enterprise Beans (Remote and Home interface classes) + JEE applications

 

 

Distributed applications

 

Pros

 

 

Cons

 

 

Hibernate

 

Pros

 

 

Cons

 

 

Garbage Collection

 

 

To make GC most effective

 

 

Types of Garbage Collectors