Sie sind auf Seite 1von 38

-1-

7 Layers of OSI Architechture ----------------------------1. Application Layer 2. Presentation Layer 3. Session Layer 4. Transport Layer 5. Network Layer 6. Link Layer 7. Electrical/Physical 7. Electrical/Physical ---------------------Responsible for defining various Electrical standards, like standardized Cables, Bit Stream Standards etc, to be used while communicating between HOSTS (Computers). 6. Link Layer ------------Responsible for Encoding & subsequent De-Coding of Data Packets at various Network points. 5. Network Layer ---------------Responsible for providing LOGICAL paths for Data packets to pass through. It basically provides SWITCHING & ROUTING facilities. 4. Transport Layer -----------------Responsible for TRANPARENT flow of data between HOSTS (Computers), without due consideration to HARDWARE details. This layer is not concerned as to which applications are sharing data; rather it is only concerned with TRANSFERRING DATA PACKETS FROM ONE POINT TO ANOTHER3. Session Layer ---------------Responsible for maintaining a REGISTRY of all currently active connections from various HOSTS (Computers). 2. Presentation Layer --------------------Responsible for isolating different Data formats from each other. Ex.: Encryption process involves the AUTOMATIC conversion of Application data Format to Network Format & Vice-Versa. 1. Application Layer -------------------nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

-2-

Responsible for END-USER friendly protocols, like HTTP, FTP, TELNET etc. Software Developers directly interact with this layer of protocol to write programs. What is a balanced tree? A binary tree is balanced if the depth of two subtrees of every node never differ by more than one

What is the difference between run time binding and compile time binding? Compile Time Binding : In case of operator overloading and function overloading the name of the function is resolved during the compile time . Even if there are two or more functions with the same name the compiler mangles the name so that each function is uniquely identified . This has to be resolved at compile time and is known as compile-time binding or early binding. Run Time Binding : In case of polymorphism (virtual functions) if a base class pointer(or reference) is allocated a pointer(or reference) of derived class the actual function called is determined only during runtime through the virtual table entry . This is runtime binding or late binding What does the following C statement do? while(*c++ = *d++); assuming c and d are pointers to characters. string copy utill zero appears How would you do conditional compilation preprocessors: #ifdef/ifndef #else/elif #endif #pragma What is a "constraint"? A constraint allows you to apply simple referential integrity checks to a table. There are four primary types of constraints that are currently supported by SQL Server: PRIMARY/UNIQUE - enforces uniqueness of a particular table column. DEFAULT - specifies a default value for a column in case an insert operation does not provide one. FOREIGN KEY - validates that every value in a column exists in a column of another table. CHECK - checks that every value stored in a column is in some specified list Each type of constraint performs a specific type of action. Write a function to compute the factorial of a given integer. factorial (n) { if n=0 then return 1 else return n*factorial(n-1) }
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

-3-

Loop is faster than recusive, so, here is a loop version: int factorial( int n) { int i; int result =1; for (i=n; i>0; i--) result *= i; return result; } What is a "functional dependency"? How does it relate to database table design? What functional dependence in the context of a database means is that : Assume that a table exists in the database called TABLE with a composite primary key (A, B) and other non-key attributes (C, D, E). Functional dependency in general, would mean that any non-key attribute C D or E being dependent on the primary key (A and B)in our table here. Partial functional dependency, on the other hand, is another corollary of the above, which states that all non-key attributes - C D or E - if dependent on the subset of the primary key (A and B) and not on it as a whole. Example : ---------Fully Functional Dependent : C D E --> A B Partial Functional dependency : C --> A D E --> B Hope that helps! Write a function to print the Fibonacci numbers 23 of 25 people found this post useful. I believe the top most solution would be more efficient if we tested n <=2 rather than checking n==0. This would remove unnecessary iterations. int fib( int n ){ if (n<=2) return 1; else return fib(n-1) + fib(n-2); } Declare a function pointer which takes a pointer to char as an argument and returns a void pointer. void* (*func_ptr)(char* parameter)

What is "index covering" of a query? Index covering means that "Data can be found only using indexes, without touching the tables"
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

-4-

A nonclustered index that includes (or covers) all columns used in a query is called a covering index. When SQL server can use a nonclustered index to resolve the query, it will prefer to scan the index rather than the table, which typically takes fewer data pages. If your query uses only columns included in the index, then SQL server may scan this index to produce the desired output. Given a linked list which is sorted, how will you insert in sorted way. void sortedInsert(struct node** headRef, struct node* newNode){ struct node** currentRef = headRef; while (*currentRef!=NULL && (*currentRef)->data < newNode->data){ currentRef = &((*currentRef)->next); } newNode-> = (*currentRef)->next; *currentRef = newNode; } What is a "join"? Joins merge the data of two related tables into a single result set, presenting a denormalized view of the data. 'join' used to connect two or more tables logically with or without common field.

Given a sequence of characters, how will you convert the lower case characters to upper case characters? Lower case to upper case is correctly like this: if (islower(c)) c = c-'a'+'A' Upper case to lower case is if (isuuper(c)) c = c-'A'+'a' Note. The condition tested is to prevent the translation of non-alphabetic characters. What is polymorphism? 'Polymorphism' is an object oriented term. Polymorphism may be defined as the ability of related objects to respond to the same message with different, but appropriate actions. In other words, polymorphism means taking more than one form. Polymorphism leads to two important aspects in Object Oriented terminology - Function Overloading and Function Overriding. Overloading is the practice of supplying more than one definition for a given function name in the same scope. The compiler is left to pick the appropriate version of the function or operator based on the arguments with which it is called. Overriding refers to the modifications made in the sub class to the inherited methods from the base class to change their behavior. Write a function that finds repeating characters in a string.
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

-5-

Maintain a character count table like int char_count[255]; //Initialize to 0 here Keep adding the count of each characters. Scan throughout the array and print the characters with count more than 1. Reverse a string. void strrev (char *s) { char *t = s + strlen(s) - 1; char ch = '\0'; while (s < t) { ch = *s; *s = *t; *t = ch; s++; t--; } } Implement an algorithm to sort a linked list 11 of 11 people found this post useful. node * insert(node * to_insert,node * sorted) { if (to_insert->value<sorted->value){ to_insert->next=sorted; return to_insert; } node * temp = sorted; while((temp->next!=null) && (to_insert->value>=temp->next->value) temp=temp->next; if (temp->next==null) { temp->next=to_insert; return sorted; } to_insert->next=temp->next; temp->next=to_insert; return sorted; } node * sort(node * list) { node * sorted=list; list=list->next; sorted->next=null; while (list!=null) { temp=list; list=list->next; temp->next=null; sorted=insert(temp,sorted); }
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

-6-

return sorted; } Implement an algorithm to sort an array int[] arraySort(int[] arr, int len) { for (int i=0;i<len;i++) { for (int j=i+1; j<len; j++) { if(arr[i]>arr[j]) { int buf=arr[i]; arr[i]=arr[j]; arr[j]=buf; } } return arr; } What are templates? ++ Templates allow u to generate families of functions or classes that can operate on a variety of different data types, freeing you from the need to create a separate function or class for each type. Using templates, u have the convenience of writing a single generic function or class definition, which the compiler automatically translates into a specific version of the function or class, for each of the different data types that your program actually uses. Many data structures and algorithms can be defined independently of the type of data they work with. You can increase the amount of shared code by separating data-dependent portions from dataindependent portions, and templates were introduced to help you do that. What is a "trigger"? Triggers are stored procedures created in order to enforce integrity rules in a database. A trigger is executed every time a data-modification operation occurs (i.e., insert, update or delete). Triggers are executed automatically on occurance of one of the data-modification operations.

Declare a void pointer.

void* p; malloc is just the library function called to allocated some memory and of course a void pointer will be returned , but it is the declaration of a void pointer. What is wrong with this? main(){ int *ptr; *ptr=10; }
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

-7-

The memory is not allocated...before assigning it a value 1. What is the difference between CGI and Servlet? 2. What is meant by a servlet? 3. What are the types of servlets? What is the difference between 2 types of Servlets? 4. What is the type of method for sending request from HTTP server ? 5. What are the exceptions thrown by Servlets? Why? 6. What is the life cycle of a servlet? 7. What is meant by cookies? Why is Cookie used? 8. What is HTTP Session? 9. What is the difference between GET and POST methods? 10. How can you run a Servlet Program? 11. What is the middleware? What is the functionality of Webserver? 12. What webserver is used for running the Servlets? 13. How do you invoke a Servelt? What is the difference in between doPost and doGet methods? 14. What is the difference in between the HTTPServlet and Generic Servlet? Explain their methods? Tell me their parameter names also? 15. What are session variable in Servlets? 16. What is meant by Session? Tell me something about HTTPSession Class? 17. What is Session Tracking? 18. Difference between doGet and doPost? 19. What are the methods in HttpServlet? 20. What are the types of SessionTracking? Why do you use Session Tracking in HttpServlet? 21. What will print out? main() { char *p1="name"; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20); while(*p2++ = *p1++); printf("%sn",p2); }

