1.What is the difference between procedural and object-oriented
programs? Ans: a) In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP 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. 2.What are ncapsulation! "nheritance and #ol$morphism? Ans: ncapsulation is the mechanism that binds together code and data it manipulates and keeps both safe from outside interference and misuse. "nheritance is the process by which one object acquires the properties of another object. #ol$morphism is the feature that allows one interface to be used for general class actions. %.What is the difference between Assignment and "nitiali&ation? Ans: ssignment can be done as many times as desired whereas initiali!ation can be done only once. '.What is ((#s? Ans: Object oriented programming organi!es a program around its data, i. e. , objects and a set of well defined interfaces to that data. n object"oriented program can be characteri!ed as data controlling access to code. ).What are *lass! *onstructor and #rimiti+e data t$pes? Ans: *lass 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. *onstructor is a special kind of method that determines how an object is initiali!ed when created. #rimiti+e data t$pes are # types and they are$ byte, short, int, long, float, double, boolean, char. ,.What is an (bject and how do $ou allocate memor$ to it? Ans: 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. %hen an object is created using new operator, memory is allocated to it. SVIT 1 -.What is the difference between constructor and method? Ans: &onstructor will be automatically in'oked when an object is created whereas method has to be called explicitly. ..What are methods and how are the$ defined? Ans: (ethods 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. (ethod definition has four parts. )hey are name of the method, type of object or primiti'e type the method returns, a list of parameters and the body of the method. method*s signature is a combination of the first three parts mentioned abo'e. /.What is the use of bin and lib in J01? Ans: +in contains all tools such as ja'ac, applet'iewer, awt tool, etc., whereas lib contains PI and all packages. 12.What is casting? Ans: &asting is used to con'ert the 'alue of one type to another. 11.3ow man$ wa$s can an argument be passed to a subroutine and e4plain them? Ans: n argument can be passed in two ways. )hey are passing by 'alue and passing by reference. Passing by 'alue$ )his method copies the 'alue of an argument into the formal parameter of the subroutine. Passing by reference$ In this method, a reference to an argument ,not the 'alue of the argument) is passed to the parameter. 12.What is the difference between an argument and a parameter? Ans: %hile defining method, 'ariables passed in the method are called parameters. %hile using those methods, 'alues passed to those 'ariables are called arguments. 1%.What are different t$pes of access modifiers? Ans: public: ny thing declared as public can be accessed from anywhere. pri+ate: ny thing declared as pri'ate can*t be seen outside of its class. protected: ny thing declared as protected can be accessed by classes in the same package and subclasses in the other packages. default modifier : &an be accessed only to classes in the same package. 1'.What is final! finali&e56 and finall$? Ans: final : final keyword can be used for class, method and 'ariables. final class cannot be subclassed and it pre'ents other programmers from subclassing a secure class to in'oke insecure methods. final method can*t be o'erridden. final 'ariable can*t change from its initiali!ed 'alue. SVIT 2 finali&e56 : finali!e,) method is used just before an object is destroyed and can be called just prior to garbage collection. finall$ : finally, a key word used in exception handling, creates a block of code that will be executed after a try-catch block has completed and before the code following the try-catch block. )he finally block will execute whether or not an exception is thrown. .or example, if a method opens a file upon exit, then you will not want the code that closes the file to be bypassed by the exception"handling mechanism. )his finally keyword is designed to address this contingency. 1).What is 78"*(0? Ans: /nicode is used for internal representation of characters and strings and it uses 01 bits to represent each other. 1,.What is 9arbage *ollection and how to call it e4plicitl$? Ans: %hen an object is no longer referred to by any 'ariable, ja'a automatically reclaims memory used by that object. )his is known as garbage collection. 2ystem. gc,) method may be used to call it explicitly. 1-.What is finali&e56 method? Ans: finali!e ,) method is used just before an object is destroyed and can be called just prior to garbage collection. 1..What are :ransient and Volatile ;odifiers? Ans: :ransient: )he transient modifier applies to 'ariables only and it is not stored as part of its object*s Persistent state. )ransient 'ariables are not seriali!ed. Volatile: 3olatile modifier applies to 'ariables only and it tells the compiler that the 'ariable modified by 'olatile can be changed unexpectedly by other parts of the program. 1/.What is method o+erloading and method o+erriding? Ans: ;ethod o+erloading$ %hen a method in a class ha'ing the same method name with different arguments is said to be method o'erloading. ;ethod o+erriding : %hen a method in a class ha'ing the same method name with same arguments is said to be method o'erriding. 22.What is difference between o+erloading and o+erriding? Ans: a) In o'erloading, there is a relationship between methods a'ailable in the same class whereas in o'erriding, there is relationship between a superclass method and subclass method. b) O'erloading does not block inheritance from the superclass whereas o'erriding blocks inheritance from the superclass. c) In o'erloading, separate methods share the same name whereas in o'erriding, subclass method replaces the superclass. SVIT 3 d) O'erloading must ha'e different method signatures whereas o'erriding must ha'e same signature. 21.What is meant b$ "nheritance and what are its ad+antages? Ans: Inheritance is the process of inheriting all the features from a class. )he ad'antages of inheritance are reusability of code and accessibility of 'ariables and methods of the super class by subclasses. 44.%hat is the difference between this,) and super,)5 Ans: this,) can be used to in'oke a constructor of the same class whereas super,) can be used to in'oke a super class constructor. 46.%hat is the difference between superclass and subclass5 Ans: super class is a class that is inherited whereas sub class is a class that does the inheriting. 47.%hat modifiers may be used with top"le'el class5 Ans: public, abstract and final can be used for top"le'el class. 48.%hat are inner class and anonymous class5 Ans: Inner class $ classes defined in other classes, including those defined in methods are called inner classes. n inner class can ha'e any accessibility including pri'ate. nonymous class $ nonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot ha'e explicit constructors. 2,.What is a pac<age? Ans: package is a collection of classes and interfaces that pro'ides a high" le'el layer of access protection and name space management. 2-.What is a reflection pac<age? Ans: ja'a. lang. reflect package has the ability to analy!e itself in runtime. 2..What is interface and its use? Ans: Interface is similar to a class which may contain method*s signature only but not bodies and it is a formal set of method and constant declarations that must be defined by the class that implements it. Interfaces are useful for$ a)9eclaring methods that one or more classes are expected to implement b)&apturing similarities between unrelated classes without forcing a class relationship. c)9etermining an object*s programming interface without re'ealing the actual body of the class. 2/.What is an abstract class? Ans: n abstract class is a class designed with implementation gaps for subclasses to fill in and is deliberately incomplete. SVIT 4 %2.What is the difference between "nteger and int? Ans: a) Integer is a class defined in the ja'a. lang package, whereas int is a primiti'e data type defined in the :a'a language itself. :a'a does not automatically con'ert from one to the other. b) Integer can be used as an argument for a method that requires an object, whereas int can be used for calculations. %1.What is a cloneable interface and how man$ methods does it contain? Ans: It is not ha'ing any method because it is a );;<9 or (=><= interface. %2.What is the difference between abstract class and interface? Ans: a) ll the methods declared inside an interface are abstract whereas abstract class must ha'e at least one abstract method and others may be concrete or abstract. b) In abstract class, key word abstract must be used for the methods whereas interface we need not use that keyword for the methods. c) bstract class must ha'e subclasses whereas interface can*t ha'e subclasses. %%.*an $ou ha+e an inner class inside a method and what +ariables can $ou access? Ans: ?es, we can ha'e an inner class inside a method and final 'ariables can be accessed. %'.What is the difference between =tring and =tring >uffer? Ans: a) 2tring objects are constants and immutable whereas 2tring+uffer objects are not. b) 2tring class supports constant strings whereas 2tring+uffer class supports growable and modifiable strings. %).What is the difference between Arra$ and +ector? Ans: rray is a set of related data type and static whereas 'ector is a growable array of objects and dynamic. %,.What is the difference between e4ception and error? Ans: )he exception class defines mild error conditions that your program encounters. <xceptions can occur when trying 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. )he error class defines serious error conditions that you should not attempt to reco'er from. In most cases it is ad'isable to let the program terminate when such an error is encountered. %-.What is the difference between process and thread? Ans: Process is a program in execution whereas thread is a separate path of execution in a program. SVIT 5 %..What is multithreading and what are the methods for inter-thread communication and what is the class in which these methods are defined? Ans: (ultithreading is the mechanism in which more than one thread run independent of each other within the process. wait ,), notify ,) and notifyll,) methods can be used for inter"thread communication and these methods are in Object class. wait,) $ %hen a thread executes a call to wait,) method, it surrenders the object lock and enters into a waiting state. notify,) or notifyll,) $ )o remo'e a thread from the waiting state, some other thread must make a call to notify,) or notifyll,) method on the same object. %/.What is the class and interface in ja+a to create thread and which is the most ad+antageous method? Ans: )hread class and =unnable interface can be used to create threads and using =unnable interface is the most ad'antageous method to create threads because we need not extend thread class here. '2.What are the states associated in the thread? Ans: )hread contains ready, running, waiting and dead states. '1.What is s$nchroni&ation? Ans: 2ynchroni!ation is the mechanism that ensures that only one thread is accessed the resources at a time. '2.When $ou will s$nchroni&e a piece of $our code? Ans: %hen you expect your code will be accessed by different threads and these threads may change a particular data causing data corruption. '%.What is deadloc<? Ans: %hen two threads are waiting each other and can*t precede the program is said to be deadlock. ''.What is daemon thread and which method is used to create the daemon thread? Ans: 9aemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the ja'a runtime system. set9aemon method is used to create a daemon thread. ').Are there an$ global +ariables in Ja+a! which can be accessed b$ other part of $our program? Ans: @o, it is not the main method in which you define 'ariables. ;lobal 'ariables is not possible because concept of encapsulation is eliminated here. ',.What is an applet? Ans: pplet is a dynamic and interacti'e program that runs inside a web page displayed by a ja'a capable browser. SVIT 6 '-.What is the difference between applications and applets? Ans: a)pplication must be run on local machine whereas applet needs no explicit installation on local machine. b)pplication must be run explicitly within a ja'a"compatible 'irtual machine whereas applet loads and runs itself automatically in a ja'a"enabled browser. c)pplication starts execution with its main method whereas applet starts execution with its init method. d)pplication can run with or without graphical user interface whereas applet must run within a graphical user interface. '..3ow does applet recogni&e the height and width? Ans: /sing getParameters,) method. '/.When do $ou use codebase in applet? Ans: %hen the applet class file is not in the same directory, codebase is used. )2.What is the lifec$cle of an applet? Ans: init,) method " &an be called when an applet is first loaded start,) method " &an be called each time an applet is started. paint,) method " &an be called when the applet is minimi!ed or maximi!ed. stop,) method " &an be used when the browser mo'es off the applet*s page. destroy,) method " &an be called when the browser is finished with the applet. )1.3ow do $ou set securit$ in applets? Ans: using set2ecurity(anager,) method )2.What is an e+ent and what are the models a+ailable for e+ent handling? Ans: n e'ent is an e'ent object that describes a state of change in a source. In other words, e'ent occurs when an action is generated, like pressing button, clicking mouse, selecting a list, etc. )here are two types of models for handling e'ents and they are$ a) e'ent"inheritance model and b) e'ent"delegation model )%.What are the ad+antages of the model o+er the e+ent-inheritance model? Ans: )he e'ent"delegation model has two ad'antages o'er the e'ent"inheritance model. )hey are$ a)It enables e'ent handling by objects other than the ones that generate the e'ents. )his allows a clean separation between a component*s design and its use. b)It performs much better in applications where many e'ents are generated. )his performance impro'ement is due to the fact that the e'ent"delegation model does not ha'e to be repeatedly process unhandled e'ents as is the case of the e'ent"inheritance. )'.What is source and listener? SVIT 7 Ans: source $ source is an object that generates an e'ent. )his occurs when the internal state of that object changes in some way. listener $ listener is an object that is notified when an e'ent occurs. It has two major requirements. .irst, it must ha'e been registered with one or more sources to recei'e notifications about specific types of e'ents. 2econd, it must implement methods to recei'e and process these notifications. )).What is adapter class? Ans: n adapter class pro'ides an empty implementation of all methods in an e'ent listener interface. dapter classes are useful when you want to recei'e and process only some of the e'ents that are handled by a particular e'ent listener interface. ?ou can define a new class to act listener by extending one of the adapter classes and implementing only those e'ents in which you are interested. .or example, the (ouse(otiondapter class has two methods, mouse9ragged,)and mouse(o'ed,). )he signatures of these empty are exactly as defined in the (ouse(otionAistener interface. If you are interested in only mouse drag e'ents, then you could simply extend (ouse(otiondapter and implement mouse9ragged,) . ),.What is meant b$ controls and what are different t$pes of controls in AW:? Ans: &ontrols are components that allow a user to interact with your application and the %) supports the following types of controls$ Aabels, Push +uttons, &heck +oxes, &hoice Aists, Aists, 2crollbars, )ext &omponents. )hese controls are subclasses of &omponent. )-.What is the difference between choice and list? Ans: &hoice is displayed in a compact form that requires you to pull it down to see the list of a'ailable choices and only one item may be selected from a choice. Aist may be displayed in such a way that se'eral list items are 'isible and it supports the selection of one or more list items. )..What is the difference between scrollbar and scrollpane? Ans: 2crollbar is a &omponent, but not a &ontainer whereas 2crollpane is a &onatiner and handles its own e'ents and perform its own scrolling. )/.What is a la$out manager and what are different t$pes of la$out managers a+ailable in ja+a AW:? Ans: layout manager is an object that is used to organi!e components in a container. )he different layouts are a'ailable are .lowAayout, +orderAayout, &ardAayout, ;ridAayout and ;rid+agAayout. ,2.3ow are the elements of different la$outs organi&ed? Ans: ?low@a$out: )he elements of a .lowAayout are organi!ed in a top to bottom, left to right fashion. >order@a$out: )he elements of a +orderAayout are organi!ed at the borders ,@orth, 2outh, <ast and %est) and the center of a SVIT 8 container. *ard@a$out: )he elements of a &ardAayout are stacked, on top of the other, like a deck of cards. 9rid@a$out: )he elements of a ;ridAayout are of equal si!e and are laid out using the square of a grid. 9rid>ag@a$out: )he elements of a ;rid+agAayout are organi!ed according to a grid. Bowe'er, the elements are of different si!e and may occupy more than one row or column of the grid. In addition, the rows and columns may ha'e different si!es. ,1.Which containers use a >order la$out as their default la$out? Ans: %indow, .rame and 9ialog classes use a +orderAayout as their layout. ,2.Which containers use a ?low la$out as their default la$out? Ans: Panel and pplet classes use the .lowAayout as their default layout. ,%.What are wrapper classes? Ans: %rapper classes are classes that allow primiti'e types to be accessed as objects. ,'.What are Vector! 3ashtable! @in<ed@ist and numeration? Ans: Vector : )he 3ector class pro'ides the capability to implement a growable array of objects. 3ashtable : )he Bashtable class implements a Bashtable data structure. Bashtable indexes and stores objects in a dictionary using hash codes as the object*s keys. Bash codes are integer 'alues that identify objects. @in<ed@ist: =emo'ing or inserting elements in the middle of an array can be done using AinkedAist. AinkedAist stores each object in a separate link whereas an array stores object references in consecuti'e locations. numeration: n object that implements the <numeration interface generates a series of elements, one at a time. It has two methods, namely has(ore<lements,) and next<lement,). Bas(ore<lemnts,) tests if this enumeration has more elements and next<lement method returns successi'e elements of the series. ,).What is the difference between set and list? Ans: 2et stores elements in an unordered way but does not contain duplicate elements, whereas list stores elements in an ordered way but may contain duplicate elements. ,,.What is a stream and what are the t$pes of =treams and classes of the =treams? Ans: 2tream is an abstraction that either produces or consumes information. )here are two types of 2treams and they are$ +yte 2treams$ Pro'ide a con'enient means for handling input and output of bytes. &haracter 2treams$ Pro'ide a con'enient means for handling input C output of characters. +yte 2treams classes$ re defined by using two abstract classes, namely Input2tream and Output2tream. &haracter 2treams classes$ re defined by using two abstract classes, namely =eader and %riter. SVIT 9 ,-.What is the difference between AeaderBWriter and "nput=treamB(utput =tream? Ans: )he =eader-%riter class is character"oriented and the Input2tream-Output2tream class is byte"oriented. ,..What is an "B( filter? Ans: n I-O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another. ,/.What is seriali&ation and deseriali&ation? Ans: 2eriali!ation is the process of writing the state of an object to a byte stream. 9eseriali!ation is the process of restoring these objects. -2.What is J0>*? Ans: :9+& is a set of :a'a PI for executing 2DA statements. )his PI consists of a set of classes and interfaces to enable programs to write pure :a'a 9atabase applications. -1.What are dri+ers a+ailable? Ans: a) :9+&"O9+& +ridge dri'er b) @ati'e PI Partly":a'a dri'er c) :9+&"@et Pure :a'a dri'er d) @ati'e"Protocol Pure :a'a dri'er -2.What is the difference between J0>* and (0>*? Ans: a) O+9& is for (icrosoft and :9+& is for :a'a applications. b) O9+& can*t be directly used with :a'a because it uses a & interface. c) O9+& makes use of pointers which ha'e been remo'ed totally from :a'a. d) O9+& mixes simple and ad'anced features together and has complex options for simple queries. +ut :9+& is designed to keep things simple while allowing ad'anced capabilities when required. e) O9+& requires manual installation of the O9+& dri'er manager and dri'er on all client machines. :9+& dri'ers are written in :a'a and :9+& code is automatically installable, secure, and portable on all platforms. f) :9+& PI is a natural :a'a interface and is built on O9+&. :9+& retains some of the basic features of O9+&. -%.What are the t$pes of J0>* 0ri+er ;odels and e4plain them? Ans: )here are two types of :9+& 9ri'er (odels and they are$ a) )wo tier model and b) )hree tier model )wo tier model$ In this model, :a'a applications interact directly with the database. :9+& dri'er is required to communicate with the particular database management system that is being accessed. 2DA statements are sent to the database and the results are gi'en to SVIT 10 user. )his model is referred to as client-ser'er configuration where user is the client and the machine that has the database is called as the ser'er. )hree tier model$ middle tier is introduced in this model. )he functions of this model are$ a) &ollection of 2DA statements from the client and handing it o'er to the database, b) =ecei'ing results from database to the client and c) (aintaining control o'er accessing and updating of the abo'e. -'.What are the steps in+ol+ed for ma<ing a connection with a database or how do $ou connect to a database? Ans: a) Aoading the dri'er $ )o load the dri'er, &lass. for@ame,) method is used. &lass. for@ame,Esun. jdbc. odbc. :dbcOdbc9ri'erE)F %hen the dri'er is loaded, it registers itself with the ja'a. sql. 9ri'er(anager class as an a'ailable database dri'er. b) (aking a connection with database$ )o open a connection to a gi'en database, 9ri'er(anager. get&onnection,) method is used. &onnection con G 9ri'er(anager. get&onnection ,Ejdbc$odbc$somedbE, HuserE, HpasswordE)F c) <xecuting 2DA statements $ )o execute a 2DA query, ja'a. sql. statements class is used. create2tatement,) method of &onnection to obtain a new 2tatement object. 2tatement stmt G con. create2tatement,)F query that returns data can be executed using the executeDuery,) method of 2tatement. )his method executes the statement and returns a ja'a. sql. =esult2et that encapsulates the retrie'ed data$ =esult2et rs G stmt. executeDuery,E2<A<&) I .=O( some tableE)F d) Process the results $ =esult2et returns one row at a time. @ext,) method of =esult2et object can be called to mo'e to the next row. )he get2tring,) and getObject,) methods are used for retrie'ing column 'alues$ while,rs. next,)) J 2tring e'ent G rs. get2tring,Ee'entE)F Object count G ,Integer) rs. getObject,EcountE)F -).What t$pe of dri+er did $ou use in project? Ans: :9+&"O9+& +ridge dri'er ,is a dri'er that uses nati'e,& language) libraries and makes calls to an existing O9+& dri'er to access a database engine). -,.What are the t$pes of statements in J0>*? Ans: 2tatement K )o be used create2tatement,) method for executing single 2DA statement Prepared2tatement K )o be used prepared2tatement,) method for executing same 2DA statement o'er and o'er. &allable2tatement K )o be used prepare&all,) method for multiple 2DA statements o'er and o'er. --.What is stored procedure? SVIT 11 Ans: 2tored procedure is a group of 2DA statements that forms a logical unit and performs a particular task. 2tored Procedures are used to encapsulate a set of operations or queries to execute on database. 2tored procedures can be compiled and executed with different parameters and results and may ha'e any combination of input-output parameters. -..3ow to create and call stored procedures? Ans: )o create stored procedures$ &reate procedure procedurename ,specify in, out and in out parameters) +<;I@ ny multiple 2DA statementF <@9F )o call stored procedures$ &allable2tatement csmt G con. prepare&all,EJcall procedure name,5,5)LE)F csmt. registerOutParameter,column no. , data type)F csmt. setInt,column no. , column name) csmt. execute,)F -/.What is ser+let? Ans: 2er'lets are modules that extend request-response"oriented ser'ers, such as ja'a"enabled web ser'ers. .or example, a ser'let might be responsible for taking data in an B)(A order"entry form and applying the business logic used to update a company*s order database. .2.What are the classes and interfaces for ser+lets? Ans: )here are two packages in ser'lets and they are ja'ax. ser'let and .1.What is the difference between an applet and a ser+let? Ans: a) 2er'lets are to ser'ers what applets are to browsers. b) pplets must ha'e graphical user interfaces whereas ser'lets ha'e no graphical user interfaces. .2.What is the difference between do#ost and do9et methods? Ans: a) do;et,) method is used to get information, while doPost,) method is used for posting information. b) do;et,) requests can*t send large amount of information and is limited to 47M" 488 characters. Bowe'er, doPost,)requests passes all of its data, of unlimited length. c) do;et,) request is appended to the request /=A in a query string and this allows the exchange is 'isible to the client, whereas a doPost,) request passes directly o'er the socket connection as part of its B))P request body and the exchange are in'isible to the client. .%.What is the life c$cle of a ser+let? Ans: <ach 2er'let has the same life cycle$ a) ser'er loads and initiali!es the ser'let by init ,) method. b) )he ser'let handles !ero or more client*s requests through ser'ice,) method. c) )he ser'er remo'es the ser'let through destroy,) method. SVIT 12 .'.Who is loading the init56 method of ser+let? Ans: %eb ser'er .).What are the different ser+ers a+ailable for de+eloping and deplo$ing =er+lets? Ans: a) :a'a %eb 2er'er b) :=un c) pache 2er'er d) @etscape Information 2er'er e) %eb Aogic .,.3ow man$ wa$s can we trac< client and what are the$? Ans: )he ser'let PI pro'ides two ways to track client state and they are$ a) /sing 2ession tracking and b) /sing &ookies. .-.What is session trac<ing and how do $ou trac< a user session in ser+lets? Ans: 2ession tracking is a mechanism that ser'lets use to maintain state about a series requests from the same user across some period of time. )he methods used for session tracking are$ a) /ser uthentication " occurs when a web ser'er restricts access to some of its resources to only those clients that log in using a recogni!ed username and password. b) Bidden form fields " fields are added to an B)(A form that are not displayed in the client*s browser. %hen the form containing the fields is submitted, the fields are sent back to the ser'er. c) /=A rewriting " e'ery /=A that the user clicks on is dynamically modified or rewritten to include extra information. )he extra information can be in the form of extra path information, added parameters or some custom, ser'er"specific /=A change. d) &ookies " a bit of information that is sent by a web ser'er to a browser and which can later be read back from that browser. e) Bttp2ession" places a limit on the number of sessions that can exist in memory. )his limit is set in the session. maxresidents property. ...What is =er+er-=ide "ncludes 5=="6? Ans: 2er'er"2ide Includes allows embedding ser'lets within B)(A pages using a special ser'let tag. In many ser'lets that support ser'lets, a page can be processed by the ser'er to include output from ser'lets at certain points inside the B)(A page. )his is accomplished using a special internal 22I@&A/9<, which processes the ser'let tags. 22I@&A/9< ser'let will be in'oked whene'er a file with an. shtml extension is requested. 2o B)(A files that include ser'er" side includes must be stored with an . shtml extension. ./.What are coo<ies and how will $ou use them? SVIT 13 Ans: &ookies are a mechanism that a ser'let uses to ha'e a client hold a small amount of state"information associated with the user. a) &reate a cookie with the &ookie constructor$ public &ookie,2tring name, 2tring 'alue) b) ser'let can send a cookie to the client by passing a &ookie object to the add&ookie,) method of Bttp2er'let=esponse$ public 'oid Bttp2er'let=esponse. add&ookie,&ookie cookie) c) ser'let retrie'es cookies by calling the get&ookies,) method of Bttp2er'let=equest$ public &ookieN O Bttp2er'let=equest. get&ookie,). /2."s it possible to communicate from an applet to ser+let and how man$ wa$s and how? Ans: ?es, there are three ways to communicate from an applet to ser'let and they are$ a) B))P &ommunication,)ext"based and object"based) b) 2ocket &ommunication c) =(I &ommunication /1.What is connection pooling? Ans: %ith ser'lets, opening a database connection is a major bottleneck because we are creating and tearing down a new connection for e'ery page request and the time taken to create connection will be more. &reating a connection pool is an ideal approach for a complicated ser'let. %ith a connection pool, we can duplicate only the resources we need to duplicate rather than the entire ser'let. connection pool can also intelligently manage the si!e of the pool and make sure each connection remains 'alid. number of connection pool packages are currently a'ailable. 2ome like 9b&onnection+roker are freely a'ailable from :a'a <xchange %orks by creating an object that dispenses connections and connection Ids on request. )he &onnectionPool class maintains a Bastable, using &onnection objects as keys and +oolean 'alues as stored 'alues. )he +oolean 'alue indicates whether a connection is in use or not. program calls get&onnection,) method of the &onnectionPool for getting &onnection object it can useF it calls return&onnection,) to gi'e the connection back to the pool. /2.Wh$ should we go for interser+let communication? Ans: 2er'lets running together in the same ser'er communicate with each other in se'eral ways. )he three major reasons to use interser'let communication are$ a) 9irect ser'let manipulation " allows to gain access to the other currently loaded ser'lets and perform certain tasks ,through the 2er'let&ontext object) b) 2er'let reuse " allows the ser'let to reuse the public methods of another ser'let. c) 2er'let collaboration " requires to communicate with each other by sharing specific information ,through method in'ocation) /%."s it possible to call ser+let with parameters in the 7A@? Ans: ?es. ?ou can call a ser'let with parameters in the syntax as ,5Param0 G xxx PP m4 G yyy). /'.What is =er+let chaining? SVIT 14 Ans: 2er'let chaining is a technique in which two or more ser'lets can cooperate in ser'icing a single request. In ser'let chaining, one ser'let*s output is piped to the next ser'let*s input. )his process continues until the last ser'let is reached. Its output is then sent back to the client. /).3ow do ser+lets handle multiple simultaneous reCuests? Ans: )he ser'er has multiple threads that are a'ailable to handle requests. %hen a request comes in, it is assigned to a thread, which calls a ser'ice method ,for example$ do;et,), doPost,) and ser'ice,)) of the ser'let. .or this reason, a single ser'let object can ha'e its ser'ice methods called by many threads at once. /,.What is the difference between :*#B"# and 70#? Ans: )&P-IP is a two"way communication between the client and the ser'er and it is a reliable and there is a confirmation regarding reaching the message to the destination. It is like a phone call. /9P is a one"way communication only between the client and the ser'er 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 "net address? Ans: <'ery computer connected to a network has an IP address. n IP address is a number that uniquely identifies each computer on the @et. n IP address is a 64"bit number. /..What is 0omain 8aming =er+ice508=6? Ans: It is 'ery difficult to remember a set of numbers,IP address) to connect to the Internet. )he 9omain @aming 2er'ice,9@2) is used to o'ercome this problem. It maps one particular IP address to a string of characters. .or example, www. mascom. com implies com is the domain name reser'ed for /2 commercial sites, moscom is the name of the company and www is the name of the specific computer, which is mascom*s ser'er. //.What is 7A@? Ans: /=A stands for /niform =esource Aocator and it points to resource files on the Internet. /=A has four components$ http$--www. address. com$#M-index.html, where http " protocol name, address " IP address or host name, #M " port number and index.html " file path. 122.What is A;" and steps in+ol+ed in de+eloping an A;" object? Ans: =emote (ethod In'ocation ,=(I) allows ja'a object that executes on one machine and to in'oke the method of a :a'a object to execute on another machine. )he steps in'ol'ed in de'eloping an =(I object are$ a) 9efine the interfaces b) Implementing these interfaces c) &ompile the interfaces and their implementations with the ja'a compiler d) &ompile the ser'er implementation with =(I compiler e) =un the =(I registry f) =un the application SVIT 15 SVIT 16