Some of the java Interview Questions for the fresher and Experienced ( Set - 1 )

1. What is Java , speak something about Java ?

Ans: Basically few points has to be remembered regarding java :

a) Java is high level language.
b) Java is Compiled and Interpreted language.
c) Java is a Object-Oriented Language but not a pure Object-Oriented.
d) Java is Platform-Independent Language which makes language as Portable.
........ Click here to see more

If interviewer ask you to speak something about java then without any hesitation ,confidently go on explaining from very basic of java till OOPS concept. Still interview won't let you stop speaking then start explaining threading feature of java. But mostly they will let you cover all the basic things of java and then they start asking their next level of question.
You should speak about following points->
i> What is Java?
ii> OOPS features of Java.
iii> Explain in brief about each Oops features.

2. Is Java Platform Independent ? If yes then justify your answer ?

Ans: Yes , java is platform independent. As we know that java is compiled + interpreted language and .class file is the result of compilation and this file is going to be interpreted by JVM so we need JVM to execute this .class file and thus JVM has to be present and designed for each operating System like Windows , Unix etc.So due to the portability to .class file from a machine to another machine makes java platform independent.


3. What are the command for compiling and executing Java program ?

Ans: javac is a command for compiling java file will result in .class file
        java is a command for executing .class file.

4. What is Classpath in Java ?

Ans: Classpath in java means setting path for the .class files. Classpath is a command in java used for setting path for the .class file. Let suppose we have a .class file in a directory and we are currently at another location, now that .class file which is at different location so can be from another location but we need to set the path for the .class file using classpath command.
like this way, set classpath='......directorylocaltion....';

5. Who is the super class of all the Java classes ?

Ans: Object class is super class all the classes.

6. How many keywords does Java have , name few which you have used in your program?

Ans: Java has 50 keywords. Some of the commonly used keywords are :-

public    private     protected    static    final    new    synchronized    class   int   float   long  
byte       double   default     abstract      interface   for   if     import   package   instanceof  
native     return   super    this   strictfp    switch   throw    throws   try   catch   void   while  
transient   volatile   void    implements    goto      finally   enum   do   continue   const  
break    assert   else   short.
null   true   false  ( These 3 words are Reserved word ).

7. What is "this" in Java and what is its use ?

Ans: Few points about this has to be remembered :

a) At very first this is a keyword in java.
b) this points to the current object.
c) Although 'this' is not a variable so it cannot hold any other reference.
...........Click here to know more

Some of the used of "this" keyword -
a) 'this' is the simplest way to use instead of current object reference.
b) As it always points to the current object , so we can perform any task using 'this' for the current object.

8. What is "super" in Java and for what purpose super is being used in Java programs ?

Ans:  Few points about this has to be remembered :

a) At first 'super' is a keyword in java.
b) 'super' refers to the inherited member from super class to its sub-class.
...........Click here to know more

9. How "this" is different from "super" ?

Ans: Point of differences :

a) 'this' refers to the current object where as 'super' refers to the inherited member of the super class.
b) this() is used for constructor chaining where as super() is used for calling super class default constructor.

10. Is Java is pure-object oriented language and why ?

Ans: No java is not a pure-Objected Oriented Language.
Basically there are two strong reason by which we can conclude and say that java is not a pure- Object Oriented Language, they are-

a) Use of static will not involve any Object creation.
b) Use of primitive type. Although respective Wrapper class is there but still primitive is being used for many purposes.

11. Is Java supporting multiple inheritance and why ?

Ans: No java is not supporting Multiple inheritance directly but approached towards performing multiple inheritance using interfaces. There would lead to some issues if java is supporting multiple inheritance directly :
a) Memory wastage problem
b) Ambiguity Problem in calling methods.

12. Is pointer supported by Java and why?

Ans: Yes Pointer are supported by java but is fully abstract from the developer. It is internally implemented by the java vendor. It is not given at the developer level as because to make java secured. As we know that pointer directly goes to the memory address so there may have chance of security threat if pointer is allowed to implement in java.

13. What is the use of  "native" keyword in Java ?

Ans: 'native' is a keyword in java and are used with the method, which says, that method is implemented using some low level language. So if we have to implement something in low level language then we can use the 'native' keyword.

14. What is Constructor ?

Ans: Constructor is like a method but with no return type. Constructor has same name as the class name. It is used to initialize the  instance variable.
..........Click here to know more

15. What is the purpose of making main() as static ? 

Ans: Purpose of main() as static:
a) So that JVM need not to create any object to call main().
.............Clicl here to know more

16. Does Constructor return any value ? 

Ans: As constructor doesn't have any return type so it cannot return any value, bt we can write 'return' in the constructor as writing 'return' simply means returning the control to the caller.

17. What if we write simply "return" statement in constructor?

Ans: Nothing will happen it will simply return the control to the caller.

18. How may types of initialization blocks in java ?

Ans: There are two types of initialization block:
1. Static initialization block
2. Instance initialization block.

19. What is the use of introducing static initializing block in java ?

Ans: Static initialization block can be used for following purposes:

a) It can be used to initialize the final static variable.
b) It can be used to execute some other method before the main() method.
...............Click here to know more

20. What is the use and purpose of instance initialization block in java ?

Ans: Static initialization block can be used for following purposes:

a) It can be used to initialize the final instance variable.











3 comments:

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

Online Members

Live Traffic