- Most popular JSP editors such as DreamWeaver and WSAD support Custom Tag syntax and the ability to step through them in a debugger.
The Tags themselves are built using Java, of course. Inserting a Tag only requires embedding an XML-like fragment into a JSP. When a JSP that contains one or more tags is invoked, the servlet produced from JSP compilation calls out to the appropriate Tag handler instance to perform its logic. All invocations of the same Tag invoke the same code. The better application's containers will create a pool of tag instances and not create a new instance of the Java class for every request. This helps to improve performance in a manner similar to how an EJB container can reuse Stateless Session bean instances.
2. method called automatically by JVM is called calll back method...
ex :private void writeObject (OOS os) throws Exception {
}
Object class does not implement serializable
Generic Servlet implements serilizable
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
-True,,, interfaces provide just the declarations of method and implicitly these methods are "public abstract".
Interfaces are useful when some classes implements it, or some other interfaces extends it.
The interface "LayoutManager" is implemented by classes like FlowLayout, GridLayout etc.
BorderLayout, CardLayout classes implements LayoutManager2.
LayoutManager2 extends LayoutManager.
So BorderLayout, CardLayout classes implements LayoutManager, but not directly.
I dun know whether i answered ur question the way u wanted !!.
Object class does not implement serializable
Generic Servlet implements serilizable
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
I was thinking about that, and I had some doubts.
When I declare an interface, for example:
public interface MyInterface
{
public void method1();
public void method2();
}
Could these interface methods be considered abstract? What I mean is that the concept of an abstract method is:
An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon).
So, could these methods be considered abstract? They are not "pure" abstract methods as I'm not using the
What can you tell me about it?abstract
word, but conceptually, it looks like they are.-True,,, interfaces provide just the declarations of method and implicitly these methods are "public abstract".
Interfaces are useful when some classes implements it, or some other interfaces extends it.
The interface "LayoutManager" is implemented by classes like FlowLayout, GridLayout etc.
BorderLayout, CardLayout classes implements LayoutManager2.
LayoutManager2 extends LayoutManager.
So BorderLayout, CardLayout classes implements LayoutManager, but not directly.
I dun know whether i answered ur question the way u wanted !!.
Abstract classes can have abstract methods.
Interfaces can only have abstract methods.
An interface is like a "purely" abstract class. The class and all of its methods are abstract. An abstract class can have implemented methods but the class itself cannot be instantiated (useful for inheritance and following DRY).
For an interface, since there isn't any implementation at all they are useful for their purpose: a contract. If you implement the Interface then you must implement the methods in the interface.
So the difference is an abstract class can have implemented methods whereas a interface cannot.
The reason they are separate is so a class can implement several interfaces. Java and C# restrict a class to inherent from a single parent class. Some languages allow you to inherit from multiple classes and you could accomplish the work of an interface via a "purely" abstract class. But multiple inheritance has its problems, namely the dreaded Diamond Problem
Methods in an interface is
"public abstract" by default.
Some code.
------------------------------------
interface Mine {
// is as good as saying "public abstract", thats the default
// for an method in an interface
void tester();
/* Won't compile, must be "public"
private abstract void tester();
*/
/* Won't compile, must be "public"
protected abstract void tester();
*/
}
class Test1 implements Mine {
/*
// Won't compile. coz, ur implementing a method of an
// interface with a
// weaker access privilege ( default access in this case),
// Mr. compiler donot like this
void tester() {
System.out.println("Oops !!");
}
*/
public void tester() {
System.out.println("Mmmm... good enough !!");
}
}
----------------------------------------------------
Check out this code.
It won't compile, coz, class B is overriding the method with a weaker access privilege ( again, default access in this case),
class A {
public void tester() {
}
}
class B extends A{
void tester() {
}
}
Table: Differences between abstract classes and interfaces
-------------------
-The element
------------------------
Methods in an interface is
"public abstract" by default.
Some code.
------------------------------------
interface Mine {
// is as good as saying "public abstract", thats the default
// for an method in an interface
void tester();
/* Won't compile, must be "public"
private abstract void tester();
*/
/* Won't compile, must be "public"
protected abstract void tester();
*/
}
class Test1 implements Mine {
/*
// Won't compile. coz, ur implementing a method of an
// interface with a
// weaker access privilege ( default access in this case),
// Mr. compiler donot like this
void tester() {
System.out.println("Oops !!");
}
*/
public void tester() {
System.out.println("Mmmm... good enough !!");
}
}
----------------------------------------------------
Check out this code.
It won't compile, coz, class B is overriding the method with a weaker access privilege ( again, default access in this case),
class A {
public void tester() {
}
}
class B extends A{
void tester() {
}
}
Partial Implementations
If a class includes an interface but does not fully implement the methods defined by that interface, then that class must be declared as abstract.
nterfaces support multiple inheritance which is not possible with concrete and abstract classes.
"implements" keyword is used in place of "extends". "extends" comes with concrete and abstract classes.
Interfaces must contain abstract methods only.
As in abstract classes, all the abstract methods of the interfaces should be overridden by the subclass.
As with abstract classes, with interfaces also, objects cannot be created but reference variables can be created.
Interface reference variable can be assigned with concrete subclass objects. Once assigned, the interface reference variable works like an object. This feature applies to abstract classes also.
As all methods must be abstract and public, these two keyword can be omitted in method declaration. If omitted, JVM takes by default.
All interface variables must be public, static and final. If omitted, they are taken by default.
All interface methods should be overridden with public only as overridden method cannot have a weaker access specifier.
- See more at: http://way2java.com/oops-concepts/interfaces-partial-implementatin-of-multiple-inheritance/#sthash.TueDnU3f.dpuf
Compare and Contrast Abstract classes with Interfaces?
Even though the interface is a special derivative of abstract class; it differs a lot with abstract class. Following table gives their differences.
Abstract class | Interface |
---|---|
1. Multiple inheritance is not supported | Multiple inheritance is supported |
2. To inherit "extends" keyword is used | To inherit "implements" keyword is used |
3. May include concrete methods also | All must be abstract methods |
4. Methods may be of any specifier except private. That is, may be public, protected or default | Methods must be public only |
5. Access specifier should be written | If omitted, taken by default (as public) |
6. Access modifier abstract should be written | If omitted, taken by default (as abstract) |
7. Variables can be any access specifier including private | Variables should be public, static and final. If omitted, taken by default. |
8. Constructors can be included in code | No constructors |
9. main() can be included in code | main() method cannot be included |
After knowing the differences, let us see the similarities.
- With abstract classes and interfaces, objects cannot be created; but reference variables can be created.
- All the abstract methods of the both should be overridden by the inherited class.
- "Dynamic polymorphism" is supported by both.
- Both works as template (structure of methods) from which new classes can be derived easily.
-------------------
-The element
load-on-startup
indicates that this servlet should be loaded (instantiated and have its init() called) on the startup of the Web application. The element content of this element must be an integer indicating the order in which the servlet should be loaded. If the value is a negative integer, or the element is not present, the container is free to load the servlet whenever it chooses. If the value is a positive integer or 0, the container must load and initialize the servlet as the application is deployed. The container must guarantee that servlets marked with lower integers are loaded before servlets marked with higher integers. The container may choose the order of loading of servlets with the same load-on-startup
value.------------------------
No comments:
Post a Comment