Select chapter



basics (7.papers)
constructors (1.papers)
packages (1.papers)
inheritance (7.papers)
misc (3.papers)
exceptions (5.papers)
threads (4.papers)
overloading (1.papers)
jsp (3.papers)
servlets (9.papers)
jdbc (2.papers)
util (1.papers)
xml (2.papers)
IO stream (3.papers)
Hide

Sponsored Links


  

java interview questions and answers

1
which of the below statements are false about java's local variables, instance variables, and class variables?
  1. a local variable declared in one function can be used in other functions of same class as well.
  2. an instance variable of a class can be used by all the functions of same class directly.
  3. a class variable declared in a class can be shared by all the objects of same class directly.
  4. all are true
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
3
In java, is it possible to have multiple public classes in one file?
  1. it is possible to have to multiple public classes in a file
  2. you should have only one class in a given file
  3. you should have only one public class in a file, but you can have n number of other non public classes in that file which is closely related with each other.
  4. all are true
Show Answer
Share Facebook gmail Twitter
4
which of the below statements are true about static members (class members) and this pointer?
  1. You can call constructor of a class from instance method (other than constructor) of same class directly using this() call.
  2. you can use this pointer in a static method of a class.
  3. you can use this pointer in an instance method of a class.
  4. I can call instance members of a class directly using class name from outside classes which doesn't inherit it.
Show Answer
Share Facebook gmail Twitter
5
How to access a static variable of a class?
  1. static variables can be accessed using class name from outside class.
  2. to get static variables of a class we have to create the object first for that class and access that variable with that object.
  3. option 1 is true only if that static variable is not private.
  4. option 2 is wrong if we try to do like that compiler will give error.
Show Answer
Share Facebook gmail Twitter
6
What is shadowing in java and Which of the below statement is true about shadowing concept?
  1. shadowing means having same name for local variables and instance variables.
  2. In such case local variables will be given high priority.
  3. to avoid shadowing effect we use this pointer.
  4. all are true
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
8
Where does your java code sit?
  1. stack
  2. heap
  3. data segment
  4. code segment
Show Answer
Share Facebook gmail Twitter
9
where does local variables sit?
  1. stack
  2. heap
  3. data segment
  4. code segment
Show Answer
Share Facebook gmail Twitter
10
which of the below statements are false about memory segments of java program?
  1. all static variables will sit in data segment
  2. all static function will sit in data segment
  3. all instance variables will sit in heap
  4. all objects created using new operator will also sit in heap.
Show Answer
Share Facebook gmail Twitter
11
which is of the below statements are false about variables of java?
  1. local variable - any variable declared in function level or in a block is called as local variable.
  2. instance variable - any variable declared in class level which is not static is called as instance variable.
  3. class or static variable - any variable declared in class level and which is static is called as class or static variable.
  4. global variable - any variable declared outside the class is called as global variable.
Show Answer
Share Facebook gmail Twitter
12
which is false in java, related to local variables?
  1. local static variables are allowed in java
  2. local static variables are not allowed in java
  3. local inner classes are not possible in java.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
17
Which is true about a member of a class?
  1. A class can have instance members or class members
  2. instance variable & instance method are instance members
  3. static variables & static methods are class members.
  4. all are true
Show Answer
Share Facebook gmail Twitter
18
Where to use static variables? Or what is the use of static variables?
  1. Generally we use static keyword along with final variables.
  2. We use static variables if we want to share a variable among all the objects of a class.
  3. both option 1 & 2 are correct
  4. none are true
Show Answer
Share Facebook gmail Twitter
19
which of the below statements are false about class members or static members?
  1. I can access instance variables, instance methods, and class variables from an instance method of the same class directly.
  2. I can access a static variable and a static method from a static method of the same class directly.
  3. I can access a static method from an instance method of same class directly.
  4. I can access instance method from a static method of same class directly.
Show Answer
Share Facebook gmail Twitter
20
What is data abstraction or data hiding in java?
  1. Abstraction means hiding unwanted details and showing what is wanted. By applying private access modifiers to data members of a class, we will hide the internal implementation details of the data. Thus we achieve data abstraction or data hiding (implementation hiding).
  2. Hiding data in database is called as data hiding.
  3. Implementing encapsulation in java is called as data hiding.
Show Answer
Share Facebook gmail Twitter
Read more papers :