8:17 pm - Saturday April 20, 2019

Basic Interview Question3

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

31.What is the difference between static and non-static variables?


A static variable is associated with the class as a whole rather than with specific instances of a class.

Non-static variables take on unique values with each object instance.

32. What is the difference between a while statement and a do statement?


A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.

33. Does Java provide any construct to find out the size of an object?


No there is not sizeof operator in Java. So there is not direct way to determine the size of an object directly in Java.


34. What are pass by reference and passby value?

Pass By Reference means the passing the address itself rather than passing the value. Passby Value means passing a copy of the value to be passed.

35. What is an Iterator?

Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator.

36. Declaration of access specifier and access modifiers :

Class – Public, Abstract, Final

Inner Class – Public, Protected, Private, Final, Static,

Anonymous – Public, Protected, Private, Static

Variable – Public, Protected, Private, Final, Static, Transient, Volatile, Native

Method – Public, Protected, Private, Final, Abstract, Static, Native, Synchronized

Constructor – Public, Protected, Private

Free-floating code block – Static, Synchronized.

37. What is an abstract class?


Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is

abstract may not be instantiated (ie, you may not call its constructor), abstract class may contain

static data. Any class with an abstract method is automatically abstract itself, and must be declared as

such.A class may be declared abstract even if it has no abstract methods. This prevents it from being


38.What is static in java?


Static means one per class, not one for each object no matter how many instance of a class might

exist. This means that you can use them without creating an instance of a class. Static methods are

implicitly final, because overriding is done based on the type of the object, and static methods are

attached to a class, not an object. A static method in a superclass can be shadowed by another static

method in a subclass, as long as the original method was not declared final. However, you can’t

override a static method with a nonstatic method. In other words, you can’t change a static method

into an instance method in a subclass.

39. What is final?


A final class can’t be extended ie., final class may not be subclassed. A final method can’t be

overridden when its class is inherited. You can’t change value of a final variable (is a constant).

Filed in: Z-A Interview Questions

No comments yet.

Leave a Reply