Friday, December 29, 2006

1)Do you know in java Programming when constructor are given return type then it acts as a normal function.And if static keyword is given before constructor then while compiling it ask for return type.If we give return type before static keyword then it acts like normal functions. 2)In every program we use public static void main but instead of that if we use public static void mian .That is instead of main we misspell as mian Do you know what will happen.Most of them will think it will not compile and execute.But this is not true.It will compile and generate error when it try to execute it.Reason is while it executes JVM start searching for main and as main is not present it generates error. 3)Anyone of you know How to find the size of object.And people will think as there is no sizeof operator in java we can't find.But this is not true.We can find the size of object with the class name Runtime.we have get the size by the using the code Runtime r= Runtime.getRuntime(); before and after the creation of the new objects you can check the memeory and by subtraction you can get the memory like sizeof operator in C. 4)how to write a Java application without a main methodclass MainMethodNot{static{System.out.println("Hello Java");System.exit(0);}}As there is no main method you will think how the program will compile and execute.But it will do.When it find static keyword it enter in the loop and print Hello Java and before JVM find main method it there is exit command and it terminates before searching main. 5)Do you konw in JVM there are 3 things.First is class Loader.Second is class Verifier.Third is Java Interpreter.class Loader loads the dot class file(.class) which contains bytecode and byte code means it doesnot have one's and zero format rather than bytecode is in form of assembly language. class verifier checks for errors and java Interpreter converts machine independent code to machine dependent code.And when we try to execute with keywordjava filename.the java invokes JVM and class Loader and the file is loaded in RAM.

0 Comments:

Post a Comment

<< Home