Answer:empty string. What will be printed as the result of the operation below: main() { int x=20,y=35; x=y++ + x++;
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

-8-

y= ++y + ++x; printf("%d%dn",x,y); }

Answer : 5794 What will be printed as the result of the operation below: main() { int x=5; printf("%d,%d,%dn",x,x< <2,x>>2); }

Answer: 5,20,1 22. What will be printed as the result of the operation below: #define swap(a,b) a=a+b;b=a-b;a=a-b; void main() { int x=5, y=10; swap (x,y); printf("%d %dn",x,y); swap2(x,y); printf("%d %dn",x,y); } int swap2(int a, int b) {

int temp;
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

-9-

temp=a; b=a; a=temp; return 0; }

Answer: 10, 5 10, 5 What will be printed as the result of the operation below: main() { char *ptr = " Cisco Systems"; *ptr++; printf("%sn",ptr); ptr++; printf("%sn",ptr); }

Answer:Cisco Systems isco systems What will be printed as the result of the operation below: main() { char s1[]="Cisco"; char s2[]= "systems"; printf("%s",s1); }

Answer: Cisco
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 10 -

What will be printed as the result of the operation below: main() { char *p1; char *p2; p1=(char *)malloc(25); p2=(char *)malloc(25); strcpy(p1,"Cisco"); strcpy(p2,"systems"); strcat(p1,p2); printf("%s",p1); }

Answer: Ciscosystems The following variable is available in file1.c, who can access it?: static int average;

Answer: all the functions in the file1.c can access the variable. WHat will be the result of the following code? #define TRUE 0 // somecode.

while(TRUE) { // } somecode

Answer: This will not go into the loop as TRUE is defined as 0. 23. What will be printed as the result of the operation below:
chetana_freshers@yahoogroups.com

nareshbethi@rediffmail.com

- 11 -

int x;

int modifyvalue() { return(x+=10); }

int changevalue(int x) { return(x+=1); }

void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%dn",x); x++; changevalue(x); printf("Second output:%dn",x); modifyvalue(); printf("Third output:%dn",x);
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 12 -

Answer: 12 , 13 , 13 What will be printed as the result of the operation below: main() { int x=10, y=15; x = x++; y = ++y; printf("%d %dn",x,y); }

Answer: 11, 16 What will be printed as the result of the operation below: main() { int a=0; if(a==0) printf("Cisco Systemsn"); printf("Cisco Systemsn"); }

Answer: Two lines with Cisco Systems will be printed. Q: Write a short code using C++ to print out all odd number from 1 to 100 using a for loop(Asked by Intacct.com people) for( unsigned int i = 1; i < = 100; i++ ) if( i & 0x00000001 ) cout << i<<","; ISO layers and what layer is the IP operated from?( Asked by Cisco system people)
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 13 -

cation, Presentation, Session, Transport, Network, Data link and Physical. The IP is operated in the Network layer. 3.Q: Write a program that ask for user input from 5 to 9 then calculate the average( Asked by Cisco system people) A.int main() { int MAX=4; int total =0; int average=0; int numb; cout<<"Please enter your input from 5 to 9"; cin>>numb; if((numb <5)&&(numb>9)) cout<<"please re type your input"; else for(i=0;i<=MAX; i++) { total = total + numb; average= total /MAX; } cout<<"The average number is"<<average<<endl; return 0; } 4.Q: Can you be bale to identify between Straight- through and Cross- over cable wiring? and in what case do you use Straight- through and Cross-over? (Asked by Cisco system people) A. Straight-through is type of wiring that is one to to one connection Cross- over is type of wiring which those wires are got switched We use Straight-through cable when we connect between NIC Adapter and Hub. Using Cross-over cable when connect between two NIC Adapters or sometime between two hubs. 5.Q: If you hear the CPU fan is running and the monitor power is still on, but you did not see any thing show up in the monitor screen. What would you do to find out what is going wrong? (Asked by WNI people) A. I would use the ping command to check whether the machine is still alive(connect to the network) or it is dead. This set of questions came from a prominent gaming company. As you can see, the answers are not given (the interviews are typically conducted by senior developers), but theres a set of notes with common mistakes to avoid. 1. Explain which of the following declarations will compile and what will be constant - a pointer or the value pointed at: o const char * o char const * o char * const Note: Ask the candidate whether the first declaration is pointing to a string or a single character. Both explanations are correct, but if he says that its a single character pointer, ask why a whole string is initialized as char* in C++. If he says this is a string declaration, ask him to declare a pointer to a single
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 14 -

character. Competent candidates should not have problems pointing out why const char* can be both a character and a string declaration, incompetent ones will come up with invalid reasons. Youre given a simple code for the class BankCustomer. Write the following functions: Copy constructor = operator overload == operator overload + operator overload (customers balances should be added up, as an example of joint account between husband and wife)
o o o o

2.

Note:Anyone confusing assignment and equality operators should be dismissed from the interview. The applicant might make a mistake of passing by value, not by reference. The candidate might also want to return a pointer, not a new object, from the addition operator. Slightly hint that youd like the value to be changed outside the function, too, in the first case. Ask him whether the statement customer3 = customer1 + customer2 would work in the second case. 3. What problems might the following macro bring to the application?

#define sq(x) x*x 4. Consider the following struct declarations:

struct A { A(){ cout << "A"; } }; struct B { B(){ cout << "B"; } }; struct C { C(){ cout << "C"; } }; struct D { D(){ cout << "D"; } }; struct E : D { E(){ cout << "E"; } }; struct F : A, B { C c; D d; E e; F() : B(), A(),d(),c(),e() { cout << "F"; } }; What constructors will be called when an instance of F is initialized? Produce the program output when this happens. 5. 6. 7. Anything wrong with this code? T *p = new T[10]; delete p;

nareshbethi@rediffmail.com

chetana_freshers@yahoogroups.com

- 15 -

Note: Incorrect replies: No, everything is correct", Only the first element of the array will be deleted", The entire array will be deleted, but only the first element destructor will be called". 8. 9. 10. Anything wrong with this code? T *p = 0; delete p;

Note: Typical wrong answer: Yes, the program will crash in an attempt to delete a null pointer. The candidate does not understand pointers. A very smart candidate will ask whether delete is overloaded for the class T. 11. Explain virtual inheritance. Draw the diagram explaining the initialization of the base class when virtual inheritance is used. Note: Typical mistake for applicant is to draw an inheritance diagram, where a single base class is inherited with virtual methods. Explain to the candidate that this is not virtual inheritance. Ask them for the classic definition of virtual inheritance. Such question might be too complex for a beginning or even intermediate developer, but any applicant with advanced C++ experience should be somewhat familiar with the concept, even though hell probably say hed avoid using it in a real project. Moreover, even the experienced developers, who know about virtual inheritance, cannot coherently explain the initialization process. If you find a candidate that knows both the concept and the initialization process well, hes hired. 12. Whats potentially wrong with the following code? 13. long value; 14. //some stuff 15. value &= 0xFFFF; Note: Hint to the candidate about the base platform theyre developing for. If the person still doesnt find anything wrong with the code, they are not experienced with C++. 16. What does the following code do and why would anyone write something like that?

void send (int *to, int * from, int count) { int n = (count + 7) / 8; switch ( count % 8) { case 0: do { *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; case 2: *to++ = *from++; case 1: *to++ = *from++;
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 16 -

} while ( --n > 0 ); } } 17. In the H file you see the following declaration:

class Foo { void Bar( void ) const ; }; Tell me all you know about the Bar() function. 1. In C++, what is the difference between method overloading and method overriding?Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). Method overriding is the ability of the inherited class rewriting the virtual method of the base class. 2. What methods can be overridden in Java? In C++ terminology, all public methods in Java are virtual. Therefore, all Java methods can be overwritten in subclasses except those that are declared final, static, and private. 3. In C, what is the difference between a static variable and global variable? A static variable declared outside of any function is accessible only to all the functions defined in the same file (as the static variable). However, a global variable can be accessed by any function (including the ones from different files). 4. In C, why is the void pointer useful? When would you use it? The void pointer is useful becuase it is a generic pointer that any pointer can be cast into and back again without loss of information. 5. What are the defining traits of an object-oriented language? The defining traits of an objectoriented langauge are: o encapsulation o inheritance o polymorphism What is pure virtual function? A class is made abstract by declaring one or more of its virtual functions to be pure. A pure virtual function is one with an initializer of = 0 in its declaration Q. Write a Struct Time where integer m, h, s are its members struct Time { int m; int h; int s; }; ow do you traverse a Btree in Backward in-order? Process the node in the right subtree Process the root Process the node in the left subtree Q. What is the two main roles of Operating System? As a resource manager As a virtual machine
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 17 -

