Sunday, October 14, 2007

JAVA QUESTIONS IN RMI and JSP

Q) What is RMI and steps involved in developing an RMI object?

A) 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

Q) 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

Q) what is UnicastRemoteObject?

A) All remote objects must extend UnicastRemoteObject, which provides functionality that is needed to make objects available from remote machines.

Q) Explain the methods, rebind( ) and lookup() in Naming class?

A) rebind( ) of the Naming class(found in java.rmi) is used to update the RMI registry on the server machine. Naming. rebind("AddSever", AddServerImpl);
lookup( ) of the Naming class accepts one argument, the rmi URL and returns a reference to an object of type AddServerImpl.

Q) What is a Java Bean?

A) A Java Bean is a software component that has been designed to be reusable in a variety of different environments.

Q) What is BDK?

A) BDK, Bean Development Kit is a tool that enables to create, configure and connect a set of set of Beans and it can be used to test Beans without writing a code.

Q) What is JSP?

A) JSP is a dynamic scripting capability for web pages that allows Java as well as a few special tags to be embedded into a web file (HTML/XML, etc). The suffix traditionally ends with .jsp to indicate to the web server that the file is a JSP files. JSP is a server side technology - you can't do any client side validation with it.
The advantages are:
a) The JSP assists in making the HTML more functional. Servlets on the other hand allow outputting of HTML but it is a tedious process.
b) It is easy to make a change and then let the JSP capability of the web server you are using deal with compiling it into a servlet and running it.

Q) What are JSP scripting elements?

A) JSP scripting elements lets to insert Java code into the servlet that will be generated from the current JSP page.
There are three forms:
a) Expressions of the form <%= expression %> that are evaluated and inserted into the output,
b) Scriptlets of the form <% code %> that are inserted into the servlet's service method, and
c) Declarations of the form <%! Code %> that are inserted into the body of the servlet class, outside of any existing methods.

Q) What are JSP Directives?

A) A JSP directive affects the overall structure of the servlet class. It usually has the following form: <%@ directive attribute="value" %>
However, you can also combine multiple attribute settings for a single directive, as follows: <%@ directive attribute1="value1" attribute 2="value2" ... attributeN ="valueN" %>
There are two main types of directive: page, which lets to do things like import classes, customize the servlet superclass, and the like; and include, which lets to insert a file into the servlet class at the time the JSP file is translated into a servlet

Q) What are Predefined variables or implicit objects?

A) 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.

Q) What is Bootstrapping in RMI?

Dynamic loading of stubs and skeletons is known as Boot Strapping.

Q) What are different types of Exceptions?.

Runtime exceptions, Errors, Program Exceptions

Q) What is servlet tunnelling?.

Used in applet to servlet communications, a layer over http is built so as to enable object serialization.

Q) What is the frontend in Java?.Also what is Backend?.

Frontend: Applet
Backend : Oracle, Ms-Access(Using JDBC).



Access Modifiers: Which gives additional meaning to data, methods and classes.

Q) Tools 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

Q) Hostile Applets:Its an applet which when downloaded attempts to exploit your system's resources in an inappropriate manner.It performs or causes you to perform an action which you would not otherwise care to perform.

Q) RemoteObjects: Objects that have methods that can be called accross virtual machines are Remote Objects.An object becomes Remote by implementing Remote Interface.

Q) Compiling: Conversion of Programmer-readable Text into Bytecodes,which are platform independent,is known as Compiling.

Q) Java Primitive Data Types:
Byte-8-bit, short-16-bit, int-32-bit, Long-64-bit, Float-32-bit floating point, Bouble-64-bit floating point, Char-16-bit Unicode

Q) What is a unicode?

Unicode is a standard that supports International Characters.

Q) What are blocks?.

They are statements appearing within braces {}.

35. What are types of Java applications?.

(i) Standalone applications(No browser).
(ii) Applets(Browser).

Q) What is the method that gets invoked first in a stand alone application?.

The main()method.

Q) What is throwing an Exception?.

The act of passing an Exception Object to the runtime system is called Throwing an Exception.

Q) 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

Q) What is runnable?.

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.

Q) What is preemptive and Non-preemptive Time Scheduling?.

Preemptive: Running tasks are given small portions of time to execute by using time-slicing.
Non-Preemptive: One task doesn't give another task a chance to run until its finished or has normally yielded its time.

Q) 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.

1. executeQuery() returns ResultSet.

2 .Throwable class is a sub-class of object and implements Serializable.

3 . Skeletons are server side proxies and stubs are client side proxies. True

4 . Netscape introduced JScript language - True

5 . EventDelegation model was introduced by JDK 1.1 - False

6 . StringTokenizer provides two constructors - False

7 . java.applet is one of the smallest package in Java API - True


Q) What is IP?.

