Wednesday 2 November 2011

Top Interview Questions on Java

Is it possible to communicate from an applet to servlet and how many ways and how?- Yes, there are three ways to communicate from an applet to servlet and they are: a) HTTP Communication(Text-based and object-based) b) Socket Communication c) RMI Communication
What is connection pooling?- With servlets, opening a database connection is a major bottleneck because we are creating and tearing down a new connection for every page request and the time taken to create connection will be more. Creating a connection pool is an ideal approach for a complicated servlet. With a connection pool, we can duplicate only the resources we need to duplicate rather than the entire servlet. A connection pool can also intelligently manage the size of the pool and make sure each connection remains valid. A number of connection pool packages are currently available. Some like DbConnectionBroker are freely available from Java Exchange Works by creating an object that dispenses connections and connection Ids on request. The ConnectionPool class maintains a Hastable, using Connection objects as keys and Boolean values as stored values. The Boolean value indicates whether a connection is in use or not. A program calls getConnection() method of the ConnectionPool for getting Connection object it can use; it calls returnConnection() to give the connection back to the pool.
Why should we go for interservlet communication?- Servlets running together in the same server communicate with each other in several ways. The three major reasons to use interservlet communication are: a) Direct servlet manipulation - allows to gain access to the other currently loaded servlets and perform certain tasks (through the ServletContext object) b) Servlet reuse - allows the servlet to reuse the public methods of another servlet. c) Servlet collaboration - requires to communicate with each other by sharing specific information (through method invocation)
Is it possible to call servlet with parameters in the URL?- Yes. You can call a servlet with parameters in the syntax as (?Param1 = xxx || m2 = yyy).
What is Servlet chaining?- Servlet chaining is a technique in which two or more servlets can cooperate in servicing a single request. In servlet chaining, one servlet’s output is piped to the next servlet’s input. This process continues until the last servlet is reached. Its output is then sent back to the client. 
How do servlets handle multiple simultaneous requests?- The server has multiple threads that are available to handle requests. When a request comes in, it is assigned to a thread, which calls a service method (for example: doGet(), doPost() and service()) of the servlet. For this reason, a single servlet object can have its service methods called by many threads at once.

What is Inet address?- Every computer connected to a network has an IP address. An IP address is a number that uniquely identifies each computer on the Net. An IP address is a 32-bit number.

What is Domain Naming Service(DNS)?- It is very difficult to remember a set of numbers(IP address) to connect to the Internet. The Domain Naming Service(DNS) is used to overcome this problem. It maps one particular IP address to a string of characters. For example, www. mascom. com implies com is the domain name reserved for US commercial sites, moscom is the name of the company and www is the name of the specific computer, which is mascom’s server.

What is URL?- URL stands for Uniform Resource Locator and it points to resource files on the Internet. URL has four components: http://www. address. com:80/index.html, where http - protocol name, address - IP address or host name, 80 - port number and index.html - file path.

What is RMI and steps involved in developing an RMI object?- Remote Method Invocation (RMI) allows java object that executes on one machine and to invoke the method of a Java object to execute on another machine. The steps involved in developing an RMI object are: a) Define the interfaces b) Implementing these interfaces c) Compile the interfaces and their implementations with the java compiler d) Compile the server implementation with RMI compiler e) Run the RMI registry f) Run the application

What is RMI architecture?- RMI architecture consists of four layers and each layer performs specific functions: a) Application layer - contains the actual object definition. b) Proxy layer - consists of stub and skeleton. c) Remote Reference layer - gets the stream of bytes from the transport layer and sends it to the proxy layer. d) Transportation layer - responsible for handling the actual machine-to-machine communication.

what is UnicastRemoteObject?- All remote objects must extend UnicastRemoteObject, which provides functionality that is needed to make objects available from remote machines.

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

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

What is a Jar file?- Jar file allows to efficiently deploying a set of classes and their associated resources. The elements in a jar file are compressed, which makes downloading a Jar file much faster than separately downloading several uncompressed files. The package java. util. zip contains classes that read and write jar files.

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

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

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

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

What are Predefined variables or implicit objects?- To simplify code in JSP expressions and scriptlets, we can use eight automatically defined variables, sometimes called implicit objects. They are request, response, out, session, application, config, pageContext, and page.

What are JSP ACTIONS?- JSP actions use constructs in XML syntax to control the behavior of the servlet engine. You can dynamically insert a file, reuse JavaBeans components, forward the user to another page, or generate HTML for the Java plugin. Available actions include: jsp:include - Include a file at the time the page is requested. jsp:useBean - Find or instantiate a JavaBean. jsp:setProperty - Set the property of a JavaBean. jsp:getProperty - Insert the property of a JavaBean into the output. jsp:forward - Forward the requester to a newpage. Jsp: plugin - Generate browser-specific code that makes an OBJECT or EMBED

How do you pass data (including JavaBeans) to a JSP from a servlet?- (1) Request Lifetime: Using this technique to pass beans, a request dispatcher (using either “include” or forward”) can be called. This bean will disappear after processing this request has been completed. Servlet: request. setAttribute(”theBean”, myBean); RequestDispatcher rd = getServletContext(). getRequestDispatcher(”thepage. jsp”); rd. forward(request, response); JSP PAGE:(2) Session Lifetime: Using this technique to pass beans that are relevant to a particular session (such as in individual user login) over a number of requests. This bean will disappear when the session is invalidated or it times out, or when you remove it. Servlet: HttpSession session = request. getSession(true); session. putValue(”theBean”, myBean); /* You can do a request dispatcher here, or just let the bean be visible on the next request */ JSP Page: 3) Application Lifetime: Using this technique to pass beans that are relevant to all servlets and JSP pages in a particular app, for all users. For example, I use this to make a JDBC connection pool object available to the various servlets and JSP pages in my apps. This bean will disappear when the servlet engine is shut down, or when you remove it. Servlet: GetServletContext(). setAttribute(”theBean”, myBean); JSP PAGE:

How can I set a cookie in JSP?- response. setHeader(”Set-Cookie”, “cookie string”); To give the response-object to a bean, write a method setResponse (HttpServletResponse response) - to the bean, and in jsp-file:<% bean. setResponse (response); %>

How can I delete a cookie with JSP?- Say that I have a cookie called “foo, ” that I set a while ago & I want it to go away. I simply: <% Cookie killCookie = new Cookie(”foo”, null); KillCookie. setPath(”/”); killCookie. setMaxAge(0); response. addCookie(killCookie); %>

How are Servlets and JSP Pages related?- JSP pages are focused around HTML (or XML) with Java codes and JSP tags inside them. When a web server that has JSP support is asked for a JSP page, it checks to see if it has already compiled the page into a servlet. Thus, JSP pages become servlets and are transformed into pure Java and then compiled, loaded into the server and executed.

Large list of Intel interview questions

  1. Insights of an inverter. Explain the working?
  2. Insights of a 2 input NOR gate. Explain the working?
  3. Insights of a 2 input NAND gate. Explain the working?
  4. Implement F= not (AB+CD) using CMOS gates?
  5. Insights of a pass gate. Explain the working?
  6. Why do we need both PMOS and NMOS transistors to implement a pass gate?
  7. What does the above code synthesize to?
  8. Cross section of a PMOS transistor?
  9. Cross section of an NMOS transistor?
  10. What is a D-latch? Write the VHDL Code for it?
  11. Differences between D-Latch and D flip-flop?
  12. Implement D flip-flop with a couple of latches? Write a VHDL Code for a D flip-flop?
  13. What is latchup? Explain the methods used to prevent it?
  14. What is charge sharing?
  15. While using logic design, explain the various steps that r followed to obtain the desirable design in a well defined manner?
  16. Why is OOPS called OOPS? (C++)
  17. What is a linked list? Explain the 2 fields in a linked list?
  18. Implement a 2 I/P and gate using Tran gates?
  19. Insights of a 4bit adder/Sub Circuit?
  20. For f = AB+CD if B is S-a-1, what r the test vectors needed to detect the fault?
  21. Explain various adders and diff between them?
  22. Explain the working of 4-bit Up/down Counter?
  23. A circuit has 1 input X and 2 outputs A and B. If X = HIGH for 4 clock ticks, A = 1. If X = LOW for 4 clock ticks, B = 1. Draw a state diagram for this Spec?
  24. Advantages and disadvantages of Mealy and Moore?
  25. Id vs. Vds Characteristics of NMOS and PMOS transistors?
  26. Explain the operation of a 6T-SRAM cell?
  27. Differences between DRAM and SRAM?
  28. Implement a function with both ratioed and domino logic and merits and demerits of each logic?
  29. Given a circuit and asked to tell the output voltages of that circuit?
  30. How can you construct both PMOS and NMOS on a single substrate?
  31. What happens when the gate oxide is very thin?
  32. What is setup time and hold time?
  33. Write a pseudo code for sorting the numbers in an array?
  34. What is pipelining and how can we increase throughput using pipelining?
  35. Explain about stuck at fault models, scan design, BIST and IDDQ testing?
  36. What is SPICE?
  37. Differences between IRSIM and SPICE?
  38. Differences between netlist of HSPICE and Spectre?
  39. What is FPGA?
  40. Draw the Cross Section of an Inverter? Clearly show all the connections between M1 and poly, M1 and diffusion layers etc?
  41. Draw the Layout of an Inverter?
  42. If the current thru the poly is 20nA and the contact can take a max current of 10nA how would u overcome the problem?
  43. Implement F = AB+C using CMOS gates?
  44. Working of a 2-stage OPAMP?
  45. 6-T XOR gate?
  46. Differences between blocking and Non-blocking statements in Verilog?
  47. Differences between Signals and Variables in VHDL? If the same code is written using Signals and Variables what does it synthesize to?
  48. Differences between functions and Procedures in VHDL?
  49. What is component binding?
  50. What is polymorphism? (C++)
  51. What is hot electron effect?
  52. Define threshold voltage?
  53. Factors affecting Power Consumption on a chip?
  54. Explain Clock Skew?
  55. Why do we use a Clock tree?
  56. Explain the various Capacitances associated with a transistor and which one of them is the most prominent?
  57. Explain the Various steps in Synthesis?
  58. Explain ASIC Design Flow?
  59. Explain Custom Design Flow?
  60. Why is Extraction performed?
  61. What is LVS, DRC?
  62. Who provides the DRC rules?
  63. What is validation?
  64. What is Cross Talk?
  65. Different ways of implementing a comparator?
  66. What r the phenomenon which come into play when the devices are scaled to the sub-micron lengths?
  67. What is clock feed through?
  68. Implement an Inverter using a single transistor?
  69. What is Fowler-Nordheim Tunneling?
  70. Insights of a Tri-state inverter?
  71. If an/ap = 0.5, an/ap = 1, an/ap = 3, for 3 inverters draw the transfer characteristics?
  72. Differences between Array and Booth Multipliers?
  73. Explain the concept of a Clock Divider Circuit? Write a VHDL code for the same?
  74. Which gate is normally preferred while implementing circuits using CMOS logic, NAND or NOR? Why?
  75. Insights of a Tri-State Inverter?
  76. Basic Stuff related to Perl?
  77. Have you studied buses? What types?
  78. Have you studied pipelining? List the 5 stages of a 5 stage pipeline. Assuming 1 clock per stage, what is the latency of an instruction in a 5 stage machine? What is the throughput of this machine ?
  79. How many bit combinations are there in a byte?
  80. For a single computer processor computer system, what is the purpose of a processor cache and describe its operation?
  81. Explain the operation considering a two processor computer system with a cache for each processor.
  82. What are the main issues associated with multiprocessor caches and how might you solve them?
  83. Explain the difference between write through and write back cache.
  84. Are you familiar with the term MESI?
  85. Are you familiar with the term snooping?
  86. Describe a finite state machine that will detect three consecutive coin tosses (of one coin) that results in heads.
  87. In what cases do you need to double clock a signal before presenting it to a synchronous state machine?
  88. You have a driver that drives a long signal & connects to an input device. At the input device there is either overshoot, undershoot or signal threshold violations, what can be done to correct this problem?
  89. What are the total number of lines written by you in C/C++? What is the most complicated/valuable program written in C/C++?
  90. What compiler was used?
  91. What is the difference between = and == in C?
  92. Are you familiar with VHDL and/or Verilog?
  93. What types of CMOS memories have you designed? What were their size? Speed?
  94. What work have you done on full chip Clock and Power distribution? What process technology and budgets were used?
  95. What types of I/O have you designed? What were their size? Speed? Configuration? Voltage requirements?
  96. Process technology? What package was used and how did you model the package/system? What parasitic effects were considered?
  97. What types of high speed CMOS circuits have you designed?
  98. What transistor level design tools are you proficient with? What types of designs were they used on?
  99. What products have you designed which have entered high volume production?
  100. What was your role in the silicon evaluation/product ramp? What tools did you use?
  101. If not into production, how far did you follow the design and why did not you see it into production?

Infosys Logical questions

I have two coins for 75 paise. 1 coin is not 50 paise, how?
Latest Answer: 1 coin is not fifty paise, but another can be, so let another be 50 paise coin and the one you are talking about is 25 paise coin so here we make 75paise with two coins.

Once there came many birds to a pond. There were certain number of lotus flowers in the pond. If each bird occupied one lotus one bird was left alone without any flower. If two birds sat in a flower one
Latest Answer: Let no. of birds is "b" and no. of lotus be "l" Now, a/c to first condition--> b = l+1 & a/c to snd condition--> b/2 = l-1 Solving above equations, we get, No. of Bird=4 & No. of Lotus = 3 ...

 A pipe can fill a tank in 3 hours due to leakage it takes 3.5 hours to fill the same tank then how many hours will the leakage can empty the tank
Latest Answer: Let the tank be 1 ltr. It takes 180 min(3 hr) to fill this tank.Hence 1 min's work is 1/180After the tank got a hole in it, it takes 3 and 1/2 hrs ie.. 210 min.hence work expended in 210 min is 210*1/180=7/6Hence extra work spended due to hole is ...

Two coins one with HEAD IN BOTH SIDES and the other coin HEAD IN ONE SIDE AND TAIL IN THE OTHER SIDE is in a box,a coin is taken at random and FOUND HEAD IN ONE SIDE .what is the probability that THE OTHER SIDE IS HEAD?
Ans:::::::1.Two coins one with HEAD IN BOTH SIDES and the other coin HEAD IN ONE SIDE AND TAIL IN THE OTHER SIDE is in a box,a coin is taken at random and FOUND HEAD IN

When Arthur is as old as his father Hailey is now, he shall be 5 times as old as his son Clarke is now. By then Clarke will be 8 times older than Arthur is now. The combined ages of Hailey and Arthur are
Latest Answer: Let Age of Haley is = H, Arthur is = A, Clarke =CA+H =100 ---------------(1)H=5C ---------------------(2)(H-A) + C = 8A ----------- (3)Solving them gives H = 1500/17 , A = 200/17, C = 200/17 ...

A car is traveling at a uniform speed. The driver sees a milestone showing a 2-digit number. After traveling for an hour thedriver sees another milestone with the same digits in reverse order. After another hour the driver sees another milestone containingthe same two digits with a zero in between(0). What is the average speed of the driver.
Ans:
Let 10'splace digit is x and unit's place digit y

First milestone :      10x+y
Second milestone : 10y+x
Third milestone:      100x+y

Since the speed is uniform so
  Distance covered in first Hr = Distance covered in Second Hr
  (10y+x)-(10x+y) = (100x+y)-(10y+x)
After solving, we get  ---->   y=6x  but since x and y are digits so only possible combination is x=1 and y=6,
  So average speed = 45 KM/HR




A mathamatical word contain 10 letters.Without first four letter you can't plan your life.Last six letter specify particular time.

Ans: "TimePeriod" 

My son is half of my age & was 1/3rd of my age 10 yrs back. What is my present age?

 let the fathers age be f and son's age be s
s=.5f => f=2s..................1
(f-10)/3=(s-10) => f-10=3s-30
3s-f=20.............................2
solving 1 and 2
we get son's age as 20 and fathers age as 40

 


Search here for "Freshers Jobs"