QUESTION OF THE DAY

Which of the staements is true??


1 Garbage collection is platform dependent
2 You can suggest when garbage collection will run but cannot be certain when it will take
place
3 A reference to a primitive variable is eligable for garbage collection when it is set to null
4 The automatic garbage collection of the JVM prevents programs from ever running out
of memory

Ans in comments

Some Java Interview Questions

1. What is the diffrence between an Abstract class and Interface ?
2. What is user defined exception ?
3. What do you know about the garbate collector ?
4. What is the difference between C++ & Java ?
5. Explain RMI Architecture?
6. How do you communicate in between Applets & Servlets ?
7. What is the use of Servlets ?
8. What is JDBC? How do you connect to the Database ?
9. In an HTML form I have a Button which makes us to open another page in 15 seconds. How will do you that ?
10. What is the difference between Process and Threads ?
11. What is the difference between RMI & Corba ?
12. What are the services in RMI ?
13. How will you initialize an Applet ?
14. What is the order of method invocation in an Applet ?
15. When is update method called ?
16. How will you pass values from HTML page to the Servlet ?
17. Have you ever used HashTable and Dictionary ?
18. How will you communicate between two Applets ?
19. What are statements in JAVA ?
20. What is JAR file ?
21. What is JNI ?
22. What is the base class for all swing components ?
23. What is JFC ?
24. What is Difference between AWT and Swing ?
25. Considering notepad/IE or any other thing as process, What will happen if you start notepad or IE 3 times? Where 3 processes are started or 3 threads are started ?
26. How does thread synchronization occurs inside a monitor ?
27. How will you call an Applet using a Java Script function ?
28. Is there any tag in HTML to upload and download files ?
29. Why do you Canvas ?
30. How can you push data from an Applet to Servlet ?
31. What are 4 drivers available in JDBC ?
32. How you can know about drivers and database information ?
33. If you are truncated using JDBC, How can you know ..that how much data is truncated ?
34. And What situation , each of the 4 drivers used ?
35. How will you perform transaction using JDBC ?

FREE JAVA MATERIALS

see this site

http://www.freejavaguide.com/scjp1.htm

SINGLETON DESIGN PATTERN

Singelton design pattern is used where you want a single instance
of your class to be created through out your application,like if your
are working on any database connection application and you want
only a single connection to get created then you can use this pattern.
There are a few ways to implement this pattern.one of the
implementation way is given in above example.i think we should also
put the synchronize keyword in the method which is returning the
instance of class, to be thread safe.Other way to implement this
pattern is to make the constructor of class as private and all the
method as static.



Here is a code Snippet

public class MySingleton{
private static MySingleton s=null;
private MySingleton(){}
public static MySingleton getInstance()
{
synchronize(MySingleton.class)
{
if(s==null){s=new MySingleton();
}
}
return s;
}
}

JAVA CODE QUESTION

HOW TO CREATE AN OBJECT OF THE CLASS WITHOUT USING NEW OPERATOR

THE ANSWER IS GIVEN IN THE COMMENTS

MARCUS GREEN’S QUESTION OF THE DAY

Marcus question has a vast store of 320 questions which are posted on his site everyday

Each day only one question is posted

This is good for people doing SCJP

Here is the link

http://www.examulator.com/phezam/question.php

POINTS TO REMEMBER

• An exception which is not thrown in the "try" block (for example, thrown in a "catch" block) is

not handled by subsequent "catch" blocks, but will rather be sent to the caller of the method. Before

this happens, "finally" block is executed. Subsequent code after "finally" remains unreached if that

exception remains uncaught after the execution of "finally" block.
• If two or more interfaces declare a variable with the same name, then a class implementing these

interfaces cannot refer to that variable by its simple name as it leads to ambiguity (even if the values

of the variable is same in both the interfaces ). The ambiguity can be avoided by using fully qualified

names e.g. Interface1.varName and Interface2.varName.
• An object can be eligible for garbage collection even if there are references pointing to the object,

as long as the objects with the references are themselves eligible for garbage collection.
• The unary post-fix operators and all binary operators, except for assignment operators, associate

from left to right. All other operators associate from right to left.
• Floating point modulo (%) by zero produces NaN , but floating point divide by zero does not.
• Integer division truncates to the next lower integer value in the absolute sense, but division by right

shifting truncates to the next lower integer value in an algebraic sense. So, -7/2 == -3 but -7 >> 1 == -4.
• Native methods cannot be "abstract", or "strictfp".
• An abstract method cannot be static, final, synchronized, native, private, or strictfp.
• After a thread has started, it will continue to run even if its reference is set to null. A running thread

has a reference in a ThreadGroup even if your program does not retain one. Thus a running thread is

never garbage collected.
• A NullPointerException is thrown when an application attempts to use null in a case where an object

is required.
• A null reference may be used to access a static variable or method.

• A local class cannot have any access modifier.
• The "this" variable is not a normal reference variable that can be changed by statements like this = new A();

"this" cannot be used to refer to local variables.