Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
General <strong>Java</strong> Questions II<br />
public class Test {<br />
public static void main(String[] args) {<br />
Start s = new Start();<br />
}<br />
}<br />
Answer: Because you have included the return-type 'void' in the method declaration,<br />
it becomes a normal method, that just happens to have the same name as the class -<br />
so it won't get used as a constructor. Remove the 'void' and it should work.<br />
--<br />
Vince Bowdren<br />
P.S. by John: If you do not specifically define any constructors, the compiler inserts<br />
an invisible zero parameter constructor "behind the scenes". Often this is of only<br />
theoretical importance, but the important qualification is that you only get a default<br />
zero parameter constructor if you do not create any of your own.<br />
Your program used this zero parameter constructor and you saw nothing...<br />
Q: Why we can not declare constructor as final ?<br />
Answer: The keyword final when dealing with methods means the method cannot be<br />
overridden.<br />
Because constructors are never inherited and so will never have the oportunity to be<br />
overridden, final would have no meaning to a constructor.<br />
Q: In <strong>Java</strong>, does exist a function like sprintf in C ?<br />
Answer: http://www.efd.lth.se/~d93hb/java/printf/index.html a free <strong>Java</strong> version of<br />
fprintf(), printf() and sprintf() - hb.format package<br />
Q: If I declare an array of an objects, say Dogs, is that memory taken when I<br />
create the array or when I create the objects in the aray when I declare this array:<br />
Dog[] dog = new Dog[100];<br />
or does it take the memory when I actually create the Dogs in the array eg:<br />
for(int i = 0;i