I my interview experience, I have met variety of candidates. Those who understand programming, and those who can just make the things work( with their fingers crossed).
If you think you are first kind, or want to be first kind please go ahead, else you don’t need to be here. You are probably doing good being second kind. I mean no disrespect.
First of all I want you to answer some questions in Java. Personally I haven’t found who could answer all three.
Q1) If I have a file abc.java and I want to write two classes in it so which one of the pattern is fine.
public class abc1
public class abc2
public class abc 1
class abc 2
Anything will work
None will work because …..
Q2) What are meaning of each keyword in this line:
public static void main( String args )
Which probably all can tell. But what I aim to ask is why is that keyword required here.
Q3) All notice there is int and Integer. Why did designers bothered to write something like that.
I request you to jot down your answers before proceeding and be true to yourself.
Ans 1) Answer is case 5, and because a file abc.java should have only one public class only with the name abc. There can be multiple classes but none other can be public in that file.
Ans 2) public: It means the function can be called outside the class. This is needed because main is called from outside class.
static: What it means we all know. Why we do that so that we do not call constructor of class before main itself. So main is the first code to be executed.
void: All know
main: An anchor to call.
String args: Array of environment variables and can be changed to Stringa for gods sake. Please don’t ever miss this one.
Ans 3) Please read my blog on argument passing, section Java.