Back To Normal

Subscribe To Our E-Mail Newsletter

Monday, August 13, 2012

Java : Test Automation Questions and Answers


Couch ModePrint It

1. String Immutable
The absolutely most important reason that String is immutable is that it is used by the
class loading mechanism, and thus have profound and fundamental security aspects.

Had String been mutable, a request to load "java.io.Writer" could have been changed to load
"vijay.co.DiskErasingWriter"
Details: http://javarevisited.blogspot.in/2010/10/why-string-is-immutable-in-java.html

2. Two main mehod in single class

Ans : Its possible with different retun type and parameters (method overloading )
3. String Memory allocation vs StringBuffer vs String Builders

String sname ='vijay';

sname ='ragavan';
Details: http://javarevisited.blogspot.in/2011/07/string-vs-stringbuffer-vs-stringbuilder.html

5. Usage of Interface
Often interfaces are touted as an alternative to multiple class inheritance. While
interfaces may solve similar problems, interface and multiple class inheritance are quite
different animals, in particular:
A class inherits only constants from an interface.
A class cannot inherit method implementations from an interface.
The interface hierarchy is independent of the class hierarchy. Classes that implement the
same interface may or may not be related through the class hierarchy. This is not true for
multiple inheritance.

Usage of Interfaces :
You use an interface to define a protocol of behavior that can be implemented by any class
anywhere in the class hierarchy. Interfaces are useful for the following:
Capturing similarities between unrelated classes without artificially forcing a class relationship
Declaring methods that one or more classes are expected to implement
Revealing an object's programming interface without revealing its class. (Objects such as these are called anonymous objects and can be useful when shipping a package of classes to other developers.)
6. Garbage collector in java and usage.
Java takes a different approach; it handles deallocation for you automatically. The technique that accomplishes this is called garbage collection. It works like this: when no references to an object exist, that object is assumed to be no longer needed, and the memory occupied by the object can be reclaimed.
The finalize( ) Method
Sometimes an object will need to perform some action when it is destroyed. For example, if
an object is holding some non-Java resource such as a file handle or window character font,
then you might want to make sure these resources are freed before an object is destroyed

Keyword: System.gc();

Click Here For Smileys :D
:D
:)
:[
;)
:D
:O
(6)
(A)
:'(
:|
:o)
8)
(K)
(M)

No comments:

560 Free Online Courses

Top 200 universities launched 500 free online courses.  Please find the list here .