Wednesday, August 27, 2008

There's a lot happening at Department of Computer Science, University of Delhi, when you talk about interesting tech-seminars taking place.Recently, we had a talk on "Open Source : How we already use it" by Aadhar Mittal, our new Sun Campus Ambassador. It was an introduction to Open Source, much needed for the new batch. He started by giving some insights on Open Source and gave examples from daily life that how we already make use of so much Open Source Software(OSS) without knowing about it. He talked about advantages of OSS and told how big companies like Sun mint money from their OSS. It was an eye opener for the first years since it was their first talk. I'm sure he's going to blog about it pretty soon and put up some nice pics....:-)

Now, the big one. Today, we also had a great lecture by Prof. Christelle Schraff, Pace University, New York on "Towards 'More' Correct Software". She talked about various phases of SDLC giving emphasis on testing. She also gave a short demo on JUnit (she used it in Eclipse) but the same can be done with NetBeans too. She also talked about Java Assertions and showed us the Rational Functional Testing Tool but it was too slow on her machine. She talked in brief about formal methods like theorem proving and about some of her open source projects. It was definitely an interesting seminar with the students getting lucky enough to get a chance to meet and interact with professors of her status.

Sunday, August 17, 2008

Based on my exposure and experience with the language, I have listed some important Java(Core) questions that I think can be asked in any interview related to Java. I'm not listing the answers with them over here, but that does not mean that I do not know them :))The only reason for not writing answers here, is that it would unnecessarily increase the length of the entry, but if you have doubts in any question, you can ask me in the comments section or can mail me.

Questions

Ques. 1 What makes Java Portable?(The answer can spark discussion of things like Bytecode, VM so be clear with your concepts)

Ques. 2 List some features of Java that are not present in C++(List 5-6 main features that makes the language more powerful)

Ques. 3 Is Java Slow as compared to C/C++?(Google over it if you do not know or ask me)

Ques. 4 Differentiate between JDK. JRE and JVM.(Ok, read this link and you are through) :-)

Ques. 5 How are interfaces different from Abstract Classes.(Pretty simple one)

Ques. 6 List major OOPS principles and tell how each can be implemented using Java.(simple & still Frequently asked)

Ques. 7 Parameter passing in Java.(may be this can help.......it can be indirectly asked by giving a piece of code)

Ques. 8 How many classes can you have in 1 .java file?? How many of them can be public ? Why so ?(if you do not know this, its high time you clear your basic concepts)

Ques. 9 Is Java a compiled language or interpreted language ??(Ans: It is both compiled & interpreted. You need to explain in detail the conversion(compilation) of .java file into .class file(s) using javac and then execution(interpretation) of the .class file by the JVM)

Ques. 16 Which version of Java have you worked on ? What are the different versions of Java ? How they differ from each other ??(Tough one if you don't know it. At least remember 2 or 3 main points of differences between Java 4, 5 & 6 such as with Java 5 new features such as Auto-boxing, variable arguments, co-variant returns (in overriding) but you also need to know what they mean. Explaining them here would require another blog post)

Ques. 17 Tell how many different types of variables are possible in Java.(Tricky! Talk about Local Variables, Instance Variables & Class Variables)

Ques. 18 What are immutable objects? Give an example of immutable object in Java.(Hint: Eg is String objects are immutable...rest you have to find it your way)

Ques. 19 What is Serialization ? How it can be implemented in Java.(If you can answer this in an interview, they would seriously consider you as not many ppl can answer this so read about it & talk about the concept first and then talk abt Serializable interface)

Friday, August 15, 2008

Although most books on Java(except a few good ones) will beg to differ and say that "In Java, primitives are passed by value and objects by references"But, this is not true. Or you can say that it is 50% true.Because, even Objects when passed as parameters to a method are passed by value !!Hard to Digest !!But it is TRUE. This is not to say that changes are not reflected back when objects are passed to a method.

Actually what happens when you try and pass an object as a parameter is that the bit representation of the actual parameter(lets say the address of the actual object on the heap) is COPIED to the formal parameter. So at this time both references are pointing to the same object on the heap and thus any changes made to it are reflected back in the calling code.A proficient C programmer is not akin to this concept as it works in C exactly the same way.

Try out the following program to understand how parameter passing works in Java.class myClass{ int val;

Third line says that the value of object ob has not changed after passing it to a method and making changes there.This happened because objects ob and o are different entities and changing o (the reference) bit pattern (the address) by creating a new object won't affect ob in any way.

The bottom line on pass-by-value : Java is actually pass-by-value for all variables running within a single VM(virtual machine).