Q. In the derived class, which data member of the base class are visible? In the public and protected sections. Some good C++ questions to ask a job applicant. 1. 2. How do you decide which integer type to use? What should the 64-bit integer type on new, 64-bit machines be?

3. Whats the best way to declare and define global variables? 4. What does extern mean in a function declaration? 5. Whats the auto keyword good for? 6. I cant seem to define a linked list node which contains a pointer to itself. 7. How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters? 8. How can I declare a function that returns a pointer to a function of its own type? 9. My compiler is complaining about an invalid redeclaration of a function, but I only define it once and call it once. Whats happening? 10. What can I safely assume about the initial values of variables which are not explicitly initialized? 11. Why cant I initialize a local array with a string? 12. What is the difference between char a[] = string"; and char *p = string"; ? 13. How do I initialize a pointer to a function? Thanks to Sachin Rastogi for contributing these. 1. What makes J2EE suitable for distributed multitiered Applications? - The J2EE platform uses a multitiered distributed application model. Application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on the tier in the multitiered J2EE environment to which the application component belongs. The J2EE application parts are: o Client-tier components run on the client machine. o Web-tier components run on the J2EE server. o Business-tier components run on the J2EE server. o Enterprise information system (EIS)-tier software runs on the EIS server. 2. What is J2EE? - J2EE is an environment for developing and deploying enterprise applications. The J2EE platform consists of a set of services, application programming interfaces (APIs), and protocols that provide the functionality for developing multitiered, web-based applications. 3. What are the components of J2EE application? - A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and communicates with other components. The J2EE specification defines the following J2EE components: 1. Application clients and applets are client components. 2. Java Servlet and JavaServer Pages technology components are web components. 3. Enterprise JavaBeans components (enterprise beans) are business components. 4. Resource adapter components provided by EIS and tool vendors. 4. What do Enterprise JavaBeans components contain? - Enterprise JavaBeans components contains Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier. All the business code is contained inside an Enterprise Bean which receives data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage. An enterprise bean also retrieves data from storage, processes it (if necessary), and sends it back to the client program. 5. Is J2EE application only a web-based? - No, It depends on type of application that client wants. A J2EE application can be web-based or non-web-based. if an application client executes on the client machine, it is a non-web-based J2EE application. The J2EE application can provide a way for users to handle tasks such as J2EE system or application administration. It typically has a graphical user interface created from Swing or AWT APIs, or a command-line interface. When user request, it can open an HTTP connection to establish communication with a servlet running in the web tier.
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 18 -

6. Are JavaBeans J2EE components? - No. JavaBeans components are not considered J2EE components by the J2EE specification. They are written to manage the data flow between an application client or applet and components running on the J2EE server or between server components and a database. JavaBeans components written for the J2EE platform have instance variables and get and set methods for accessing the data in the instance variables. JavaBeans components used in this way are typically simple in design and implementation, but should conform to the naming and design conventions outlined in the JavaBeans component architecture. 7. Is HTML page a web component? - No. Static HTML pages and applets are bundled with web components during application assembly, but are not considered web components by the J2EE specification. Even the server-side utility classes are not considered web components, either. 8. What can be considered as a web component? - J2EE Web components can be either servlets or JSP pages. Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content. 9. What is the container? - Containers are the interface between a component and the low-level platform specific functionality that supports the component. Before a Web, enterprise bean, or application client component can be executed, it must be assembled into a J2EE application and deployed into its container. 10. What are container services? - A container is a runtime support of a system-level entity. Containers provide components with services such as lifecycle management, security, deployment, and threading. 11. What is the web container? - Servlet and JSP containers are collectively referred to as Web containers. It manages the execution of JSP page and servlet components for J2EE applications. Web components and their container run on the J2EE server. 12. What is Enterprise JavaBeans (EJB) container? - It manages the execution of enterprise beans for J2EE applications. Enterprise beans and their container run on the J2EE server. 13. What is Applet container? - IManages the execution of applets. Consists of a Web browser and Java Plugin running on the client together. 14. How do we package J2EE components? - J2EE components are packaged separately and bundled into a J2EE application for deployment. Each component, its related files such as GIF and HTML files or server-side utility classes, and a deployment descriptor are assembled into a module and added to the J2EE application. A J2EE application is composed of one or more enterprise bean,Web, or application client component modules. The final enterprise solution can use one J2EE application or be made up of two or more J2EE applications, depending on design requirements. A J2EE application and each of its modules has its own deployment descriptor. A deployment descriptor is an XML document with an .xml extension that describes a components deployment settings. 15. What is a thin client? - A thin client is a lightweight interface to the application that does not have such operations like query databases, execute complex business rules, or connect to legacy applications. 16. What are types of J2EE clients? - Following are the types of J2EE clients: o Applets o Application clients o Java Web Start-enabled rich clients, powered by Java Web Start technology. o Wireless clients, based on Mobile Information Device Profile (MIDP) technology. 17. What is deployment descriptor? - A deployment descriptor is an Extensible Markup Language (XML) text-based file with an .xml extension that describes a components deployment settings. A J2EE application and each of its modules has its own deployment descriptor. For example, an enterprise bean module deployment descriptor declares transaction attributes and security authorizations for an enterprise bean. Because deployment descriptor information is declarative, it can be changed without modifying the bean source code. At run time, the J2EE server reads the deployment descriptor and acts upon the component accordingly. 18. What is the EAR file? - An EAR file is a standard JAR file with an .ear extension, named from Enterprise ARchive file. A J2EE application with all of its modules is delivered in EAR file. 19. What is JTA and JTS? - JTA is the abbreviation for the Java Transaction API. JTS is the abbreviation for the Jave Transaction Service. JTA provides a standard interface and allows you to demarcate transactions in a manner that is independent of the transaction manager implementation. The J2EE SDK implements the transaction manager with JTS. But your code doesnt call the JTS methods
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 19 -