IP is Internet Protocol. It is the network protocol which is used to send information from one computer to another over the network over the internet in the form of packets.

MIME(Multipurpose Internet Mail Extension) is a general method by which the content of different types of Internet objects can be identified.

Q) What is an abstract class?.

A class which cannot be Instantiated.

Q) How many standard ports are available?.

1024.

Q) What are different ways of Session-Tracking?.

(i) User-Authorization
(ii) Hidden Files
(iii) Persistant Cookies
(iv) URL Rewriting.

Q) What is a Swing?.

It is a GUI component with a pluggable look and feel.

Q) What is default Look-and-Feel of a Swing Component?.

Java Look-and-Feel.

1 Awt Components and Swing Components can be inter-mingled in an Application - False

2 What does x mean in javax.swing?. Extension of java.

3 Images can be displayed on Swing Components - True

4 Borders can be changed or added for a LightWeight Components - True

5 Swing Components are always rectangular - False

Q) When Swing components overlap with Heavyweight components, it is the latter that is on the
top - True

Q) What are invisible components?.

They are light weight components that perform no painting, but can take space in the GUI.

Q) What are the borders provided by Swing?.

(i) Simple (ii) Matte iii) Titled iv) Compound.

Q) What are the restrictions imposed by a Security Manager on Applets?.

i) cannot read or write files on the host that's executing it.
ii) cannot load libraries or define native methods.
iii) cannot make network connections except to the host that it came from
iv) cannot start any program on the host that's executing it.
v) cannot read certain system properties.
vi) windows that an applet brings up look different than windows that an application brings up.

Q) what is the difference between Procedural and OOPs?
A)
a) In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOPs program, unit of program is object, which is nothing but combination of data and code.
b) In procedural program,data is exposed to the whole program whereas in OOPs program,it is accessible with in the object and which in turn assures the security of the code.

Q) What is the difference between Assignment and Initialization?

A) Assignment can be done as many times as desired whereas initialization can be done only once.

Q) What are Class, Constructor and Primitive data types?

A) Class is a template for multiple objects with similar features and it is a blue print for objects. It defines a type of object according to the data the object can hold and the operations the object can perform.

Constructor is a special kind of method that determines how an object is initialized when created.

Primitive data types are 8 types and they are:
byte, short, int, long
float, double
boolean
char

Q) What is an Object and how do you allocate memory to it?

A) Object is an instance of a class and it is a software unit that combines a structured set of data with a set of operations for inspecting and manipulating that data. When an object is created using new operator, memory is allocated to it.

Q) What is the difference between constructor and method?

A) Constructor will be automatically invoked when an object is created whereas method has to be called explicitly.

Q) What are methods and how are they defined?

A) Methods are functions that operate on instances of classes in which they are defined. Objects can communicate with each other using methods and can call methods in other classes.
Method definition has four parts. They are name of the method, type of object or primitive type the method returns, a list of parameters and the body of the method. A method's signature is a combination of the first three parts mentioned above.

Q) What is the use of bin and lib in JDK?

A) Bin contains all tools such as javac, appletviewer, awt tool, etc., whereas lib contains API and all packages.

Q) What is casting?
A) Casting is used to convert the value of one type to another.

Q) What is the difference between an argument and a parameter?

A) While defining method, variables passed in the method are called parameters. While using those methods, values passed to those variables are called arguments.

Q) What is Garbage Collection and how to call it explicitly?

A) When an object is no longer referred to by any variable, java automatically reclaims memory used by that
object. This is known as garbage collection.
System.gc() method may be used to call it explicitly.
Q) What is finalize() method ?

A) finalize () method is used just before an object is destroyed and can be called just prior to garbage collection.

Q) What are Transient and Volatile Modifiers?

A) Transient: The transient modifier applies to variables only and it is not stored as part of its object's
Persistent state. Transient variables are not serialized.
Volatile: Volatile modifier applies to variables only and it tells the compiler that the variable modified by
volatile can be changed unexpectedly by other parts of the program.

Q) What is method overloading and method overriding?

A) Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading.
Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding.

Q) What is difference between overloading and overriding?

A) a) In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method.
b) Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass.
c) In overloading, separate methods share the same name whereas in overriding,subclass method replaces the superclass.
d) Overloading must have different method signatures whereas overriding must have same signature.

Q) What is meant by Inheritance and what are its advantages?

A) Inheritance is the process of inheriting all the features from a class. The advantages of inheritance are reusability of code and accessibility of variables and methods of the super class by subclasses.

Q) What is the difference between this() and super()?

A) this() can be used to invoke a constructor of the same class whereas super() can be used to invoke a super class constructor.

Q) What is the difference between superclass and subclass?

A) A super class is a class that is inherited whereas sub class is a class that does the inheriting.

Q) What modifiers may be used with top-level class?

A) public, abstract and final can be used for top-level class.

No comments: