Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

what's the use of abstract key word?

  Asked By: Asksuresh    Date: Jul 11    Category: Java    Views: 1651

1.what's the use of abstract key word?
2.explain the concept of multithreading how it works
in java?
3.public static void main()
what's the need for static?
4.difference between jsp and servlets?
5.difference between error and exception?



1 Answer Found

Answer #1    Answered By: Sebastien Anderson     Answered On: Jul 11

1.What's the use of abstract  key word?

An formally unfinished class or method, marked with the keyword abstract. An
abstact class is deliberatesly missing some or all of the method bodies. An
abstract method is deliberately missing its method body. An abstract class is
similar to an interface which is missing all the method bodies. An abstract
class provides a base for someone to extend an actual class. You can't use new
on abstract classes, but you can use abstract references, which always point to
some extension of the abstract class. Interfaces are implicitly abstract as are
alls their methods.

2.explain the concept of multithreading how it works in java?

Get All your answers to Threads at :-

3.public static  void main() what's the need for static?

When we execute a Java application, we use the "java" command which runs the
Java Virtual Machine (JVM) and we specify a class file for it to execute. But,
how does the JVM know where to start executing? It starts with a special method
you must name "main";
I'm going to pass on the full explanation behind why we need "public static" in
your declaration of "main" but, trust me, it needs to be there. Think of the
keywords: public  and static as special modifiers needed for main() to function
as the base of our application for now.
The identifier can be anything, but it's pretty much a standard that you use the
name "args" since this is what everyone uses.

4.difference between jsp  and servlets?

Generally speaking use Servlets to process data on the server and use JSPs to
present data to the client.

For example, a jsp or html file can contain a <form> object. The action for the
form would be a servlet. The servlet would manipulate the data, i.e. store it to
a database, etc. The servlet could then gather any additional information, i.e.
a database index for the new data, and then based upon success or failure would
redirect the client to a jsp which would display the data that was posted along
with the index.

JSPs and Servlets, in the long run, perform the same function. The Servlet
container will compile your JSP into a servlet for you. For presentation though,
JSPs are easier to write as you don't have to explicitly output information into
a stream...it's handled for you.

5.difference between error  and exception?

Both Error and exception  are subclaasses of throwable and so can be caught in a
catch statement.
The biggest difference  is that the Error classes are all considered to be
"...serious problems that a reasonable application should not try to catch."
Thus they are all considered 'unchecked' exceptions, meaning you do not have to
account for them in your code and the compiler will not look for them.
On the other hand all subclasses of Exception (except RuntimeException) are
checked Exceptions that must either be thrown from or caught in methods that can
produce them. The compiler will check and enforce proper handling of these types
of methods.
Check out the part of the java tutorial that covers exceptions for more info.
Hope that Helps

Didn't find what you were looking for? Find more on what's the use of abstract key word? Or get search suggestion and latest updates.