directly. Instead, it invokes the JTA methods, which then call the lower-level JTS routines. Therefore, JTA is a high level transaction interface that your application uses to control transaction. and JTS is a low level transaction interface and ejb uses behind the scenes (client code doesnt directly interact with JTS. It is based on object transaction service(OTS) which is part of CORBA. 20. What is JAXP? - JAXP stands for Java API for XML. XML is a language for representing and describing text-based data which can be read and handled by any program or tool that uses XML APIs. It provides standard services to determine the type of an arbitrary piece of data, encapsulate access to it, discover the operations available on it, and create the appropriate JavaBeans component to perform those operations. 21. What is J2EE Connector? - The J2EE Connector API is used by J2EE tools vendors and system integrators to create resource adapters that support access to enterprise information systems that can be plugged into any J2EE product. Each type of database or EIS has a different resource adapter. Note: A resource adapter is a software component that allows J2EE application components to access and interact with the underlying resource manager. Because a resource adapter is specific to its resource manager, there is typically a different resource adapter for each type of database or enterprise information system. 22. What is JAAP? - The Java Authentication and Authorization Service (JAAS) provides a way for a J2EE application to authenticate and authorize a specific user or group of users to run it. It is a standard Pluggable Authentication Module (PAM) framework that extends the Java 2 platform security architecture to support user-based authorization. 23. What is Java Naming and Directory Service? - The JNDI provides naming and directory functionality. It provides applications with methods for performing standard directory operations, such as associating attributes with objects and searching for objects using their attributes. Using JNDI, a J2EE application can store and retrieve any type of named Java object. Because JNDI is independent of any specific implementations, applications can use JNDI to access multiple naming and directory services, including existing naming and directory services such as LDAP, NDS, DNS, and NIS. 24. What is Struts? - A Web page development framework. Struts combines Java Servlets, Java Server Pages, custom tags, and message resources into a unified framework. It is a cooperative, synergistic platform, suitable for development teams, independent developers, and everyone between. 25. How is the MVC design pattern used in Struts framework? - In the MVC design pattern, application flow is mediated by a central Controller. The Controller delegates requests to an appropriate handler. The handlers are tied to a Model, and each handler acts as an adapter between the request and the Model. The Model represents, or encapsulates, an applications business logic or state. Control is usually then forwarded back through the Controller to the appropriate View. The forwarding can be determined by consulting a set of mappings, usually loaded from a database or configuration file. This provides a loose coupling between the View and Model, which can make an application significantly easier to create and maintain. Controller: Servlet controller which supplied by Struts itself; View: what you can see on the screen, a JSP page and presentation components; Model: System state and a business logic JavaBeans. Thanks to Sachin Rastogi for sending this set in. 1. What is an Applet? Should applets have constructors? - Applets are small programs transferred through Internet, automatically installed and run as part of webbrowser. Applets implements functionality of a client. Applet is a dynamic and interactive program that runs inside a Web page displayed by a Java-capable browser. We dont have the concept of Constructors in Applets. Applets can be invoked either through browser or through Appletviewer utility provided by JDK. 2. What are the Applets Life Cycle methods? Explain them? - Following are methods in the life cycle of an Applet: o init() method - called when an applet is first loaded. This method is called only once in the entire cycle of an applet. This method usually intialize the variables to be used in the applet. o start( ) method - called each time an applet is started. o paint() method - called when the applet is minimized or refreshed. This method is used for drawing different strings, figures, and images on the applet window. o stop( ) method - called when the browser moves off the applets page.
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 20 -

destroy( ) method - called when the browser is finished with the applet. 3. What is the sequence for calling the methods by AWT for applets? - When an applet begins, the AWT calls the following methods, in this sequence: o init() o start() o paint()
o

When an applet is terminated, the following sequence of method calls takes place : stop() destroy() 4. How do Applets differ from Applications? - Following are the main differences: Application: Stand Alone, doesnt need web-browser. Applet: Needs no explicit installation on local machine. Can be transferred through Internet on to the local machine and may run as part of web-browser. Application: Execution starts with main() method. Doesnt work if main is not there. Applet: Execution starts with init() method. Application: May or may not be a GUI. Applet: Must run within a GUI (Using AWT). This is essential feature of applets. 5. Can we pass parameters to an applet from HTML page to an applet? How? - We can pass parameters to an applet using <param> tag in the following way: o <param name="param1 value="value1> o <param name="param2 value="value2>
o o

Access those parameters inside the applet is done by calling getParameter() method inside the applet. Note that getParameter() method returns String value corresponding to the parameter name. 6. How do we read number information from my applets parameters, given that Applets getParameter() method returns a string? - Use the parseInt() method in the Integer Class, the Float(String) constructor or parseFloat() method in the Class Float, or the Double(String) constructor or parseDoulbl() method in the class Double. 7. How can I arrange for different applets on a web page to communicate with each other? - Name your applets inside the Applet tag and invoke AppletContexts getApplet() method in your applet code to obtain references to the other applets on the page. 8. How do I select a URL from my Applet and send the browser to that page? - Ask the applet for its applet context and invoke showDocument() on that context object. URL targetURL; String URLString AppletContext context = getAppletContext(); try { targetURL = new URL(URLString); } catch (MalformedURLException e) {
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 21 -

// Code for recover from the exception } 9. context. showDocument (targetURL); 10. Can applets on different pages communicate with each other? - No, Not Directly. The applets will exchange the information at one meeting place either on the local file system or at remote system. 11. How do I determine the width and height of my application? - Use the getSize() method, which the Applet class inherits from the Component class in the Java.awt package. The getSize() method returns the size of the applet as a Dimension object, from which you extract separate width, height fields. The following code snippet explains this: 12. Dimension dim = getSize(); 13. int appletwidth = dim.width(); 14. int appletheight = dim.height(); 15. Which classes and interfaces does Applet class consist? - Applet class consists of a single class, the Applet class and three interfaces: AppletContext, AppletStub, and AudioClip. 16. What is AppletStub Interface? - The applet stub interface provides the means by which an applet and the browser communicate. Your code will not typically implement this interface. 17. What tags are mandatory when creating HTML to display an applet? 1. name, height, width 2. code, name 3. codebase, height, width 4. code, height, width Correct answer is d. 18. What are the Applets information methods? - The following are the Applets information methods: getAppletInfo() method: Returns a string describing the applet, its author, copyright information, etc. getParameterInfo( ) method: Returns an array of string describing the applets parameters. 19. What are the steps involved in Applet development? - Following are the steps involved in Applet development: o Create/Edit a Java source file. This file must contain a class which extends Applet class. o Compile your program using javac o Execute the appletviewer, specifying the name of your applets source file or html file. In case the applet information is stored in html file then Applet can be invoked using java enabled web browser. 20. Which method is used to output a string to an applet? Which function is this method included in? - drawString( ) method is used to output a string to an applet. This method is included in the paint method of the Applet. Thanks to Sachin Rastogi for contributing these. 1. What is meant by Controls and what are different types of controls? - Controls are componenets that allow a user to interact with your application. The AWT supports the following types of controls: o Labels o Push buttons o Check boxes o Choice lists o Lists o Scroll bars o Text components These controls are subclasses of Component.
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 22 -

2. Which method of the component class is used to set the position and the size of a component? - setBounds(). The following code snippet explains this: 3. txtName.setBounds(x,y,width,height); places upper left corner of the text field txtName at point (x,y) with the width and height of the text field set as width and height. 4. Which TextComponent method is used to set a TextComponent to the read-only state? setEditable() 5. How can the Checkbox class be used to create a radio button? - By associating Checkbox objects with a CheckboxGroup. 6. What methods are used to get and set the text label displayed by a Button object? getLabel( ) and setLabel( ) 7. What is the difference between a Choice and a List? - Choice: A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. List: A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items. 8. What is the difference between a Scollbar and a Scrollpane? - A Scrollbar is a Component, but not a Container. A Scrollpane is a Container and handles its own events and performs its own scrolling. 9. Which are true about the Container class? o The validate( ) method is used to cause a Container to be laid out and redisplayed. o The add( ) method is used to add a Component to a Container. o The getBorder( ) method returns information about a Containers insets. o getComponent( ) method is used to access a Component that is contained in a Container. Answers: a, b and d 10. Suppose a Panel is added to a Frame and a Button is added to the Panel. If the Frames font is set to 12-point TimesRoman, the Panels font is set to 10-point TimesRoman, and the Buttons font is not set, what font will be used to display the Buttons label? o 12-point TimesRoman o 11-point TimesRoman o 10-point TimesRoman o 9-point TimesRoman Answer: c. 11. What are the subclasses of the Container class? - The Container class has three major subclasses. They are: o Window o Panel o ScrollPane 12. Which object is needed to group Checkboxes to make them exclusive? - CheckboxGroup. 13. What are the types of Checkboxes and what is the difference between them? - Java supports two types of Checkboxes: o Exclusive o Non-exclusive. In case of exclusive Checkboxes, only one among a group of items can be selected at a time. I f an item from the group is selected, the checkbox currently checked is deselected and the new selection is highlighted. The exclusive Checkboxes are also called as Radio buttons. The non-exclusive checkboxes are not grouped together and each one can be selected independent of the other. 14. What is a Layout Manager and what are the different Layout Managers available in java.awt and what is the default Layout manager for the panel and the panel subclasses? - A
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 23 -

layout Manager is an object that is used to organize components in a container. The different layouts available in java.awt are: o FlowLayout: The elements of a FlowLayout are organized in a top to bottom, left to right fashion. o BorderLayout: The elements of a BorderLayout are organized at the borders (North, South, East and West) and the center of a container. o CardLayout: The elements of a CardLayout are stacked, one on top of the other, like a deck of cards. o GridLayout: The elements of a GridLayout are of equal size and are laid out using the square of a grid. o GridBagLayout: The elements of a GridBagLayout are organized according to a grid.However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes. The default Layout Manager of Panel and Panel sub classes is FlowLayout. 15. Can I add the same component to more than one container? - No. Adding a component to a container automatically removes it from any previous parent (container). 16. How can we create a borderless window? - Create an instance of the Window class, give it a size, and show it on the screen. Frame aFrame = new Frame(); Window aWindow = new Window(aFrame); aWindow.setLayout(new FlowLayout()); aWindow.add(new Button("Press Me")); aWindow.getBounds(50,50,200,200); aWindow.show(); 17. Can I create a non-resizable windows? If so, how? - Yes. By using setResizable() method in class Frame. 18. Which containers use a BorderLayout as their default layout? Which containers use a FlowLayout as their default layout? - The Window, Frame and Dialog classes use a BorderLayout as their default layout. The Panel and the Applet classes use the FlowLayout as their default layout. 19. How do you change the current layout manager for a container? o Use the setLayout method o Once created you cannot change the current layout manager of a component o Use the setLayoutManager method o Use the updateLayout method Answer: a. 20. What is the difference between a MenuItem and a CheckboxMenuItem?- The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked. 21. What are synchronized methods and synchronized statements? Synchronized methods are methods that are used to control access to an object. For example, a thread only executes a synchronized method after it has acquired the lock for the methods object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement. 22. What are different ways in which a thread can enter the waiting state? A thread can enter the waiting state by invoking its sleep() method, blocking on I/O, unsuccessfully attempting to acquire an
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 24 -

objects lock, or invoking an objects wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method. 23. Can a lock be acquired on a class? Yes, a lock can be acquired on a class. This lock is acquired on the classs Class object. 24. Whats new with the stop(), suspend() and resume() methods in new JDK 1.2? The stop(), suspend() and resume() methods have been deprecated in JDK 1.2. 25. What is the preferred size of a component? The preferred size of a component is the minimum component size that will allow the component to display normally. 26. What method is used to specify a containers layout? The setLayout() method is used to specify a containers layout. For example, setLayout(new FlowLayout()); will be set the layout as FlowLayout. 27. Which containers use a FlowLayout as their default layout? The Panel and Applet classes use the FlowLayout as their default layout. 28. What state does a thread enter when it terminates its processing? When a thread terminates its processing, it enters the dead state. 29. What is the Collections API? The Collections API is a set of classes and interfaces that support operations on collections of objects. One example of class in Collections API is Vector and Set and List are examples of interfaces in Collections API. 30. What is the List interface? The List interface provides support for ordered collections of objects. It may or may not allow duplicate elements but the elements must be ordered. 31. How does Java handle integer overflows and underflows? It uses those low order bytes of the result that can fit into the size of the type allowed by the operation. 32. What is the Vector class? The Vector class provides the capability to implement a growable array of objects. The main visible advantage of this class is programmer neednt to worry about the number of elements in the Vector. 33. What modifiers may be used with an inner class that is a member of an outer class? A (non-local) inner class may be declared as public, protected, private, static, final, or abstract. 34. If a method is declared as protected, where may the method be accessed? A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared. 35. What is an Iterator interface? The Iterator interface is used to step through the elements of a Collection. 36. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters? Unicode requires 16 bits, ASCII require 7 bits (although the ASCII character set uses only 7 bits, it is usually represented as 8 bits), UTF-8 represents characters using 8, 16, and 18 bit patterns, UTF-16 uses 16-bit and larger bit patterns 37. What is the difference between yielding and sleeping? Yielding means a thread returning to a ready state either from waiting, running or after creation, where as sleeping refers a thread going to a waiting state from running state. With reference to Java, when a task invokes its yield() method, it returns to the ready state and when a task invokes its sleep() method, it returns to the waiting state 38. What are wrapper classes? Wrapper classes are classes that allow primitive types to be accessed as objects. For example, Integer, Double. These classes contain many methods which can be used to manipulate basic data types 39. Does garbage collection guarantee that a program will not run out of memory? No, it doesnt. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection. The main purpose of Garbage Collector is recover the memory from the objects which are no longer required when more memory is needed. 40. Name Component subclasses that support painting? The following classes support painting: Canvas, Frame, Panel, and Applet. 41. What is a native method? A native method is a method that is implemented in a language other than Java. For example, one method may be written in C and can be called in Java. 42. How can you write a loop indefinitely? for(;;) //for loop while(true); //always true
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 25 -

43. Can an anonymous class be declared as implementing an interface and extending a class? An anonymous class may implement an interface or extend a superclass, but may not be declared to do both. 44. What is the purpose of finalization? The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected. For example, closing a opened file, closing a opened database Connection. 45. What invokes a threads run() method? After a thread is started, via its start() method or that of the Thread class, the JVM invokes the threads run() method when the thread is initially executed. 46. What is the GregorianCalendar class? The GregorianCalendar provides support for traditional Western calendars. 47. What is the SimpleTimeZone class? The SimpleTimeZone class provides support for a Gregorian calendar. 48. What is the Properties class? The properties class is a subclass of Hashtable that can be read from or written to a stream. It also provides the capability to specify a set of default values to be used. 49. What is the purpose of the Runtime class? The purpose of the Runtime class is to provide access to the Java runtime system. 50. What is the purpose of the System class? The purpose of the System class is to provide access to system resources. 51. What is the purpose of the finally clause of a try-catch-finally statement? The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught. For example, try { //some statements } catch { // statements when exception is cought } finally { //statements executed whether exception occurs or not } 52. What is the Locale class? The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region. 53. What must a class do to implement an interface? It must provide all of the methods in the interface and identify the interface in its implements clause. 54. What is a class? A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind. 55. What is a object? An object is a software bundle of variables and related methods.An instance of a class depicting the state and behavior at that particular time in real world. 56. What is a method? Encapsulation of a functionality which can be called to perform specific tasks. 57. What is encapsulation? Explain with an example. Encapsulation is the term given to the process of hiding the implementation details of the object. Once an object is encapsulated, its implementation details are not immediately accessible any more. Instead they are packaged and are only indirectly accessible via the interface of the object 58. What is inheritance? Explain with an example. Inheritance in object oriented programming means that a class of objects can inherit properties and methods from another class of objects. 59. What is polymorphism? Explain with an example. In object-oriented programming, polymorphism refers to a programming languages ability to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes. For example, given a base class shape, polymorphism enables the programmer to define different area methods for any number of derived classes, such as circles, rectangles and triangles. No matter what
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 26 -

shape an object is, applying the area method to it will return the correct results. Polymorphism is considered to be a requirement of any true object-oriented programming language 60. Is multiple inheritance allowed in Java? No, multiple inheritance is not allowed in Java. 61. What is interpreter and compiler? Java interpreter converts the high level language code into a intermediate form in Java called as bytecode, and then executes it, where as a compiler converts the high level language code to machine language making it very hardware specific 62. What is JVM? The Java interpreter along with the runtime environment required to run the Java application in called as Java virtual machine(JVM) 63. What are the different types of modifiers? There are access modifiers and there are other identifiers. Access modifiers are public, protected and private. Other are final and static. 64. What are the access modifiers in Java? There are 3 access modifiers. Public, protected and private, and the default one if no identifier is specified is called friendly, but programmer cannot specify the friendly identifier explicitly. 65. What is a wrapper class? They are classes that wrap a primitive data type so it can be used as a object 66. What is a static variable and static method? Whats the difference between two? The modifier static can be used with a variable and method. When declared as static variable, there is only one variable no matter how instances are created, this variable is initialized when the class is loaded. Static method do not need a class to be instantiated to be called, also a non static method cannot be called from static method. 67. What is garbage collection? Garbage Collection is a thread that runs to reclaim the memory by destroying the objects that cannot be referenced anymore. 68. What is abstract class? Abstract class is a class that needs to be extended and its methods implemented, aclass has to be declared abstract if it has one or more abstract methods. 69. What is meant by final class, methods and variables? This modifier can be applied to class method and variable. When declared as final class the class cannot be extended. When declared as final variable, its value cannot be changed if is primitive value, if it is a reference to the object it will always refer to the same object, internal attributes of the object can be changed. 70. What is interface? Interface is a contact that can be implemented by a class, it has method that need implementation. 71. What is method overloading? Overloading is declaring multiple method with the same name, but with different argument list. 72. What is method overriding? Overriding has same method name, identical arguments used in subclass. 73. What is singleton class? Singleton class means that any given time only one instance of the class is present, in one JVM. 74. What is the difference between an array and a vector? Number of elements in an array are fixed at the construction time, whereas the number of elements in vector can grow dynamically. 75. What is a constructor? In Java, the class designer can guarantee initialization of every object by providing a special method called a constructor. If a class has a constructor, Java automatically calls that constructor when an object is created, before users can even get their hands on it. So initialization is guaranteed. 76. What is casting? Conversion of one type of data to another when appropriate. Casting makes explicitly converting of data. 77. What is the difference between final, finally and finalize? The modifier final is used on class variable and methods to specify certain behaviour explained above. And finally is used as one of the loop in the try catch blocks, It is used to hold code that needs to be executed whether or not the exception occurs in the try catch block. Java provides a method called finalize( ) that can be defined in the class. When the garbage collector is ready to release the storage ed for your object, it will first call finalize( ), and only on the next garbage-collection pass will it reclaim the objects memory. So finalize( ), gives you the ability to perform some important cleanup at the time of garbage collection. 78. What is are packages? A package is a collection of related classes and interfaces providing access protection and namespace management. 79. What is a super class and how can you call a super class? When a class is extended that is derived from another class there is a relationship is created, the parent class is referred to as the super class by the derived class that is the child. The derived class can make a call to the super class using the keyword super. If used in the constructor of the derived class it has to be the first statement.
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 27 -

80. What is meant by a Thread? Thread is defined as an instantiated parallel process of a given program. 81. What is multi-threading? Multi-threading as the name suggest is the scenario where more than one threads are running. 82. What are two ways of creating a thread? Which is the best way and why? Two ways of creating threads are, one can extend from the Java.lang.Thread and can implement the rum method or the run method of a different class can be called which implements the interface Runnable, and the then implement the run() method. The latter one is mostly used as first due to Java rule of only one class inheritance, with implementing the Runnable interface that problem is sorted out. 83. What is deadlock? Deadlock is a situation when two threads are waiting on each other to release a resource. Each thread waiting for a resource which is held by the other waiting thread. In Java, this resource is usually the object lock obtained by the synchronized keyword. 84. What are the three types of priority? MAX_PRIORITY which is 10, MIN_PRIORITY which is 1, NORM_PRIORITY which is 5. 85. What is the use of synchronizations? Every object has a lock, when a synchronized keyword is used on a piece of code the, lock must be obtained by the thread first to execute that code, other threads will not be allowed to execute that piece of code till this lock is released. 86. What is the protocol used by server and client ? 87. Can I modify an object in CORBA ? 88. What is the functionality stubs and skeletons ? 89. What is the mapping mechanism used by Java to identify IDL language ? 90. Diff between Application and Applet ? 91. What is serializable Interface ? 92. What is the difference between CGI and Servlet ? 93. What is the use of Interface ? 94. Why Java is not fully objective oriented ? 95. Why does not support multiple Inheritance ? 96. What it the root class for all Java classes ? 97. What is polymorphism ? 98. Suppose If we have variable I in run method, If I can create one or more thread each thread will occupy a separate copy or same variable will be shared ? 99. In servlets, we are having a web page that is invoking servlets username and password ? which is checked in the database ? Suppose the second page also If we want to verify the same information whether it will connect to the database or it will be used previous information? 100. What are virtual functions ? 101. Write down how will you create a binary Tree ? 102. What are the traverses in Binary Tree ? 103. Write a program for recursive Traverse ? 104. What are session variable in Servlets ? 105. What is client server computing ? 106. What is Constructor and Virtual function? Can we call Virtual function in a constructor ? 107. Why we use OOPS concepts? What is its advantage ? 108. What is the middleware ? What is the functionality of Webserver ? 109. Why Java is not 100 % pure OOPS ? ( EcomServer ) 110. When we will use an Interface and Abstract class ? 111. What is an RMI? 112. How will you pass parameters in RMI ? Why u serialize? 113. What is the exact difference in between Unicast and Multicast object ? Where we will use ? 114. What is the main functionality of the Remote Reference Layer ? 115. How do you download stubs from a Remote place ? 116. What is the difference in between C++ and Java ? can u explain in detail ? 117. I want to store more than 10 objects in a remote server ? Which methodology will follow ? 118. What is the main functionality of the Prepared Statement ? 119. What is meant by static query and dynamic query ? 120. What are the Normalization Rules ? Define the Normalization ? 121. What is meant by Servlet? What are the parameters of the service method ? 122. What is meant by Session ? Tell me something about HTTPSession Class ?
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 28 -

123. How do you invoke a Servlet? What is the difference in between doPost and doGet methods ? 124. What is the difference in between the HTTPServlet and Generic Servlet ? Explain their methods ? Tell me their parameter names also ? 125. Have you used threads in Servlet ? 126. Write a program on RMI and JDBC using StoredProcedure ? 127. How do you sing an Applet ? 128. In a Container there are 5 components. I want to display the all the components names, how will you do that one ? 129. Why there are some null interface in java ? What does it mean ? Give me some null interfaces in JAVA ? 130. Tell me the latest versions in JAVA related areas ? 131. What is meant by class loader ? How many types are there? When will we use them ? 132. How do you load an Image in a Servlet ? 133. What is meant by flickering ? 134. What is meant by distributed Application ? Why we are using that in our applications ? 135. What is the functionality of the stub ? 136. Have you used any version control ? 137. What is the latest version of JDBC ? What are the new features are added in that ? 138. Explain 2 tier and 3 -tier Architecture ? 139. What is the role of the webserver ? 140. How have you done validation of the fields in your project ? 141. What is the main difficulties that you are faced in your project ? 142. What is meant by cookies ? Explain ? What is meant by static query and dynamic query? Ans: Static query is a query that is fixed and doesn\t varry at the run time. Where as Dynamic query varries with the change in the values at the run time. For example: \"select * from emp where name = \sachin\\ is a static query and always returns the same result. \"select * from emp where name = \\ + vName + \"\\ is a dynamic query as the result of this query will be based on the value of vName. What are the Normalization Rules? Define the Normalization? Ans: Normalization is the process of putting things right, making them normal. This is needed for: 1. Avoid Redundancy 2. Data Integrity There are many forms in which a relation can be normalized: 1. INF 2. 2NF 3. 3NF 4. BCNF 5. 4NF 6. 5NF Thanks to Sachin Rastogi for sending in Java database interview questions. 1. What are the steps involved in establishing a JDBC connection? This action involves two steps: loading the JDBC driver and making the connection. 2. How can you load the drivers? Loading the driver or drivers you want to use is very simple and involves just one line of code. If, for example, you want to use the JDBC-ODBC Bridge driver, the following code will load it: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Your driver documentation will give you the class name to use. For instance, if the class name is jdbc.DriverXYZ, you would load the driver with the following line of code:
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 29 -

Class.forName("jdbc.DriverXYZ"); 3. What will Class.forName do while loading drivers? It is used to create an instance of a driver and register it with the DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS. 4. How can you make the connection? To establish a connection you need to have the appropriate driver connect to the DBMS. The following line of code illustrates the general idea: String url = jdbc:odbc:Fred"; Connection con = DriverManager.getConnection(url, Fernanda", J8?); 5. How can you create JDBC statements and what are they? A Statement object is what sends your SQL statement to the DBMS. You simply create a Statement object and then execute it, supplying the appropriate execute method with the SQL statement you want to send. For a SELECT statement, the method to use is executeQuery. For statements that create or modify tables, the method to use is executeUpdate. It takes an instance of an active connection to create a Statement object. In the following example, we use our Connection object con to create the Statement object Statement stmt = con.createStatement(); 6. How can you retrieve data from the ResultSet? JDBC returns results in a ResultSet object, so we need to declare an instance of the class ResultSet to hold our results. The following code demonstrates declaring the ResultSet object rs. ResultSet rs = stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES"); String s = rs.getString("COF_NAME"); The method getString is invoked on the ResultSet object rs, so getString() will retrieve (get) the value stored in the column COF_NAME in the current row of rs. 7. What are the different types of Statements? Regular statement (use createStatement method), prepared statement (use prepareStatement method) and callable statement (use prepareCall) 8. How can you use PreparedStatement? This special type of statement is derived from class Statement.If you need a Statement object to execute many times, it will normally make sense to use a PreparedStatement object instead. The advantage to this is that in most cases, this SQL statement will be sent to the DBMS right away, where it will be compiled. As a result, the PreparedStatement object contains not just an SQL statement, but an SQL statement that has been precompiled. This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatements SQL statement without having to compile it first. 9. PreparedStatement updateSales = 10. con.prepareStatement("UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ?"); 11. What does setAutoCommit do? When a connection is created, it is in auto-commit mode. This means that each individual SQL statement is treated as a transaction and will be automatically committed right after it is executed. The way to allow two or more statements to be grouped into a transaction is to disable auto-commit mode: con.setAutoCommit(false); Once auto-commit mode is disabled, no SQL statements will be committed until you call the method commit explicitly.
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 30 -

con.setAutoCommit(false); PreparedStatement updateSales = con.prepareStatement( "UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ?"); updateSales.setInt(1, 50); updateSales.setString(2, "Colombian"); updateSales.executeUpdate(); PreparedStatement updateTotal = con.prepareStatement("UPDATE COFFEES SET TOTAL = TOTAL + ? WHERE COF_NAME LIKE ?"); updateTotal.setInt(1, 50); updateTotal.setString(2, "Colombian"); updateTotal.executeUpdate(); con.commit(); con.setAutoCommit(true); 12. How do you call a stored procedure from JDBC? The first step is to create a CallableStatement object. As with Statement an and PreparedStatement objects, this is done with an open Connection object. A CallableStatement object contains a call to a stored procedure. 13. CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}"); 14. ResultSet rs = cs.executeQuery(); 15. How do I retrieve warnings? SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or a ResultSet object. Each of these classes has a getWarnings method, which you must invoke in order to see the first warning reported on the calling object: 16. SQLWarning warning = stmt.getWarnings(); 17. if (warning != null) 18. { 19. System.out.println("n---Warning---n"); 20. while (warning != null) 21. { 22. System.out.println("Message: " + warning.getMessage()); 23. System.out.println("SQLState: " + warning.getSQLState()); 24. System.out.print("Vendor error code: "); 25. System.out.println(warning.getErrorCode()); 26. System.out.println(""); 27. warning = warning.getNextWarning(); 28. } 29. } 30. How can you move the cursor in scrollable result sets? One of the new features in the JDBC 2.0 API is the ability to move a result sets cursor backward as well
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 31 -

as forward. There are also methods that let you move the cursor to a particular row and check the position of the cursor. Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet srs = stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES"); The first argument is one of three constants added to the ResultSet API to indicate the type of a ResultSet object: TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE , and TYPE_SCROLL_SENSITIVE. The second argument is one of two ResultSet constants for specifying whether a result set is read-only or updatable: CONCUR_READ_ONLY and CONCUR_UPDATABLE. The point to remember here is that if you specify a type, you must also specify whether it is read-only or updatable. Also, you must specify the type first, and because both parameters are of type int , the compiler will not complain if you switch the order. Specifying the constant TYPE_FORWARD_ONLY creates a nonscrollable result set, that is, one in which the cursor moves only forward. If you do not specify any constants for the type and updatability of a ResultSet object, you will automatically get one that is TYPE_FORWARD_ONLY and CONCUR_READ_ONLY. 31. Whats the difference between TYPE_SCROLL_INSENSITIVE , and TYPE_SCROLL_SENSITIVE? You will get a scrollable ResultSet object if you specify one of these ResultSet constants.The difference between the two has to do with whether a result set reflects changes that are made to it while it is open and whether certain methods can be called to detect these changes. Generally speaking, a result set that is TYPE_SCROLL_INSENSITIVE does not reflect changes made while it is still open and one that is TYPE_SCROLL_SENSITIVE does. All three types of result sets will make changes visible if they are closed and then reopened: 32. Statement stmt = 33. con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); 34. ResultSet srs = 35. stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES"); 36. srs.afterLast(); 37. while (srs.previous()) 38. { 39. String name = srs.getString("COF_NAME"); 40. float price = srs.getFloat("PRICE"); 41. System.out.println(name + " " + price); 42. } 43. How to Make Updates to Updatable Result Sets? Another new feature in the JDBC 2.0 API is the ability to update rows in a result set using methods in the Java programming language rather than having to send an SQL command. But before you can take advantage of this capability, you need to create a ResultSet object that is updatable. In order to do this, you supply the ResultSet constant CONCUR_UPDATABLE to the createStatement method. 44. Connection con = 45. DriverManager.getConnection("jdbc:mySubprotocol:mySubName"); 46. Statement stmt = 47. con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); 48. ResultSet uprs = 49. stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES"); 1. What is JSP? Describe its concept. JSP is a technology that combines HTML/XML markup languages and elements of Java programming Language to return dynamic content to the Web client, It is normally used to handle Presentation logic of a web application, although it may have business logic. 2. What are the lifecycle phases of a JSP? JSP page looks like a HTML page but is a servlet. When presented with JSP page the JSP engine does the following 7 phases.
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 32 -

