programming language & alogirthm

Sunday, December 25, 2005

java interview questions

http://www.allapplabs.com/interview_questions/java_interview_questions.htm

Thursday, December 22, 2005

Princeton CS: datastructure & alogrithm class

http://www.cs.princeton.edu/courses/archive/fall02/cs226/index.html

Wednesday, December 14, 2005

http://www.bruceeckel.com/

Bruce Eckel (www.BruceEckel.com) is the author of Thinking in Java (Prentice-Hall, 1998, 2nd Edition, 2000, 3rd Edition, 2003, 4th Edition, 2005), the Hands-On Java Seminar CD ROM (available on the Web site), Thinking in C++ (PH 1995; 2nd edition 2000, Volume 2 with Chuck Allison, 2003), C++ Inside & Out (Osborne/McGraw-Hill 1993), among others. He's given hundreds of presentations throughout the world, published over 150 articles in numerous magazines, was a founding member of the ANSI/ISO C++ committee and speaks regularly at conferences. He provides public and private seminars & design consulting in C++ and Java.

Wednesday, December 07, 2005

java vs c++: String

Unlike C++, Java has a String type, and objects of this type are immutable (cannot be modified). Quoted strings are automatically converted into String objects.

Unlike C++, Java provides true arrays as first-class objects. There is a length member, which tells you how big the array is. An exception is thrown if you attempt to access an array out of bounds. All arrays are instantiated in dynamic memory and assignment of one array to another is allowed. However, when you make such an assignment, you simply have two references to the same array. Changing the value of an element in the array using one of the references changes the value insofar as both references are concerned.

java vs c++ (1) object hierarchy

All classes in Java ultimately inherit from the Object class. This is significantly different from C++ where it is possible to create inheritance trees that are completely unrelated to one another.

The interface keyword in Java is used to create the equivalence of an abstract base class containing only method declarations and constants. No variable data members or method definitions are allowed. (True abstract base classes can also be created in Java.) The interface concept is not supported by C++.

Java does not support multiple inheritance. To some extent, the interface feature provides the desirable features of multiple inheritance to a Java program without some of the underlying problems.

In addition to the access specifiers applied to individual members of a class, C++ allows you to provide an additional access specifier when inheriting from a class. This latter concept is not supported by Java.

Examples:
a stack implementation in java
public interface Stack {
public void Push(Object o );
public Object Pop();
}
c++:
class Stack{
public:
virtual void Push(object&)=0;
virtual Object& Pop()=0;
}
the risk of "virtual" inheritance:
deadly diamond of death

Saturday, December 03, 2005

Generic Programming in JDK1.5


http://java.sun.com/j2se/1.5.0/docs/guide/collections/index.html

A collection is an object that represents a group of objects
  • Reduces programming effort by providing useful data structures and algorithms so you don't have to write them yourself.
  • Increases performance by providing high-performance implementations of useful data structures and algorithms. Because the various implementations of each interface are interchangeable, programs can be easily tuned by switching implementations.
There are nine collection interfaces. The most basic interface is Collection. Five interfaces extend Collection: Set, List, SortedSet, Queue, and BlockingQueue. The other three collection interfaces, Map, SortedMap, and ConcurrentMap do not extend Collection, as they represent mappings rather than true collections.