1)How many ways are there to create an object?
i) Using ‘new’ operator:
Test s=new Test();
ii) Factory method:
Thread t=Thread.currentThread();
iii) newInstance():
Class c=Class.forName(“Test”);
Object obj=c.newInstance(); àcreates Test class Object.
Test t=(Test)obj;
iv) clone():
Test t1=new Test(10,20);
Test t2=t1.clone();
v) Deserialization:
FileInputStream fis=new FileInputStream(“Test.txt”);
ObjectInputStream ois=new ObjectInputStream(fis);
UserDefSerCls uds=new UserDefSerCls(,” ”,);
Ois.readObject(uds);
Ois.close();
2) What are the differences b/w HashMap and HashSet?
HashMap | HashSet |
It stores the data in key,value format.
It allows duplicate elements as values.
It implements Map
It allows only one NULL key.
| It stores grouped data .
It does not allow any duplicates.
It implements Set.
It does not allow NULL .
|
3) What is the difference b/w wait(-), sleep(-)& wait(-),yield()?
Wait(-) | Sleep(-) |
Running to Waiting/ Sleeping/Block.
It makes the current thread to sleep up to the given seconds and it could sleep less than the given seconds if it receives notify()/notifyAll() call.
In this case, the locks will be released before going into waiting state so that the other threads that are waiting on that object will use it.
Causes current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed. | Do
It makes the current thread to sleep for exactly the given seconds.
In case of sleep(), once the thread is entered into synchronized block/method, no other thread will be able to enter into that method/block.
|
Yield()à when a task invokes yield(), it changes from Running state to Runnable state.
*4) Can we create a userdefined immutable class?
Yes.
i) Make the class as final and
ii) make the data members as private and final.
*5) What are the differences b/w String and StringBuffer?
String | StringBuffer |
It is immutable.
It won’t give any additional space.
| It is mutable.
gives 16 additional characters memory space. |
6) Which “Collections F/W” classes did you use in your project?
List, ArrayList, LinkedList—add()
Set, TreeSet, HashSet--
HashMap—put(), get(), entrySet(), keyset()
Map.Entry
Iterator----hasMoreElements(), next()
ListIterator.
7) Can you write the simple code for HashMap?
HashMap<String,String> hm=new HashMap<String,String>()
hm.put(“key1”,”value1”);
hm.put(“key2”,”value2”);
hm.put(“key3”,”value3”);
Set set=hm.keySet(); // gives keys Set i.e., {key1,key2,key3}
Iterator<string> itr=set.iterator();
while(itr.hasNext()){ //true….false
String empkeys=itr.next(); //for keys
String empvalnames=hm.get(empkeys); //gives values by taking keys.
System.out.println(“empname”+empvalnames+”empid”+empkeys);
}
8) What are thread states?
i) Start: Thread thread=new Thread();
ii) Runnable: looking for its turn to be picked for execution by the Thread Schedular based
on thead priorities. (setPriority())
iii) Running: The Processor is actively executing the thread code. It runs until it becomes
blocked, or voluntarily gives up its turn with Thread.yield().
Because of Context Switching overhead, yield() should not be used very
frequently.
iv) Waiting: A thread is in a blocked state while it waits for some external processing such
as file I/O to finish.
Sleepingàsleep(): Java threads are forcibly put to sleep (suspended) with this overloaded method.
Thread.sleep(milliseconds); Thread.sleep(milliseconds,nanoseconds);
Blocking on I/O: Will move to runnable after I/O condition like reading bytes of data etc changes.
Blocked on Synchronization: will move to Runnable when a Lock is acquired.
v) Dead: The thread is finished working.
How to avoid Deadlock:
1) Avoid a thread holding multiple locks----
If no thread attempts to hold more than one lock ,then no deadlock occurs.
2) Reordering lock acquisition:--
If we require threads to always acquire locks in a particular order, then no deadlock occurs.
9) What are differences b/w concrete,abstract classes and interface & they are given?
Concrete class: A class of only Concrete methods is called Concrete Class.
For this, object instantiation is possible directly.
A class can extends one class and implements many interfaces.
Abstract class: | Interface: |
*A class of only Concrete or only Abstract or both.
*Any java class can extend only one abstract class.
*It won’t force the programmer to implement/override all its methods.
*It takes less execution time than interface.
* It allows constructor.
This class can’t be instantiated directly. A class must be abstract when it consist at least one abstract method. It gives less scope than an Interface. It allows both variable & constants declaration.
It allows methods definitions or declarations whenever we want.
It gives reusability hence it can’t be declared as “final”.
| only abstract methods.
A class can implements any no. of interfaces (this gives multiple interface inheritance )
It forces the programmer to implement all its methods
Interface takes more execution time due to its complex hierarchy. * It won’t allow any constructor.
It can’t be instantiated but it can refer to its subclass objects.
It gives more scope than an abstract class. By default, methodsàpublic abstract variablesàpublic static final.
It allows methods declarations whenever we want . But it involves complexity. Since they give reusability hence they must not be declared as “final”.
|
10) Can you create a userdefined immutable class like String?
Yes, by making the class as final and its data members as private, final.
11) Name some struts supplied tags?
a) struts_html.tld b) struts_bean.tld
c) struts_logic.tld d) struts_nested.tld
d) struts_template.tld e) struts_tiles.tld.
12) How to retieve the objects from an ArrayList?
List list=new ArrayList(); // List<String> list=new ArrayList<String>();
list.add(“element1”); list.add(“element1”);
list.add(“element2”); list.add(“element2”);
list.add(“element3”); list.add(“element3”);
// Iterator<String> iterator=list.iterator();
for(String str:list)
s.o.p(str); }
Iterator iterator=list.iterator();
while(iterator.hasNext()){
String str=(String)itr.next();
S.o.p(string);
}
}
13) What are versions of your current project technologies?
Java 6.0; Servlets 3.0, Jsp 2.0; struts 1.3.4 ; spring 3.2.0; Hibernate 3.2, Oracle 10. weblogic 8.5.
14) What is “Quality”?
It is a Measure of excellence.
state of being free from defects, deficiencies, and significant variations.
A product or service that bears its ability to satisfy stated or implied needs."
15) Can I take a class as “private”?
Yes, but it is declare to inner class, not to outer class.
If we are declaring "private" to outer class nothing can be
accessed from that outer class to inner class.
|
16) How can you clone an object?
A a1=new ();
B a11=a1.clone();
17) What methods are there in Cloneable interface?
Since Cloneable is a Marker/Tag interface, no methods present.
When a class implements this interface that class obtains some special behavior and that
will be realized by the JVM.
18) What is the struts latest version?
Struts 2.0
Java has five significant types of memory allocations.
· Class Memory
· Heap Memory
· Stack Memory
· Program Counter-Memory
· Native Method Stack Memory
20) Which JSP methods can be overridden?
jspInit() & jspDestroy().
21) How do you get key when value is available from HashMap?
HashMap<Integer,String> hm=new HashMap<Integer,String>();
hm.put(1,”ram”);
hm.put(2,”sri”);
hm.put(3,”mano”);
Set<Entry<Integer,String>> set=hm.entrySet();
for(Map.Entry<Integer,String> me:set){
if(me.getValue()==”ram”)
s.o.p(“the key value is:”+key):}
OR
Set s=hm.entrySet();
Iterator itr=s.iterator();
while(itr.hasNext()){
Object mobj=itr.next();
Map.Entry me=(Map.Entry)mobj;
if(me.getValue()=="anu")
System.out.println("key is:"+me.getKey() );}
22) What Design Patterns are you using in your project?
i) MVCàseparates roles using different technologies,
ii) Singleton Java classàTo satisfy the Servlet Specification, a servlet must be a Single
Instance multiple thread component.
iii) Front Controllerà A Servlet developed as FrontController can traps only the requests.
iv) D.T.O/ V.OàData Transfer Object/Value object is there to send huge amount of data
from one layer to another layer. It avoids Network Round trips.
v) IOC/Dependency Injectionà F/w s/w or container can automatically instantiates the
objects implicitly and injects the dependent data to that object.
vi) Factory methodà It won’t allows object instantiation from out-side of the calss.
vii) View Helperà It is there to develop a JSP without Java code so that readability,
re-usability will become easy.
23) What is Singleton Java class & its importance?
A Java class that allows to create only one object per JVM is called Singleton Java class.
Ex: In Struts f/w, the ActionServlet is a Singleton Java class.
Use: Instead of creating multiple objects for a Java class having same data, it is recommended
to create only one object & use it for multiple no. of times.
24) What are the differences b/w perform() & execute()?
perform() is an deprecated method.
25) What are the drawbacks of Struts? Is it MVC-I or II? Struts is MVC-II
1) Struts 1.x components are API dependent. Because Action & FormBean classes must
extend from the Struts 1.x APIs pre-defined classes.
2) Since applications are API dependent hence their “Unit testing” becomes complex.
3) Struts allows only JSP technology in developing View-layer components.
4) Struts application Debugging is quite complex.
5) Struts gives no built-in AJAX support. (for asynchronous communication)
Note: In Struts 1.x, the form that comes on the Browser-Window can be displayed
under no control of F/W s/w & Action class.
26) What are the differences b/w struts, spring and hibernate?
Struts: allows to develop only webapplications and
it can’t support POJO/POJI model programming.
Spring: is useful in developing all types of Java applications and
support POJO/POJI model programming.
Hibernate: is used to develop DB independent persistence logic
It also supports POJO/POJI model programming.
27) What are differences b/w Servlets & Jsp?
Servlets:
i) It requires Recompilation and Reloading when we do modifications in a Servlet.(some servers)
ii) Every Servlet must be configured in “web.xml”.
iii) It is providing less amount of implicit objects support.
iv) Since it consists both HTML & B.logic hence modification in one logic may disturbs
the other logic.
v) No implicit Exception Handling support.
vi) Since it requires strong Java knowledge hence non-java programmers shows no interest.
vii) Keeping HTML code in Servlets is quite complex.
JSP:
i) No need of Recompilation & Reloading when we do modifications in a JSP page.
ii) We need not to Configure a JSP in a “web.xml”.
iii) It is providing huge amount of Implicit Objects support.
iv) Since Html & Java code are separated hence no disturbance while changing logic.
v) It is providing implicit XML Exception Handling support.
vi) It is easy to learn & implement since it is tags based.
vii) It allows to develop custom tags.
viii) It gives JSTL support.
(JSP Standard Tag LibraryàIt provides more tags that will help to develop a JSP
without using Java code).
ix) It gives all benefits of Servlets.
28) What is the difference b/w ActionServlet & Servlet?
ActionServlet: It is a predefined Singleton Java class and it traps all the requests
coming to Server. It acts as a Front-Controller in Struts 1.x.
Servlet: a Java class that extends HttpServlet/GenericServlet or implements Servlet
interface and is a Server side technology to develop dynamic web pages.
It is a Single instance multiple thread component. It need not be a Singleton Java class.
29) What are Access Specifiers & modifiers?
i) public- à Universal access specifier.
--can be used along with: class, innerclass, Interface, variable, constructor, method.
ii) protectd à Inherited access specifier.
--can be used along with: innerclass, variable, method, constructor.
iii) default à Package access specifier(with in the package).
--can be used along with: class, innerclass, interface, variable, constructor, method.
iv) private à Native access specifier.
-- can be used along with: innerclass, variable, constructor, method.
à Some other access modifiers:
i) static------------innerclass,variable,block,method.
ii) abstract—----- class,method.
iii) final--------------class,variable,method.
iv) synchronized---block,method.
v) transient---------variable.
vi) native-------------method.
vii) volatile-----------variable
viii) strict fp-----------variable
30) Which JSP tag is used to display error validation?
In Source page:
<%@page errorPage=”error-page-name.jsp”>
In Error page:
<%@page isErrorPage=”true”>
31) What are the roles of EJBContainer ?
· An EJB container is the world in which an EJB bean lives.
· The container services requests from the EJB, forwards requests from the client to the EJB, and interacts with the EJB server.
· The container provider must provide transaction support, security and persistence to beans.
· It is also responsible for running the beans and for ensuring that the beans are protected from the outside world.
32) If double is added to String then what is the result?
Double + String=String
33) What is Ant? What is its use
Ant is a tool that is used to build war, compilation, deploy.
34) What is log4j? What is its functionality?
Log4j is a tool used to display logger messages on a file/console.
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
< appender name="FILE" class="org.apache.log4j.FileAppender">
logger.debug("Hi");
logger.info("Test Log");
logger.error()
Logger logger = Logger.getLogger(SampleLogtest.class);
35) What are the functions of service()?
protected void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException, java.io.IOException
Receives standard HTTP requests from the public service method and dispatches them to the doXXX methods defined in this class. This method is an HTTP-specific version of the
public void service(ServletRequest req, ServletResponse res)
throws ServletException, java.io.IOException
Dispatches client requests to the protected service method.
There's no need to override this method.
36) How do we get the container related information?
By using “ServletContext” object.
37) What is a Singleton Pattern?
is a design pattern that is used to restrict instantiation of a class to one object.
class Single{
private static Single s=null;
private Single(){
------}
public static Single Factory(){
if(s==null)
return( new Single());
}
}
38) What are the functions of a Filter Servlet?
It traps all the requests & responses.
Container creates the Filter object when the web application is deployed.
39) How to compile a JSP page?
Jasper tool-tomcat;
Jspc tool--weblogic
40) What is Hidden variable and give its snipplet HTML code?
<input type="hidden" id="age" name="age" value="23" />
<input type="hidden" id="DOB" name="DOB" value="01/01/70" />
<input type="hidden" id="admin" name="admin" value="1" />
41) How do you forward Servlet1 request to Servlet2?
ServletContext sc=getServletContext();
RequestDispatcher rd =sc.getRequestDispatcher(“/s2url”); //” or html file name”
rd.forward(req,resp);
(or) rd.include(req,resp);
42) differences b/w a Vector & a ArrayList?
ArrayList | Vector |
1. One dimensional data structure 2. New Collections F/w class 3. Non-synchronized 4. Serialized | Do Legacy Collection F/W class Synchronized Non-serialized |
43) try{ ----code for calling a not existed file---}
catch(Exception){--------}
catch(FileNotFoundException){-------}// for catch blocks no order significance.
Which “catch” block will be executed?
Compile time Error comes.
44) types of Action classes?
Actionàconsists b.logic or logic that is there to communicate with other Model like EJB,
Spring..
DispatchActionàan Action class used to group similar action classes having different methods. The name of the method will be coming in the request.
45) How do you print the missed salaries of employees?
User table Salary table
user_id user_id;
user_name user-salary;
print user-id,user-name,user-sal;
select user-id, user-name, user-sal from User us, Salary sal where us.user-id=sal.user-id.
46) What is “IN”, “OUT”, “INOUT” parameters?
in, out, inout are the modes of the variables in PL/SQl.
“ in” is input variable mode.
“out” is output variable mode.
“inout” is in-out variable mode.
47) How can you achieve Concurrence in Java?
Using Multithreading
48) How to implement Synchronization? Can we use synchronized with variables?
using the synchronized modifier along with the method or block.
We cant synchronized a variable.
49) What classes are there in Spring Environment?
Spring config.xml. spring bean class, spring bean interface.
50) What are the common files when 5 or more projects are developed using Hibernate ?
Configuration file
50) Do you know UML?
The unified modeling language (UML) is a general-purpose visual modeling language that is intended to provide a standard way to visualize the design of a system.
51) What is Association and Composition?
Association
Association refers to the relationship between multiple objects. It refers to how objects are related to each other and how they are using each other's functionality. Composition and aggregation are two types of association.
Composition
The composition is the strong type of association. An association is said to composition if an Object owns another object and another object cannot exist without the owner object.
Consider the case of Human having a heart. Here Human object contains the heart and heart cannot exist without Human.
Aggregation
Aggregation is a weak association. An association is said to be aggregation if both Objects can exist independently. For example, a Team object and a Player object.
The team contains multiple players but a player can exist without a team.
52) How can I achieve multiple inheritance in Java without using inheritance?
While Java doesn't support multiple inheritance directly, it can be achieved through interface and implements keywords with the syntax, class Child imlements Parent1, Parent2 { ... }
53) Write the code for a class which implements the Runnable interface?
Public class RunClass implement Runnable{
-------------
-------------
public void run(){
---------
}
Runnable r=new RunClass();
Thread thr=new Thread(r);
thr.start();
54) What are static methods in Interfaces?
Static methods, which contains method implementation is owned by the interface and is invoked using the name of the interface, it is suitable for defining the utility methods and cannot be overridden.
55) What is “join()”?
When a current thread wants to finish its complete execution and allow the second thread to do
its execution then first thread must invoke this join();
56) How do you configure “one to many” association in Hibernate?
<set> and <key> and <one-to-many>
<set name="address"> // child (address table)
<key column="emp_id"/> //primary key of address table
<one-to-many class="EmpAddress"/> //pojo class
</set>
57) What are types of Beans in EJB?
Session Bean---Stateless, Statefull
Entity Bean
MessageDriven Bean
58) Explain the life cycle of EJB?
59) Draw a class diagram for a class?
Class: SampleDemo
|
Variables: int a, b,c; |
Methods: sum(), substract(). |
60) What happens when we store primitives to Collections?
Collections are the framework used to store and manipulate a group of objects. Java Collection means a single unit of objects. Since the above two statements are true, generic
Java collections can not store primitive types directly.
61) Can we make the main() thread a daemon thread?
This technique designates whether the active thread is a user thread or a daemon thread. For instance, tU.setDaemon(true) would convert a user thread named tU into a daemon thread.
On the other side, executing tD.setDaemon(false) would convert a Daemon thread, tD, into a user thread.
62) What is InterruptedException?
When two or more threads try to access same object simultaneously, then this exception
occurs. Join(), wait(), notify() ,notifyAll() throws InterruptedException.
63) What Design patterns do you know?
MVC, Singleton class, Factory , FrontController, DAO class, D.T.O/V.O
64) What an Interface allows in its inside?
Abstract methods, constants, interface.
65) Can I define a class inside an Interface?
Yes
66) What is HB? What are its files.
It is an ORM tool that is there to develop DB independent persistence logic.
Hibernate-config.xml, Hibernate-mapping.xml, pojo class
67) How to integrate HB with Spring?
The DAO implementation class of spring must extends HibernateDAOSupport and
implements DAO interface.
68) How to integrate Struts with Spring?
ContextLoaderServlet and
applicationContext.xml configured in struts-config.xml that is there in web.xml
69) What are the differences b/w BeanFactory and ApplicationContext?
BeanFactory (I) container | ApplicationContext (I) |
to develop spring core applications. | It is an advanced & extended for BeanFactory.
It gives full fledged spring features support like; i) Bean property values can be collected from “outside properties file”. ii) gives support for Pre-Initialization of Beans. iii) text messages can be collected from outside property files to give support for i18n. iv) allows to work with EventHandling through Listeners.
|
Pre-initialization: creating Bean class objects & performing Dependency Injection on
Bean properties at the time of container activation.
70) What is the interface implemented by HashMap and Hashtable?
Map
71) What is the difference between System.out, System.err, and System.in?
System.out – It is a PrintStream that is used for writing characters or can be said it can output the data we want to write on the Command Line Interface console/terminal.
System.err – It is used to display error messages.
System.in – It is an InputStream used to read input from the terminal Window. We can’t use the System.in directly so we use Scanner class for taking input with the system.in.
72) What are ServletListeners?
Source obj | Event | Listener | EventHandling methods (public void |
ServletRequest
ServletContext
HttpSession
| ServletRequestEvent(sre)
ServletContextEvent(sce)
HttpSessionEvent (hse) | ServletRequestListener
ServletContextListener
HttpSessionListener | requestInitialized(sre) requestDestroyed(sre)
contextInitialized(sce) contextDestroyed(sce)
sessionCreated(hse) sessionDestroyed(hse) |
From Servlet 2.4 onwards, EventHandling is allowed on special objects of webapplication
like ServletContext, ServletRequest, HttpSession objects.
ServletRequest:
By doing EventHandling on ServletRequest object, we can keep track
each “request” object creation time & destruction time. Based on this, we can
find out “request processing time”.
HttpSession:
By performing EventHandling on HttpSession object, we can find out “session” object creation time & destruction time. Based on this, we can know the time taken by the each user to work with “session”.
Procedure to configure Listeners with webapplication
1) Develop a Java class implementing appropriate “Listener”
& place it in WEB-INF/classes folder.
2) Configure that Listener class name in web.xml by using <listener-class>
73) What is a Session?
Session: It is a set of related & continuous requests given by a client to a web application.
Ex: SignIn to SignOut in any Mail Systems Application like Gmail, Ymail etc…
74) How do you maintain client data at client side?
Cookies
75) What are the methods with Serializable interface?
No methods are there in Serializable Interface as a Marker/Tagged Interface.
Ex: Serializable, Cloneable, Remote, SingleThreadModel
76) What are the sorting methods are there in Java?
Java is a flexible language in itself and supports the operation of a variety of sorting algorithms. Most of these algorithms are
extremely flexible themselves and can be implemented with both a recursive as well as an iterative approach. Here are 5 most popular sorting algorithms in java:
1. Merge Sort
2. Heap Sort
3. Insertion Sort
4. Selection Sort
5. Bubble Sort
77) What do you mean by data encapsulation?
· Data Encapsulation is an Object-Oriented Programming concept of hiding the data attributes and their behaviours in a single unit.
· It helps developers to follow modularity while developing software by ensuring that each object is independent of other objects by having its own methods, attributes, and functionalities.
· It is used for the security of the private properties of an object and hence serves the purpose of data hiding.
78) What are the Http request methods?
GET,POST
79) Difference b/w GET and POST methods?
GET | POST |
1) It is a default Http request method
2) Query string is visible in Browser address bar hence no data Secrecy.
3) It allows to send limited amount of data(1kb)
4) It is not suitable for File uploading.
5) It is not suitable for sending Enscripted data.
6) It shows Idempotent behaviour.
7) Use either doGet(-,-) or service(-,-) to process this. | Not a default method.
It gives data Secrecy.
Unlimited amount of data.
Suitable for File uploading.
Suitable.
Non-Idempotent.
Use either doPost(-,-) or service(-,-)
|
80) What is Idempotent behavior?
It is the behavior like processing the multiple same requests from the same web page.
81) How the POST is not having Idempotent behavoiur?
POST is not an idempotent method since calling it multiple times may result in incorrect updates. Usually, POST APIs create new resources on the server.
If POST/payment endpoint is called with an identical request body, you will create multiple records.
82) How the JSP code is converting into Servlet code?
JSP parser/Engine/compiler
83) What are the Wrapper class objects?
The primitives are not allowed to store inside the collections. So, they will be converted into
Wrapper class objects using their respective wrapper classes.
84) What is Servlet life-cycle?
1. If an instance of the servlet does not exist, the Web container
b. Creates an instance of the servlet class.
c. Initializes the servlet instance by calling the init method.
2. Invokes the service method, passing a request and response object.
3. If the container needs to remove the servlet, it finalizes the servlet by calling
the servlet's destroy method.
85) Can I Implement Serializable when I don’t want to save the object in persistence stores?
If NetWork is there then YES else NO.
86) What is “reflection api”?
import java.lang.reflection;
Reflection API based applications:
are capable of gathering “internal details about a Java class/ interface
by performing Mirror Image Operations on that class/interface.
87) What are the SessionTracking Techniques?
Session Tracking: It is a technique by which the client data can be remembered across
the multiple requests given by a client during a Session.
1) Hidden Form Fields
2) Http Cookies
3) HttpSession with Cookies
4) HttpSession with URL-rewriting.(best)
5)
88) How to handle multiple submit buttons in a HTML form?
<input type=”submit” name=”s1” value=”add”> </th>
<input type=”submit” name=”s1” value=”delete”> </th>
<input type=”submit” name=”s1” value=”modify”> </th>
Code for accessing the above data in Servlet.
String cap=request.getParameter(“s1”);
if(cap.equals(“add”)) {
---------- }
elseif(cap.equals(“delete”)) {
------------- }
else(cap.equals(“modify”)) {
------------ }
89) Do you know CSS? What can I do with CSS?
CSS is a style language that defines layout of HTML documents. For example, CSS covers fonts, colours, margins, lines, height, width, background images, advanced positions and many other things
HTML is used to structure content. CSS is used for formatting structured content.
91) What are the uses with Hibernate?
i) It allows to develop DB independent query language like HQL.
ii) It supports POJO/POJI model programming.
iii) Any Java/J2EE can access HB persistence logic.
iv) It supports to call all Procedures & Functions of PL/SQL programming.
v) The result after “SELECT” operation, by default, is “Serializable”.
92) What are the differences b/w Servlet and JSP?
For every time we modifing the servlet , we should re-deploy the servlet.
Its very big headache.
Manually written servlets are somewhat faster than JSPs.
JSP:
i) No need of Recompilation & Reloading when we do modifications in a JSP page.
ii) We need not to Configure a JSP in a “web.xml”.
iii) It is providing huge amount of Implicit Objects support.
iv) Since Html & Java code are separated hence no disturbance while changing logic.
v) It is providing implicit XML Exception Handling support.
93) How to connect with DB?
Class.forName(“oracle.jdbc.driver.OracleDriver”);
Connection con=DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1506”,
”logicalDBname”,”username”,”password”);
Statement st=con.createStatement();
// ResultSet rs=st.execute(“select query”); (or)
// int x=st.executeUpdate(“Non-select query”);
94) Code for DataSource?
Context ct=new InitialContext();
Object obj=ct.lookUp(“ JNDI name of dataSource reference”);
DataSource ds=(DataSource)obj;
Connecton con=ds.getConnection();
Statement st=con.createStatement();
--------------------
con.close();
95) What is the return type of “executeUpdate()” ?
It is used to execute “Non-Select queries” and
whose return type is “int”.
96) What is “OUTER join”?
It gives both matching and non-matching rows.
97) What is an Application Server?
i) It allows to deploy all types of Java applications like web, distributed,enterpraise
applications.
ii) It contains both web and ejb containers.
iii) It gives more implicit middleware support like Tx management, Security, Connection
pooling..
98) How to know the no. of dynamically generated objects of a class?
Take a Static count variable, pass this to a” Parameterized Constructor” and keep the
increment operation inside it.
99) Can you write the flow for ATM ?
start |
Enter PIN |
Valid PIN | ||||
Not Valid | ||||
Check Bal |
available Bal |
Not available |
Withdraw process |
stop |
100) What is Synchronization?
The process of allowing only one thread among n no. of threads into a Sharable Resource
to perform “Read” & “Write” operations.
0 comments