1. Page translation: -page is parsed, and a java file which is a servlet is created. 2. Page compilation: page is compiled into a class file 3. Page loading : This class file is loaded. 4. Create an instance :- Instance of servlet is created 5. jspInit() method is called 6. _jspService is called to handle service calls 7. _jspDestroy is called to destroy it when the servlet is not required. 3. What is a translation unit? JSP page can include the contents of other HTML pages or other JSP files. This is done by using the include directive. When the JSP engine is presented with such a JSP page it is converted to one servlet class and this is called a translation unit, Things to remember in a translation unit is that page directives affect the whole unit, one variable declaration cannot occur in the same unit more than once, the standard action jsp:useBean cannot declare the same bean twice in one unit. 4. How is JSP used in the MVC model? JSP is usually used for presentation in the MVC pattern (Model View Controller ) i.e. it plays the role of the view. The controller deals with calling the model and the business classes which in turn get the data, this data is then presented to the JSP for rendering on to the client. 5. What are context initialization parameters? Context initialization parameters are specified by the <context-param> in the web.xml file, these are initialization parameter for the whole application and not specific to any servlet or JSP. 6. What is a output comment? A comment that is sent to the client in the viewable page source. The JSP engine handles an output comment as un-interpreted HTML text, returning the comment in the HTML output sent to the client. You can see the comment by viewing the page source from your Web browser. 7. What is a Hidden Comment? A comment that documents the JSP page but is not sent to the client. The JSP engine ignores a hidden comment, and does not process any code within hidden comment tags. A hidden comment is not sent to the client, either in the displayed JSP page or the HTML page source. The hidden comment is useful when you want to hide or comment out part of your JSP page. 8. What is a Expression? Expressions are act as place holders for language expression, expression is evaluated each time the page is accessed. 9. What is a Declaration? It declares one or more variables or methods for use later in the JSP source file. A declaration must contain at least one complete declarative statement. You can declare any number of variables or methods within one declaration tag, as long as semicolons separate them. The declaration must be valid in the scripting language used in the JSP file. 10. What is a Scriptlet? A scriptlet can contain any number of language statements, variable or method declarations, or expressions that are valid in the page scripting language. Within scriptlet tags, you can declare variables or methods to use later in the file, write expressions valid in the page scripting language, use any of the JSP implicit objects or any object declared with a <jsp:useBean>. 11. What are the implicit objects? List them. Certain objects that are available for the use in JSP documents without being declared first. These objects are parsed by the JSP engine and inserted into the generated servlet. The implicit objects are: o request o response o pageContext o session o application o out o config o page o exception 12. Whats the difference between forward and sendRedirect? When you invoke a forward request, the request is sent to another resource on the server, without the client being informed that a different resource is going to process the request. This process occurs completely with in the web container And then returns to the calling method. When a sendRedirect method is invoked, it causes the web container to return to the browser indicating that a new URL should be requested. Because the browser issues a completely new request any object that are stored as request attributes before the redirect occurs will be lost. This extra round trip a redirect is slower than forward.
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 33 -

13. What are the different scope values for the <jsp:useBean>? The different scope values for <jsp:useBean> are: o page o request o session o application 14. Why are JSP pages the preferred API for creating a web-based client program? Because no plug-ins or security policy files are needed on the client systems(applet does). Also, JSP pages enable cleaner and more module application design because they provide a way to separate applications programming from web page design. This means personnel involved in web page design do not need to understand Java programming language syntax to do their jobs. 15. Is JSP technology extensible? Yes, it is. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries. 16. What is difference between custom JSP tags and beans? Custom JSP tag is a tag you defined. You define how a tag, its attributes and its body are interpreted, and then group your tags into collections called tag libraries that can be used in any number of JSP files. Custom tags and beans accomplish the same goals encapsulating complex behavior into simple and accessible forms. There are several differences: o Custom tags can manipulate JSP content; beans cannot. o Complex operations can be reduced to a significantly simpler form with custom tags than with beans. o Custom tags require quite a bit more work to set up than do beans. o Custom tags usually define relatively self-contained behavior, whereas beans are often defined in one servlet and used in a different servlet or JSP page. o Custom tags are available only in JSP 1.1 and later, but beans can be used in all JSP 1.x versions. 17. What is the difference between an Abstract class and Interface ? 18. What is user defined exception ? 19. What do you know about the garbage collector ? 20. What is the difference between C++ & Java ? 21. Explain RMI Architecture? 22. How do you communicate in between Applets & Servlets ? 23. What is the use of Servlets ? 24. What is JDBC? How do you connect to the Database ? 25. In an HTML form I have a Button which makes us to open another page in 15 seconds. How will do you that ? 26. What is the difference between Process and Threads ? 27. What is the difference between RMI & Corba ? 28. What are the services in RMI ? 29. How will you initialize an Applet ? 30. What is the order of method invocation in an Applet ? 31. When is update method called ? 32. How will you pass values from HTML page to the Servlet ? 33. Have you ever used HashTable and Dictionary ? 34. How will you communicate between two Applets ? 35. What are statements in JAVA ? 36. What is JAR file ? 37. What is JNI ? 38. What is the base class for all swing components ? 39. What is JFC ? 40. What is Difference between AWT and Swing ? 41. Considering notepad/IE or any other thing as process, What will happen if you start notepad or IE 3 times? Where 3 processes are started or 3 threads are started ? 42. How does thread synchronization occurs inside a monitor ? 43. How will you call an Applet using a Java Script function ? 44. Is there any tag in HTML to upload and download files ? 45. Why do you Canvas ?
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 34 -

