Good Bye, Steve Job

I shocked when my colleague said Steve Job may gone. I feel very sad now when I know his death from news.

The most respectful person in this century, Steve Job, Good Bye.

珍惜所拥有

Facebook Timeline Showcase

My Facebook Profile recently updated with this new feature, called “Facebook Timeline”. It arranged my activities onto Timeline.

It is believed that this feature is now only available to certain group of people, such as Developer, and it will go live next Wednesday. Only Developer can see the other developer’s timeline, when the other people only can see the old profile.

The new thing is that I can set my cover photo in my Facebook Profile. I chose a very wonderful, memorable photo that I taken from Second Life.

I can easily navigated to the activities that I done in last month, last two months, or last last years, when I clicked the link at the top right side, Facebook will take me to the activities posted at that time period automatically using slide animation.

It provides another page to show ‘Activities Logs’, a very simple page showing activities list with the information and the time happened.

Java Certification Question (20111003)

Q1

QUESTION: What happens when you attempt to compile and run these two files in the same directory?

 

//File P1.java

package MyPackage;

class P1{

void afancymethod(){

System.out.println(“What a fancy method”);

}

}

//File P2.java

public class P2 extends P1{

public static void main(String argv[]){

P2 p2 = new P2();

p2.afancymethod();

}

}

 

A. Both compile and P2 outputs “What a fancy method” when run.

B. Neither will compile.

C. Both compile but P2 has an error at run time.

D. P1 compiles cleanly but P2 has an error at compile time.

Answer: D

Noticed that these two files said to be in the same directory, but second file didn’t have package declaration while first file have. Therefore, P2 will prompt error at compile time.

Q2

What will be the output of the following code?

 

public class Sample {

 

public String getCountryName(){

return “USA”;

}

 

public StringBuffer getCountryName(){

StringBuffer sb = new StringBuffer();

sb.append(“UK”);

return sb;

}

 

public static void main(String[] args){

Sample s = new Sample();

System.out.println(s.getCountryName().toString());

}

}

 

A. Compile with error

B. USA

C. UK

D. Runtime Exception

Answer: A.

Java allows overloading method, meant with same method name, but having different parameters. However, Java does not allow overloading method with different returned types if the parameter list is the same. Because you see, it is contradicted themselves.

Q3

What will be the result of attempting to compile and run the following code?

 

abstract class MineBase {

abstract void amethod();

static int i;

}

public class Mine extends MineBase {

public static void main(String argv[]){

int[] ar = new int[5];

for(i=0;i < ar.length;i++)

System.out.println(ar[i]);

}

}

 

A. A sequence of 5 0’s will be printed.

B. Error: ar is used before it is initialized.

C. Error: Mine must be declared abstract.

D. IndexOutOfBoundes Error

Answer: C.

The answer is C, Mine must be declared abstract, or Mine must implements the method abstract void method().

Java 8 geared up to cloud and its feature

Java SE 8 is geared up to the cloud. Multi-tenancy and modularity is featured.

Multi-tenancy is considered as one of the main components characteristics of cloud computing, as single instance of software application runs on the server but served multiple clients.

Modularity is reorganization of JDK into a set of clearly defined though interdependent modules.

Java 8 also decides to include C# / Scala’s Lambda style which worked pretty well in subjective measure. Java 7 should have Lambda but its construct is weird.

JSR TBD is included as language support for collections, where literal expressions for immutable lists, sets, and maps, and indexing-access syntax for lists and maps.

Below codes are possible when define a Set or List.

List<Integer> aListOfNumber = [1,2,3,4,7,2,4,6,7];

Set<Integer> aSetOfNumber = {1,5,34,45645,23};

Map<Integer, String> aHashMap = {5 : “fyhao”, 6 : “bmwjob”, 18 : “Singapore”};

Virtual extension method is included as providing default implementation for interface virtual methods. If you are not afford an implementation of method, one will providing you an implementation with no charge.

Sharing state often introduce complexity in concurrency programming. If the state is not shared, or said immutable state, it will not brought trouble because it has fixed input-output pair. Functional language comes with this benefit, but Java is not going to switch language but just adopt the principle functional language based on, seek to increase immutability and decrease sharing. Fork-join decomposition introduced in Java SE 7 to easily write algorithm that parallelized automatically across wide range of hardware configurations.