Tuesday, December 5, 2006

Questions for getting knowlwdge in Java conti......

16.)Can a reference variable of an interfece holds the address of an object of a class that implements that interface
Example
class X implements Y
{
//Method Implementations of Interface
public static void main(String args[])
{
Y y=new X();
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Yes. reference variable of an interfece holds the address of an object of a class that implements that interface


17.)Explain the advantages of OOPs with the examples.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The main advantage of using OOPs is that it supports Inheritance.Inheritance is the process of acquiring the properties and methods from one entity to another entity
Other advantages are abstraction(data hiding) and polymorphism.

ENCAPSULATION: It is the data binds together code and the data it manipulates and keeps them safe from outside interference and misuse. When data and code are linked together in this fashion, an object is created. In other words an object is the device that supports encapsulation.
POLYMORPHISM: The name itself suggests that “POLY” stands for many and “MORPHISM” stands for forms. Polymorphism is the quality that allows one name to be used for two or more related but technically different purposes. In general giving multiple interfaces to a function or an operator is called “POLYMORPHISM”.INHERITANCE: Inheritance is the process by which one object can acquire the properties of another. The best example for this is C,C++, and JAVA languages itself. Java is being derived from C++ which in return is being derived from C from where it inherits all the capabilities of C,C++ and also add the features of its own.


18.) difference between data abstraction vs encapsulation
----------------------------------------------------------------------------------------------------------------------------------------------------------------

Abstraction is achieved through encapsulation. Abstraction solves the problem in the design side while encapsulation is the implementation.
In Short Abstraction is "Collection of data" and Encapsulation is "Exposure (or grouping) of data in appropriate access specifier".


19.)difference between class and object?


Class is like a template where as object is the implementation of the template. By using the same we can have any no .of implementations

Class is the blueprint to construct a building. object is the physical constructed building . we can construct any no .of buildings with the same blue print.

20.)What are there to update the instance variables?
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Setter methods (or) simply called as mutators can update the instance variables


21.)Can instance variables can be overridden?
----------------------------------------------------------------------------------------------------------------------------------------------------------------

Instance variables can not be overridden. Only methods which a subclass extends its super class and methods from the interface can be overridden.

22.)How many polymorphism are there in OOPS and how many supports Java?
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Coercion,overloading,parametric, and inclusion among these java supports only three


23.) How come jvm know what to do with marker interface I mean we are not implementing any method. Will it know with the name of the marker interface what to do?
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
jvm does not know bout marker interfaces. yr code, or sun knowns bout marker interfaces via reflection.

24.) explain the difference between response.sendRedirect and forward methods
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

when client gives req to a servletà response.sendredirect() method partially delegates the control to another servlet or jsp by giving request to that,and recieves the response from that servlet.then our requested servlet includes the response of its own and another servlet,and that willbe passed to the client.that means client doesnot knowthat control goes to another servlet,that willbe happened internally.

incaseof forward() method control permanently goes to another servlet.the output ofthe first servlet willbe discarded.The only response of redirected servlet willbe displayed to the browser.


25.) How can we make a hashmap synchronised by using the collections framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
There is a static method in Collection Using which u can obtain a Synchronized version of HashMap..

Map m = Collections.synchronizedMap(new HashMap(...));

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home