46. How can you push data from an Applet to Servlet ? 47. What are 4 drivers available in JDBC ? 48. How you can know about drivers and database information ? 49. If you are truncated using JDBC, How can you know ..that how much data is truncated ? 50. And What situation , each of the 4 drivers used ? 51. How will you perform transaction using JDBC ? 52. In RMI, server object first loaded into the memory and then the stub reference is sent to the client ? or whether a stub reference is directly sent to the client ? 53. Suppose server object is not loaded into the memory, and the client request for it , what will happen? 54. What is serialization ? 55. Can you load the server object dynamically? If so, what are the major 3 steps involved in it ? 56. What is difference RMI registry and OSAgent ? 57. To a server method, the client wants to send a value 20, with this value exceeds to 20,. a message should be sent to the client ? What will you do for achieving for this ? 58. What are the benefits of Swing over AWT ? 59. Where the CardLayout is used ? 60. What is the Layout for ToolBar ? 61. What is the difference between Grid and GridbagLayout ? 62. How will you add panel to a Frame ? 63. What is the corresponding Layout for Card in Swing ? 64. What is light weight component ? 65. Can you run the product development on all operating systems ? 66. What is the webserver used for running the Servlets ? 67. What is Servlet API used for connecting database ? 68. What is bean ? Where it can be used ? 69. What is difference in between Java Class and Bean ? 70. Can we send object using Sockets ? 71. What is the RMI and Socket ? 72. How to communicate 2 threads each other ? 73. What are the files generated after using IDL to Java Compilet ?

