Java is a pure object oriented programming language, which has derived C syntax and C++ object oriented programming features. Is a compiled and interpreted language and is platform independent and Can do graphics, networking, multithreading. It was initially called as OAK.
- Encapsulation : Nothing but data hiding, like the variables declared under private of a particular class are accessed only in that class and cannot access in any other the class.
- Inheritance : Is the process in which one object acquires the properties of another object, ie., derived object.
- Polymorphism: One method different forms, ie., method overriding and interfaces are the examples of polymorphism.
- What are Java Buzzwords ?
Simple : Easy to learn.
Secure : Provided by firew alls between networked applications.
Portable : Can be dynamically downloaded at various platforms in internet.
OOP : Four Corner stones.
Multithread : Can perform more than one task concurrently in a single program.
Robust : overcomes problems of de-allocation of memory and exceptions.
Interpreted : Convert into byte code and the executes by JVM.
Distributed : Concept of RMI.
Dynamic : Verifying and accessing objects at run time.
- Scope and lifetime of variables ?
scope of variables is only to that particular block lifetime will be till the block ends.
When a member is declared as static it can be accessed before any objects of its class are created and without any reference to any object. these are global variables, no copy of these variables can be made. static can also be declared for methods. and cannot refer to this or super.
- method overloading : same method name with different arguments.
- method overriding : same method name and same number of arguments
- How Exception handling is done in Java ?
Is managed via 5 keywords :
try : statements that you want to monitor the exceptions contain in try block.
catch : the exception thrown by try is catched by this.
throw : to manually throw exception we go for this.
throws : Exception that is thrown out of a method must be specified by throws after the method declaration.
finally : This block is executed whether or not an exception is thrown. and also it is executed just before the method returns. and this is optional block.
- What is the use of bin and lib in JDK?
Bin contains all tools such as javac, appletviewer, awt tool, etc., whereas lib contains API and all packages.
- What is the difference between superclass and subclass?
A super class is a class that is inherited whereas sub class is a class that does the inheriting.
- What is the difference between exception and error?
The exception class defines mild error conditions that your program encounters.
Ex: Arithmetic Exception, FilenotFound exception
Exceptions can occur when
- try to open the file, which does not exist
- the network connection is disrupted
- operands being manipulated are out of prescribed ranges
- the class file you are interested in loading is missing
The error class defines serious error conditions that you should not attempt to recover from.
In most cases it is advisable to let the program terminate when such an error is encountered.
Ex: Running out of memory error, Stack overflow error.
An adapter class provides an empty implementation of all methods in an event listener interface. Adapter classes are useful when you want to receive and process only some of the events that are handled by a particular event listener interface. You can define a new class to act listener by extending one of the adapter classes and implementing only those events in which you are interested.
- What is meant by controls and what are different types of controls in AWT?
Controls are components that allow a user to interact with your application and the AWT supports the following types of controls:
Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components.
These controls are subclasses of Component.
- What is Bootstrapping in RMI?
Dynamic loading of stubs and skeletons is known as Boot Strapping.
- What is servlet tunnelling?
Used in applet to servlet communications, a layer over http is built so as to enable object serialization.
- What is the frontend in Java?.Also what is Backend?.
Frontend: Applet
Backend : Oracle, Ms-Access(Using JDBC).
- What are theTools provided by JDK
(i) javac - compiler
(ii) java - interpretor
(iii) jdb - debugger
(iv) javap - Disassembles
(v) appletviewer - Applets
(vi) javadoc - documentation generator
(vii) javah - ' C' header file generator
- What are the Java Primitive Data Types ?
Byte-8-bit, short-16-bit, int-32-bit, Long-64-bit, Float-32-bit floating point, Double-64-bit floating point, Char-16-bit Unicode
- What are the packages in JDK?
There are 8 packages
(i) java.lang
(ii) java.util
(iii) java.io
(iv) java.applet
(v) java.awt
(vi) java.awt.image
(vii) java.awt.peer
(viii) java.awt.net
Its an Interface through which Java implements Threads.The class can extend from any class but if it implements Runnable,Threads can be used in that particular application.
- What is synchronization?.
Two or more threads trying to access the same method at the same point of time leads to synchronization.If that particular method is declared as synchronized only one thread can access it at a time. Another thread can access it only if the first thread' s task is complete.
Skeletons are server side proxies and stubs are client side proxies. True
Netscape introduced JScript language
MIME(Multipurpose Internet Mail Extension) is a general method by which the content of different types of Internet objects can be identified.
- What are different ways of Session-Tracking?.
(i) User-Authorization
(ii) Hidden Files
(iii) Persistant Cookies
(iv) URL Rewriting.
- What are the four components in URL ?
http:// www. yahoo .com : 8080 / index.html
http: --- > is protocol
www. yahoo .com --- is IP address
8080 -- port number and is a pointer to memory location.
index.html -- file path to be loaded
- What is a StringTokenizer ?
String Tokenizer provide parsing process in which it identifies the delimiters provided by the user , by default delimiters are spaces, tab, newline etc. and separates them from the tokens. Tokens are those which are separated by delimiters.
- What are macros and Inline functions ? Which is best and Difference ?
Inline functions do Parameter passing, where as Macros do Text Substitution.
Its better to go for Inline functions than macros, else you may get different results.
The process of writing the state of an object to a byte stream. and can restore these objects by using deserialization.Is also need to implement RMI, which allows a java object of one machine to invoke java object of another machine.ie., the object is passed as an argument by serializing it and the receiving machine deserializes it.
- What is the difference between CGI and Servlet ?
CGI suffered serious performance problems. servlets performance is better.
CGI create separate process to handle client request. and Servlets do not.
CGI is platform dependent, whereas Servlet is platform-independent b’cauz written in java.
Servlets can communicate with applets, databases and RMI mechanisms.
- What are Vector, Hashtable, LinkedList and Enumeration?
Vector : The Vector class provides the capability to implement a growable array of objects.
Hashtable : The Hashtable class implements a Hashtable data structure. A Hashtable indexes and stores objects in a dictionary using hash codes as the object' s keys. Hash codes are integer values that identify objects.
LinkedList : Removing or inserting elements in the middle of an array can be done using LinkedList. A
LinkedList stores each object in a separate link whereas an array stores object references in consecutive locations.
Enumeration : An object that implements the Enumeration interface generates a series of elements, one at a time.
It has two methods, namely hasMoreElements( ) and nextElement( ). HasMoreElemnts( ) tests if this enumeration has more elements and nextElement method returns successive elements of the series.
- What is the difference between an applet and a servlet?
Servlets are to servers what applets are to browsers.
Applets must have graphical user interfaces whereas servlets have no graphical user interfaces.
- What is the difference between doPost and doGet methods?
a) doGet() method is used to get information, while doPost( ) method is used for posting information.
b) doGet() requests can' t send large amount of information and is limited to 240 -255 characters. However, doPost( )requests passes all of its data, of unlimited length.
c) A doGet( ) request is appended to the request URL in a query string and this allows the exchange is visible to the client, whereas a doPost() request passes directly over the socket connection as part of its HTTP request body and the exchange are invisible to the client.
- What is the life cycle of a servlet?
Each Servlet has the same life cycle:
a) A server loads and initializes the servlet by init () method.
b) The servlet handles zero or more client' s requests through service( ) method.
c) The server removes the servlet through destroy() method.
- What are the different servers available for developing and deploying Servlets?
a) Java Web Server
b) JRun
g) Apache Server
h) Netscape Information Server
i) Web Logic
- How do servlets handle multiple simultaneous requests?
The server has multiple threads that are available to handle requests. When a request comes in, it is assigned to a thread, which calls a service method (for example: doGet(), doPost( ) and service( ) ) of the servlet. For this reason, a single servlet object can have its service methods called by many threads at once.
- What is the difference between TCP/IP and UDP?
TCP/IP is a two-way communication between the client and the server and it is a reliable and there is a confirmation regarding reaching the message to the destination. It is like a phone call. UDP is a one-way communication only betw een the client and the server and it is not a reliable and there is no confirmation regarding reaching the message to the destination. It is like a postal mail.
- What is RMI and steps involved in developing an RMI object?
Remote Method Invocation (RMI) allows java object that executes on one machine and to invoke the method
of a Java object to execute on another machine.
The steps involved in developing an RMI object are:
a) Define the interfaces
b) Implementing these interfaces
c) Compile the interfaces and their implementations with the java compiler
d) Compile the server implementation with RMI compiler
e) Run the RMI registry
f) Run the application
- What is RMI architecture?
a) Application layer ---- contains the actual object definition
b) Proxy layer ---- consists of stub and skeleton
c) Remote Reference layer ---- gets the stream of bytes from the transport layer and sends it to the proxy layer
d) Transportation layer ---- responsible for handling the actual machine-to-machine communication
- What are Predefined variables or implicit objects?
To simplify code in JSP expressions and scriptlets, we can use eight automatically defined variables, sometimes called implicit objects. They are request, response, out, session, application, config, pageContext, and page.