Showing posts with label javafaq. Show all posts
Showing posts with label javafaq. Show all posts

Thursday, October 30, 2008

Why does it print 0??

Why does it print 0??

int i =0;
i = i++;
System.out.println(i);

Why does it print 0 and not 1???????



Answer is :

i = i++;(here doing the post increment which will be 1 after that line.but assigning on that line to i , which holds value "0")
So, the output is 0

Thursday, June 12, 2008

About Interface in Java

n the Java programming language, an interface is a reference type, similar to a class, that can contain only constants, method signatures, and nested types. There are no method bodies. interfaces cannot be instantiated—they can only be implemented by classes or extended by other interfaces.
An interface can contain constant declarations in addition to method declarations. All constant values defined in an interface are implicitly public, static, and final.

how Class.forName() works exactly?

Dynamic loading is one of the strongest features of java,is its ability to dynamically load code given
the name of the class to load, without having to know the actual classname until runtime.