Which set of statements will successfully invoke this function within SQL*Plus? 1. VARIABLE g_yearly_budget NUMBER EXECUTE g_yearly_budget := GET_BUDGET(11); 2. VARIABLE g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11); 3. VARIABLE :g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11); 4. VARIABLE g_yearly_budget NUMBER :g_yearly_budget := GET_BUDGET(11); 2. CREATE OR REPLACE PROCEDURE update_theater 3. (v_name IN VARCHAR v_theater_id IN NUMBER) IS 4. BEGIN 5. UPDATE theater 6. SET name = v_name 7. WHERE id = v_theater_id; 8. END update_theater; 9. When invoking this procedure, you encounter the error: ORA-000: Unique constraint(SCOTT.THEATER_NAME_UK) violated. How should you modify the function to handle this error?
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 35 -

1. An user defined exception must be declared and associated with the error code and handled in the EXCEPTION section. 2. Handle the error in EXCEPTION section by referencing the error code directly. 3. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception. 4. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement. 10. Read the following code: 11. CREATE OR REPLACE PROCEDURE calculate_budget IS 12. v_budget studio.yearly_budget%TYPE; 13. BEGIN 14. v_budget := get_budget(11); 15. IF v_budget < 30000 16. THEN 17. set_budget(11,30000000); 18. END IF; 19. END; You are about to add an argument to CALCULATE_BUDGET. What effect will this have? 1. The GET_BUDGET function will be marked invalid and must be recompiled before the next execution. 2. The SET_BUDGET function will be marked invalid and must be recompiled before the next execution. 3. Only the CALCULATE_BUDGET procedure needs to be recompiled. 4. All three procedures are marked invalid and must be recompiled. 20. Which procedure can be used to create a customized error message? 1. RAISE_ERROR 2. SQLERRM 3. RAISE_APPLICATION_ERROR 4. RAISE_SERVER_ERROR 21. The CHECK_THEATER trigger of the THEATER table has been disabled. Which command can you issue to enable this trigger? 1. ALTER TRIGGER check_theater ENABLE; 2. ENABLE TRIGGER check_theater; 3. ALTER TABLE check_theater ENABLE check_theater; 4. ENABLE check_theater; 22. Examine this database trigger 23. CREATE OR REPLACE TRIGGER prevent_gross_modification 24. {additional trigger information} 25. BEGIN 26. IF TO_CHAR(sysdate, DY) = MON 27. THEN 28. RAISE_APPLICATION_ERROR(-20000,Gross receipts cannot be deleted on Monday); 29. END IF; 30. END; This trigger must fire before each DELETE of the GROSS_RECEIPT table. It should fire only once for the entire DELETE statement. What additional information must you add? 1. 2. 3. 4. 31. 32. 33. BEFORE DELETE ON gross_receipt AFTER DELETE ON gross_receipt BEFORE (gross_receipt DELETE) FOR EACH ROW DELETED FROM gross_receipt Examine this function: CREATE OR REPLACE FUNCTION set_budget (v_studio_id IN NUMBER, v_new_budget IN NUMBER) IS
chetana_freshers@yahoogroups.com

nareshbethi@rediffmail.com

- 36 -

34. 35. 36.

BEGIN UPDATE studio SET yearly_budget = v_new_budget WHERE id = v_studio_id;

IF SQL%FOUND THEN RETURN TRUEl; ELSE RETURN FALSE; END IF;

COMMIT; END; Which code must be added to successfully compile this function? 1. Add RETURN right before the IS keyword. 2. Add RETURN number right before the IS keyword. 3. Add RETURN boolean right after the IS keyword. 4. Add RETURN boolean right before the IS keyword. 37. Under which circumstance must you recompile the package body after recompiling the package specification? 1. Altering the argument list of one of the package constructs 2. Any change made to one of the package constructs 3. Any SQL statement change made to one of the package constructs 4. Removing a local variable from the DECLARE section of one of the package constructs 38. Procedure and Functions are explicitly executed. This is different from a database trigger. When is a database trigger executed? 1. When the transaction is committed 2. During the data manipulation statement 3. When an Oracle supplied package references the trigger 4. During a data manipulation statement and when the transaction is committed 39. Which Oracle supplied package can you use to output values and messages from database triggers, stored procedures and functions within SQL*Plus? 1. DBMS_DISPLAY 2. DBMS_OUTPUT 3. DBMS_LIST 4. DBMS_DESCRIBE 40. What occurs if a procedure or function terminates with failure without being handled? 1. Any DML statements issued by the construct are still pending and can be committed or rolled back. 2. Any DML statements issued by the construct are committed
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 37 -

3. Unless a GOTO statement is used to continue processing within the BEGIN section, the construct terminates. 4. The construct rolls back any DML statements issued and returns the unhandled exception to the calling environment. 41. Examine this code 42. BEGIN 43. theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year; 44. END; For this code to be successful, what must be true? 1. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist only in the body of the THEATER_PCK package. 2. Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package. 3. Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package. 4. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist in the specification of the THEATER_PCK package. 45. A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hard-coded and must be created dynamically when the function is executed. Which Oracle supplied package will enable this feature? 1. DBMS_DDL 2. DBMS_DML 3. DBMS_SYN 4. DBMS_SQL 46. What is a servlet? Servlets are modules that extend request/response-oriented servers,such as Java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to update a companys order database. Servlets are to servers what applets are to browsers. Unlike applets, however, servlets have no graphical user interface. 47. Whats the advantages using servlets over using CGI? Servlets provide a way to generate dynamic documents that is both easier to write and faster to run. Servlets also address the problem of doing server-side programming with platform-specific APIs: they are developed with the Java Servlet API, a standard Java extension. 48. What are the general advantages and selling points of Servlets? A servlet can handle multiple requests concurrently, and synchronize requests. This allows servlets to support systems such as online real-time conferencing. Servlets can forward requests to other servers and servlets. Thus servlets can be used to balance load among several servers that mirror the same content, and to partition a single logical service over several servers, according to task type or organizational boundaries. 49. Which package provides interfaces and classes for writing servlets? javax 50. Whats the Servlet Interface? The central abstraction in the Servlet API is the Servlet interface. All servlets implement this interface, either directly or, more commonly, by extending a class that implements it such as HttpServlet.Servlets > Generic Servlet > HttpServlet > MyServlet. The Servlet interface declares, but does not implement, methods that manage the servlet and its communications with clients. Servlet writers provide some or all of these methods when developing a servlet. 51. When a servlet accepts a call from a client, it receives two objects. What are they? ServletRequest (which encapsulates the communication from the client to the server) and ServletResponse (which encapsulates the communication from the servlet back to the client). ServletRequest and ServletResponse are interfaces defined inside javax.servlet package. 52. What information does ServletRequest allow access to? Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by the client, and the names
nareshbethi@rediffmail.com chetana_freshers@yahoogroups.com

- 38 -

of the remote host that made the request and the server that received it. Also the input stream, as ServletInputStream.Servlets use the input stream to get data from clients that use application protocols such as the HTTP POST and GET methods. 53. What type of constraints can ServletResponse interface set on the client? It can set the content length and MIME type of the reply. It also provides an output stream, ServletOutputStream and a Writer through which the servlet can send the reply data. 54. Explain servlet lifecycle? Each servlet has the same life cycle: first, the server loads and initializes the servlet (init()), then the servlet handles zero or more client requests (service()), after that the server removes the servlet (destroy()). Worth noting that the last step on some servers is done when they shut down. 55. How does HTTP Servlet handle client requests? An HTTP Servlet handles client requests through its service method. The service method supports standard HTTP client requests by dispatching each request to a method designed to handle that request.

nareshbethi@rediffmail.com

chetana_freshers@yahoogroups.com

Das könnte Ihnen auch gefallen