Академический Документы
Профессиональный Документы
Культура Документы
Or Explain
• polymorphism,
• abstraction
• inheritance
• encapsulation
think from your project point of view
what is polymorphism
Or
explain method overloading and overriding, give practical scenario for both
e.g. from capital market point of view – there can be cash market and Futures and Options
There are 2 methods in a class. Both have the same method signature except
for return types. Is this overloading or overriding or what is it?
Answer It is not overloading because overloading
# 6 must have different parameters, no matter
what ever may be the return type is.
And for overriding inheritance should be
used between 2 classes.
so it is neither overriding nor overloading.
• Explain encapsulation
• please give encapsulation example from your project
data abstraction is one of the two major aspects of encapsulation (the other is information
hiding).
When you encapsulate something you get an outside and an inside. Take any encapsulated unit,
like a primitive or an object for example. The way you can use it and how it behaves is the data
abstraction. Hidden inside is the implementation.
In Java you usually define your own data abstraction by putting together a set of non-private
methods in the form of a class or an interface.
Encapsulation is the concept that an object should totally separate its interface from its
implementation. All the data and implementation code for an object should be entirely hidden behind
its interface.
The idea is that we can create an interface (Public methods in a class) and, as long as that interface
remains consistent, the application can interact with our objects. This remains true even if we entirely
rewrite the code within a given method thus the interface is independent of the implementation
e.g
/Example of Encapsulation
class Box {
// what are the properties or fields
private int length;
private int width;
private int height;
class BoxVol {
public static void main (String args[]) {
double vol;
ob1.setLength(120);
ob1.setWidth(100);
ob1.setHeight(90);
vol = ob1.displayVolume();
System.out.println("Volume is : " + vol);
}
}
**************************************…
private keyword use top specifies encapsulated.
By keeping your data private(encapsulated)out side entity(other methods and data) can not misuse it
or alter it with out your permission. you can only allow them to use it but you will not allow them to
alter it.
Interface:---
rose is a flower
Parent - child relationship
corporate user is a user
has a relationship
s1==s2
would be true
s1== s3
would be false
s3.equals(s2) = true
would be true
String builder is faster than String Buffer and last one is threadsafe.please tell
another important difference.
Answer String is immutable whereas StringBuffer and
# 2 StringBuilder
can change their values.
Yes
exceptions.
------------------------------------------------
------------------------------------------
thread priorities..
t.setpriority.
by extending thread.
override run interface
----------------------------------------
thread t.start
starting
------------------------------------------
no state
ready to run state
running
destroyed
or sleep -> ready to run ->
-------------------------------------------------------------
================================================================
JDBC connectivity..
application server
jndi look up has to be done to get the datasource and the from there the connection object
-----------------------------------------
what is adv of connection pooling.
better performance -
-----------------------------------
----------------------------------------
- init()
- instance getting initialized. first request from webbrowser. init will only be called once. opening of file etc.
- service
doget
dopost
- destroy
they have to implement single thread model interface. marker - which will server one request.
what is http -
request and response.
how do u maintain session
session object
------------------------------------------------
------------------------------------
request
response
session
out
pagecontext
applicationcontext
--------------------------------------
hibernate
what is hibernate
- It is an orm tool
what is ORM
e.g
employee / department,
insurance
policy
If you are reviewing the code of your team members, what points will
you look at, assuming the performance of the application is not so
great
Answer UNNECASARY OB JECT CREATION shud b 0 Sandhya
# 1 avoided..REUSABILITY OF
CODE SHUD B THER.network calls shud be
less..beter to use
connection pooling.gud exceptional
handling.
Re: If you are reviewing the code of your team members, what points
will you look at, assuming the performance of the application is not so
great
Answer To boost performance:
# 2 1) Use trim() meaningfully.
2) Operation on String Object should be
on check.
3) Network calls should be put on check.
4) Keep a look on loops.
5) Use static methods for utility
purposes. Like Math class.
6) Use logging only for important tasks
1.
2. Can there be an abstract class with no abstract methods in it? - Yes
3. Can an Interface be final? - No
4. Can an Interface have an inner class? - Yes.
public interface abc
class a1
a1()
{
int j;
System.out.println("inside");
};
System.out.println("in interfia");
also
/**
* SingletonHolder is loaded on the first execution of Singleton.getInstance()
* or the first access to SingletonHolder.INSTANCE, not before.
*/
private static class SingletonHolder {
private static final Singleton INSTANCE = new Singleton();
}