forked from enhorse/java-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
165 lines (156 loc) · 72.6 KB
/
index.html
File metadata and controls
165 lines (156 loc) · 72.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
"What is Spring?"</p><p>"Spring is a set of libraries, frameworks and APIs that support Java "best practices" for ideas like IOC, DI and AOP."</p>Describe the DispatcherServlet.</p><p>The DispatcherServlet is the core of Spring Web MVC framework. It handles all the HTTP requests and responses. The DispatcherServlet receives the entry of handler mapping from the configuration file and forwards the request to the controller. The controller then returns an object of Model And View. The DispatcherServlet checks the entry of the view resolver in the configuration file and calls the specified view component.</p><p>What are the Java Spring bean scope?</p><p>singleton prototype request session globalsession</p><p>What is Spring IOC Container?</p><p>The container creates the object, wires them together, configures them and manages their complete life cycle. The Spring container makes use of Dependency Injection to manage the components that make up an application. The container receives instructions for which objects to instantiate, configure, and assemble by reading the configuration metadata provided.</p><p>In how many ways can Dependency Injection be done?</p><p>Constructor Injection Setter Injection Interface Injection</p><p>How many types of IOC containers are there in spring?</p><p>BEAN FACTORY APPLICTATION CONTEXT</p><p>Whats is Bean Factory</p><p>BeanFactory is like a factory class that contains a collection of beans. It instantiates the bean whenever asked for by clients.</p><p>What is Application Context in Spring?</p><p>ApplicationContext: The ApplicationContext interface is built on top of the BeanFactory interface. It provides some extra functionality on top BeanFactory.</p><p>can you explain Spring Beans?</p><p>They are the objects that form the backbone of the user's application. Beans are managed by the Spring IoC container. They are instantiated, configured, wired and managed by a Spring IoC container.</p><p>How configuration metadata is provided to the Spring container?</p><p>XML-Based configuration Annotation-Based configuration Java-based configuration</p><p>What do you understand by auto wiring</p><p>The Spring container is able to autowire relationships between the collaborating beans. That is, it is possible to let Spring resolve collaborators for your bean automatically by inspecting the contents of the BeanFactory.</p><p>What are different modes of autowiring?</p><p>no (default), byName, byType, constructor, autodetect</p><p>Autowiring byName</p><p>It injects the object dependency according to the name of the bean. It matches and wires its properties with the beans defined by the same names in the XML file.</p><p>Autowiring byType:</p><p>It injects the object dependency according to type. It matches and wires a property if its type matches with exactly one of the beans name in XML file.</p><p>Autowiring constructor</p><p>It injects the dependency by calling the constructor of the class. It has a large number of parameters.</p><p>Autowiring autodetect</p><p>First the container tries to wire using autowire by constructor, if it can't then it tries to autowire by byType.</p><p>@Component:</p><p>This marks a java class as a bean. It is a generic stereotype for any Spring-managed component. The component-scanning mechanism of spring now can pick it up and pull it into the application context.</p><p>@Controller:</p><p>This marks a class as a Spring Web MVC controller. Beans marked with it are automatically imported into the Dependency Injection container.</p><p>@Service:</p><p>This annotation is a specialization of the component annotation. It doesn't provide any additional behavior over the @Component annotation. You can use @Service over @Component in service-layer classes as it specifies intent in a better way.</p><p>@Repository:</p><p>This annotation is a specialization of the @Component annotation with similar use and functionality. It provides additional benefits specifically for DAOs. It imports the DAOs into the DI container and makes the unchecked exceptions eligible for translation into Spring DataAccessException.</p><p>What do you understand by @Qualifier annotation?</p><p>When you create more than one bean of the same type and want to wire only one of them with a property you can use the @Qualifier annotation along with @Autowired to remove the ambiguity by specifying which exact bean should be wired.</p><p>What do you understand by @RequestMapping annotation?</p><p>@RequestMapping annotation is used for mapping a particular HTTP request method to a specific class/ method in the controller that will be handling the respective request. This annotation can be applied at both levels:</p><p>What are the Constraints in SQL?</p><p>Constraints are used to specify the limit on the data type of the table. It can be specified while creating or altering the table statement.</p><p>What do you mean by data integrity?</p><p>Data Integrity defines accuracy as well as the consistency of the data stored in a database. It also defines integrity constraints to enforce business rules on the data when it is entered into an application or a database.</p><p>What is an Index?</p><p>An index refers to a performance tuning method of allowing faster retrieval of records from the table. An index creates an entry for each value and hence it will be faster to retrieve data.</p><p>types of Normalization.</p><p>These are called normal forms. Each consecutive normal form depends on the previous one. The first three normal forms are usually adequate. 1NF,2NF,3NF</p><p>First Normal Form (1NF)</p><p>No repeating groups within rows, atomic values for each column.</p><p>Second Normal Form (2NF)</p><p>Every non-key (supporting) column value is dependent on the whole primary key.</p><p>Third Normal Form (3NF)</p><p>Dependent solely on the primary key and no other non-key (supporting) column value.(no transitive dependencies)</p><p>What is ACID property in a database?</p><p>ACID stands for Atomicity, Consistency, Isolation, and Durability. This set of properties is used to ensure that the data transactions are processed reliably in a database system.</p><p>Atomicity:</p><p>refers to the transactions that are completely done or failed where transaction refers to a single logical operation of a data. It means if one part of any transaction fails, the entire transaction fails and the database state is left unchanged.</p><p>Consistency:</p><p>ensures that the data must meet all the validation rules. In simple words, you can say that your transaction never leaves the database without completing its state</p><p>Isolation:</p><p>The main goal of isolation is concurrency control.</p><p>Durability</p><p>Durability means that if a transaction has been committed, it will occur whatever may come in between such as power loss, crash or any sort of error.</p><p>What do you mean by data definition language?</p><p>Data definition language or DDL allows you to execute queries like CREATE, DROP and ALTER. That is those queries which define the data.</p><p>What is the difference between primary key and unique constraints?</p><p>Primary key cannot have a NULL value, the unique constraints can have NULL values. There is only one primary key in a table, but there can be multiple unique constraints. The primary key creates the clustered index automatically but the unique key does not.</p><p>What do you mean by foreign key?</p><p>A Foreign key is a field that can uniquely identify each row in another table. And this constraint is used to specify a field as a foreign key. That is this field points to the primary key of another table. This usually creates a kind of link between the two tables.</p><p>What is the difference between DELETE and TRUNCATE statements?</p><p>DELETE: Delete command is used to delete row(s) in a table. You can rollback data after using the delete Truncate is used to delete all the rows from a table. Implicit commit</p><p>What is a Relationship</p><p>Relation or links are between entities that have something to do with each other. Relationships are defined as the connection between the tables in a database.</p><p>What is the difference between 'HAVING' CLAUSE and a 'WHERE' CLAUSE?</p><p>HAVING clause can be used only with the SELECT statement. It is usually used in a GROUP BY clause and whenever GROUP BY is not used, HAVING behaves like a WHERE clause.</p><p>...</p><p>Having Clause is used only with the GROUP BY function in a query whereas WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.</p><p>How is concurrency implemented in Java, and what keywords/classes are involved?</p><p>Multiple "threads" are allowed to run at the same time, in parallel. Keywords
i.Synchronized - defines a method or block of code that can only be executed by one thread at a time
ii.Wait - forces the current thread to wait until a time limit expires, or notify is called
iii.Notify - for a given "lock" object, randomly picks one waiting thread to wake up
iv.NotifyAll - wakes up all threads waiting on the given object.
CLASSES: Thread, Runnable, Callable, Future ,ExecutorService, BlockingQueue, ThreadPoolExecutor ,CountDownLatch, AtomicInteger</p><p>What is a deadlock, and how do you avoid it?</p><p>NOTE: most candidates don't get this question :consider it extra credit
Deadlock: two threads stuck forever, owning some locks and waiting on others
Example:
i.Thread A owns lock1, waiting on lock2
ii.Thread B owns lock2, waiting on lock1
· Avoidance
iii.Use fewer locks / synchronized blocks
1. NOTE: many candidates may tell you to use MORE locks: red flag
iv.Use shorter critical sections (don't hold onto locks for very long)
v.Avoid performing blocking i/o while holding a lock
1. Blocking i/o can block for an undefined length of time
vi.Always acquire locks in the same order:
1. Never grab lock2 unless you already have lock1</p><p>What is the difference between checked/unchecked exceptions?</p><p>Checked : must be caught, or declared in a throws clause
Unchecked : do not need to be caught or declared : example is RuntimeException</p><p>What are some good ways of handling errors or exceptions in Java?</p><p>Wrap the block of code that can throw an exception in a "try / catch" block
Best practice is to use multiple catch's for each try - one catch for each different exception that may be thrown</p><p>How do you interact with data stores SQL, No-SQL, etc? What are some tradeoffs involved in choosing or working with a data store?</p><p>SQL / RDBMS
i.Use a JDBC driver specific to connect to SQL
ii.Use an ORM (object relation map) such as Hibernate, iBatis, JPA
iii.Use annotations to map class names/fields to tables/columns
iv.Referential integrity: ensures valid keyed relationships between tables
v.SQL is great for ad-hoc queries that combine different types of data
No-SQL
vi.Key-Value store, Document store
vii.Use vendor-specific API's to connect to No-SQL
viii.No referential integrity: "schema-less" data
ix.No-SQL can be much faster that SQL for certain lookups</p><p>What does the Spring @Autowired keyword do? What is it good for?</p><p>It declares a dependency between two classes
· It is much easier than editing spring beans.xml
· Often used for associating a service, for example a database access object</p><p>Name some Java Application Servers that you are familiar with? What do the deployment files look like? How did you deploy them? If you've used SpringBoot, how does that compare?</p><p>Multiple Answers. Most common are: Apache Tomcat, Jetty, GlassFish, WildFly, WebLogic, Resin, JBoss, WebSphere Application Server
Deployment files
x.Jar file = java archive : zip of java classes
xi.War file = web archive : contains jars, config files, ...
xii.Ear file = enterprise archive, collection of war
How to deploy?
xiii.Copy ear or war file to "webapps" directory
xiv.Be careful about file/owner permissions
xv.Edit configuration / resource files
What are some of the disadvantages of using an App Server?
xvi.Vendor upgrades are painful
xvii.Memory leaks
xviii.Complex class loading
xix.Package lots of functionality you might never use : code bloat
SpringBoot
xx.Is a runnable jar file, with its own main, does not need an app server.</p><p>What features / capabilities can you control from the Java command-line?</p><p>-version : reports java version
-cp : classpath
-Dvariable=value : override system properties
-Xmx : Max memory
· GC settings</p><p>What tools / techniques do you use to troubleshoot communication problems between client and server (front-end and back-end)?</p><p>Talk to the end users
Talk to the developers on both sides
Look for network problems: cable, routing, DNS
i.Tools: ifconfig, ipconfig, netstat, ping, traceroute, nslookup, wireshark, tcpdump
Look for server problems:
ii.Is the server running, is the process out of memory?
iii.Tools: ps, top
Check debug logs
iv.Logfiles on server, or in splunk
Try to duplicate the problem in a dev/QA environment</p><p>Which version control/source control tools are you familiar with? What are some of the command-line commands for interacting with the source control system?</p><p>(this question is not scored, however if they cannot name at least one source control system then this question is answered incorrectly)
Open ended question. Possible answers can include Git, cvs, subversion</p><p></p><p>
<p>"What is DI (Dependency Injection)?"</p><p>"Objects are given their dependencies at creation time by some external entity that coordinates each object in the system. The advantage is that information present only at Runtime can be acted upon by the system."</p><p>"What are 7 benefits of "Inversion Of Control"?"</p><p>"1. They minimizes the amount of code in your application.
2. With IOC containers it doesn't matter how services are created or how you get references to them. You can also easily add additional services by adding a new constructor or a setter method with little or no extra configuration.
3. IOC Makes your application more testable by not requiring any singletons or JNDI lookup mechanisms in your unit test cases.
4. IOC containers make unit testing and switching implementations very easy by manually allowing you to inject your own objects into the object under test.
5. Loose coupling is promoted with minimal effort and least intrusive mechanism. The factory design pattern is more intrusive because components or services need to be requested explicitly whereas in IOC the dependency is injected into the appropriate piece of code. Also some containers promote the designing to interfaces rather than to implementations design concept by encouraging managed objects to implement a well-defined service interface.
6. IOC containers support eager instantiation and lazy loading of services.
7. They provide support for instantiation of managed objects, cyclical dependencies, life cycles management, and dependency resolution between managed objects etc."</p><p>"What is Aspect Orientated Programming (AOP)?"</p><p>"In computing, aspect-oriented programming (AOP) is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns."</p><p>"Give examples of cross cutting concerns."</p><p>"Logging or Transaction Management are examples as they are likely to be utilized in a wide variety of places throughout the various patterns in the system."</p><p>"What is a Bean Factory?"</p><p>"A BeanFactory is a factory class that contains Bean Definitions and can be called upon to generate instances thereof whenever asked for by clients. A BeanFactory is also able to create associations between collaborating objects as they are instantiated. This removes the burden of configuration from bean itself and the beans client.
BeanFactory also takes part in the life cycle of a bean, making calls to custom initialization and destruction methods."</p><p>"What is an Application Context?"</p><p>An application context has all the functionality of a BeanFactory but it also provides:
1. A means for resolving text messages, including support for internationalization.
2. A generic way to load file resources.
3. Events to beans that are registered as listeners.</p><p>What are the 6 differences between Bean Factory and Application Context ?</p><p>An application context offers much more than a Bean Factory.
1. Support for Internationalization.
2. A generic way to load file resources.
3. Event publishing to beans that are registered as listeners.
4. Certain operations on the container or beans in the container, which have to be handled in a programmatic fashion with a bean factory, can be handled declaratively in an application context.
5. Application Contexts facilitate Spring's Resource interface which is a flexible generic abstraction for handling low-level resources. An application context itself is a ResourceLoader, Hence they provide an application with access to deployment-specific Resource instances.
6. MessageSource support: The application context implements MessageSource, an interface used to obtain localized messages, with the actual implementation being pluggable.</p><p>"What are the common implementations of the Application Context ?"</p><p>The three commonly used implementations of 'Application Context' are
1. ClassPathXmlApplicationContext : It Loads context definition from an XML file located in the classpath, treating context definitions as classpath resources.
2. FileSystemXmlApplicationContext : It loads context definition from an XML file in the filesystem.
3. XmlWebApplicationContext : It loads context definition from an XML file contained within a web application.
4. AnnotationConfigApplicationContext and AnnotationConfigWebApplicationContext. These are basically the @Configuration version of thier namesakes. Note for the latter a "contextClass" context-param for ContextLoader and/or "contextClass" init-param for FrameworkServlet must be set to the fully-qualified name of this class.</p><p>What does a typical Spring application look like?</p><p>Typically we would need the following:
- An interface that defines the functions.
- An Implementation that contains properties, its setter and getter methods, functions etc.,
- Spring AOP (Aspect Oriented Programming)
- A XML file called Spring configuration file.
- Client program that uses the function.</p><p>"What is the typical Bean life cycle in Spring Bean Factory Container ?"</p><p>1. Instantiation.
2. DI and properties population.
3. setBeanName is called for all classes that implement the BeanNameAware interface.
4. setBeanFactory() is called for all classes that implement the BeanFactoryAware interface.
5. If there are any BeanPostProcessors associated with the bean, their post-ProcessBeforeInitialization() methods will be called.
6. If an init-method is specified for the bean, it will be called.
7. Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called."</p><p>"What is meant by Bean wiring?"</p><p>"The act of creating associations between application components (beans) within the Spring container is reffered to as Bean wiring."</p><p>"What is meant by Auto wiring?"</p><p>"The Spring container is able to autowire relationships between collaborating beans. This means that it is possible to automatically let Spring resolve collaborators (other beans) for your bean by inspecting the contents of the BeanFactory."</p><p>"What is DelegatingVariableResolver?"</p><p>"DelegatingVariableResolver is an extension of the standard JSF managed beans mechanism which lets you use JSF and Spring together."</p><p>"How does one integrate a Struts application with Spring?"</p><p>"Two options:
1. Configure Spring to manage your Actions as beans, using the ContextLoaderPlugin, and set their dependencies in a Spring context.
2. Subclass Spring's ActionSupport classes and grab your Spring-managed beans explicitly using a getWebApplicationContext() method."</p><p>"What are examples of ORM's Spring supports?"</p><p>Hibernate
MyBatis
JPA (Java Persistence API)
TopLink
JDO (Java Data Objects)
OJB</p><p>What are the 2 ways to access Hibernate using Spring ?</p><p>1. IOC with a HibernateTemplate and Callback.
2. An extension of HibernateDaoSupport combined with the application of an AOP Interceptor.</p><p>How does one integrate Spring and Hibernate using HibernateDaoSupport?</p><p>Useing Spring's LocalSessionFactory:
1. Configure the Hibernate SessionFactory.
2. Extend your DAO Implementation from HibernateDaoSupport.
3. Wire in Transaction Support with AOP.</p><p>What are the 5 bean scopes in the Spring Framework ?</p><p>1. Singleton
2. Prototype
3. Request (web aware applicationContext only)
4. Session (web aware applicationContext only)
5. Global Session (web aware applicationContext only)
Singleton - Scopes a single bean definition to a single object instance per Spring IoC container.
Prototype - Scopes a single bean definition to any number of object instances.
Request - Scopes a single bean definition to the lifecycle of a single HTTP request; that is each and every HTTP request will have its own instance of a bean created off the back of a single bean definition. Only valid in the context of a web-aware Spring ApplicationContext.
Session - Scopes a single bean definition to the lifecycle of a HTTP Session. Only valid in the context of a web-aware Spring ApplicationContext.
Global Session - Scopes a single bean definition to the lifecycle of a global HTTP Session. Typically only valid when used in a portlet context. Only valid in the context of a web-aware Spring ApplicationContext.</p><p>In the context of AOP what is a Join Point?</p><p>A point during the execution of a program, such as the execution of a method or the handling of an exception. In Spring AOP, a join point always represents a method execution.</p><p>What is AOP Advice?</p><p>Action taken by an aspect at a particular join point. Different types of advice include "around," "before" and "after returning" advice. Many AOP frameworks, including Spring, model an advice as an interceptor, maintaining a chain of interceptors "around" the join point.</p><p>"What are the 5 types of AOP Advice?"</p><p>1. Before
2. After Returning
3. After Throwing
4. After Finally
5. Around
Before - Advice that executes before a join point, but which does not have the ability to prevent execution flow proceeding to the join point (unless it throws an exception).
After Returning - Advice to be executed after a join point completes normally: for example, if a method returns without throwing an exception.
After Throwing - Advice to be executed if a method exits by throwing an exception.
After Finally - Advice to be executed regardless of the means by which a join point exits (normal or exceptional return).
Around - Advice that surrounds a join point such as a method invocation. This is the most powerful kind of advice. Around advice can perform custom behavior before and after the method invocation. It is also responsible for choosing whether to proceed to the join point or to shortcut the advised method execution by returning its own return value or throwing an exception.</p><p>"What are the types of Transaction Management Spring supports?"</p><p>"Programmatic and Declarative transaction management."</p><p>What are the 4 benefits of the Spring Framework's transaction management ?</p><p>"1. It provides a consistent programming model across different transaction APIs.
2. It supports annotations.
3. It provides a simplified API.
4. It integrates with Spring's various data access abstractions."</p><p>Why do most users of the Spring Framework choose declarative transaction management?</p><p>Because it minimizes impact on application code, and hence is most consistent with the ideals of a non-invasive lightweight container.</p><p>Explain the similarities and differences between EJB CMT and the Spring Framework's declarative transaction management.</p><p>The basic approach is similar:
* It is possible to specify transaction behavior (or lack of it) down to individual method level.
* It is possible to make a setRollbackOnly() call within a transaction context if necessary.
The differences are:
* Unlike EJB Container Managed Transactions, which are tied to JTA, Spring's declarative transaction management works in any environment. It can work with JDBC, JDO, Hibernate or other transactions under the covers, with configuration changes only
* Spring enables declarative transaction management to be applied to any class, not merely special classes such as EJBs.
* Spring offers declarative rollback rules: this is a feature with no EJB equivalent. Both programmatic and declarative support for rollback rules is provided.
* Spring gives you an opportunity to customize transactional behavior, using AOP. With EJB CMT, you have no way to influence the container's transaction management other than setRollbackOnly().
* Spring does not support propagation of transaction contexts across remote calls, as do high-end application servers.</p><p>When do we use programmatic and declarative transaction management?</p><p>Programmatic transaction management is usually a good idea only if you have a small number of transactional operations, Otherwise you are probably going to want declarative transaction management. It keeps transaction management out of business logic, and is not difficult to configure.</p><p>Tell me about the Spring DAO support.</p><p>The Data Access Object (DAO) support in Spring is aimed at making it easy to work with data access technologies like JDBC, Hibernate or JDO in a consistent way. This allows one to switch between the persistence technologies fairly easily and it also allows one to code without worrying about catching exceptions that are specific to each technology.</p><p>What are the exceptions thrown by the Spring DAO classes?</p><p>Spring DAO classes throw exceptions which are subclasses of DataAccessException(org.springframework.dao.DataAccessException).Spring provides a convenient translation from technology-specific exceptions like SQLException to its own exception class hierarchy with the DataAccessException as the root exception. These exceptions wrap the original exception.</p><p>What is SQLExceptionTranslator?</p><p>SQLExceptionTranslator, is an interface to be implemented by classes that can translate between SQLExceptions and Spring's own data-access-strategy-agnostic org.springframework.dao.DataAccessException.</p><p>What is Spring's JdbcTemplate?</p><p>Spring's JdbcTemplate is the central class which interacts with a database through JDBC. JdbcTemplate provides many convenience methods for doing things such as converting database data into primitives or objects, executing prepared and callable statements, and providing custom database error handling.
JdbcTemplate template = new JdbcTemplate(myDataSource);</p><p>Concerning JdbcTemplate, what is PreparedStatementCreator ?</p><p>It's one of the most common used interfaces for writing data to database. It has one method - createPreparedStatement(Connection)
Responsible for creating a PreparedStatement.
Does not need to handle SQLExceptions.</p><p>Concerning JdbcTemplate, what is SQLProvider ?</p><p>SQLProvider is a class with one method, getSql().
Typically this is implemented by PreparedStatementCreator implementers and is useful for debugging.</p><p>Concerning JdbcTemplate, what is RowCallbackHandler ?</p><p>The RowCallbackHandler interface extracts values from each row of a ResultSet.
Has one method - processRow(ResultSet)
Called for each row in ResultSet.
Typically stateful.</p><p>What are the five modes of Spring's autowiring functionality?</p><p>1. no - No autowiring is performed. All references to other beans must be explicitly injected. This is the default mode.
2. byName - Based on the name of a property, a matching bean name in the IoC container will be injected into this property if it exists.
3. byType - Based on the type of class on a setter, if only one instance of the class exists in the IoC container it will be injected into this property. If there is more than one instance of the class a fatal exception is thrown.
4. constructor - Based on a constructor argument's class types, if only one instance of the class exists in the IoC container it will be used in the constructor.
5. autodetect - If there is a valid constructor, the constructor autowiring mode will be chosen. Otherwise if there is a default zero argument constructor the byType autowiring mode will be chosen.</p><p></p><p>
What is the difference between procedural and object-oriented programs?</p><p>a) In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP program, unit of program is object, which is nothing but combination of data and code. b) In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code.</p><p>What are Encapsulation, Inheritance and Polymorphism?</p><p>Encapsulation is the mechanism that binds together code and data it manipulates and keeps both safe from outside interference and misuse. Inheritance is the process by which one object acquires the properties of another object. Polymorphism is the feature that allows one interface to be used for general class actions.</p><p>What is the difference between Assignment and Initialization?</p><p>Assignment can be done as many times as desired whereas initialization can be done only once.</p><p>What is OOPs?</p><p>Object oriented programming organizes a program around its data, i. e. , objects and a set of well defined interfaces to that data. An object-oriented program can be characterized as data controlling access to code.</p><p>What are Class, Constructor and Primitive data types?</p><p>Class is a template for multiple objects with similar features and it is a blue print for objects. It defines a type of object according to the data the object can hold and the operations the object can perform. Constructor is a special kind of method that determines how an object is initialized when created. Primitive data types are 8 types and they are: byte, short, int, long, float, double, boolean, char.</p><p>What is an Object and how do you allocate memory to it?</p><p>Object is an instance of a class and it is a software unit that combines a structured set of data with a set of operations for inspecting and manipulating that data. When an object is created using new operator, memory is allocated to it.</p><p>What is the difference between constructor and method?</p><p>Constructor will be automatically invoked when an object is created whereas method has to be called explicitly.</p><p>What are methods and how are they defined?</p><p>Methods are functions that operate on instances of classes in which they are defined. Objects can communicate with each other using methods and can call methods in other classes. Method definition has four parts. They are name of the method, type of object or primitive type the method returns, a list of parameters and the body of the method. A method's signature is a combination of the first three parts mentioned above.</p><p>What is the use of bin and lib in JDK?</p><p>Bin contains all tools such as javac, appletviewer, awt tool, etc., whereas lib contains API and all packages.</p><p>What is casting?</p><p>Casting is used to convert the value of one type to another.</p><p>How many ways can an argument be passed to a subroutine and explain them?</p><p>An argument can be passed in two ways. They are passing by value and passing by reference. Passing by value: This method copies the value of an argument into the formal parameter of the subroutine. Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed to the parameter.</p><p>What is the difference between an argument and a parameter?</p><p>While defining method, variables passed in the method are called parameters. While using those methods, values passed to those variables are called arguments.</p><p>What are different types of access modifiers?</p><p>public: Any thing declared as public can be accessed from anywhere. private: Any thing declared as private can't be seen outside of its class. protected: Any thing declared as protected can be accessed by classes in the same package and subclasses in the other packages. default modifier : Can be accessed only to classes in the same package.</p><p>What is final, finalize() and finally?</p><p>final : final keyword can be used for class, method and variables. A final class cannot be subclassed and it prevents other programmers from subclassing a secure class to invoke insecure methods. A final method can't be overridden. A final variable can't change from its initialized value. finalize() : finalize() method is used just before an object is destroyed and can be called just prior to garbage collection. finally : finally, a key word used in exception handling, creates a block of code that will be executed after a try/catch block has completed and before the code following the try/catch block. The finally block will execute whether or not an exception is thrown. For example, if a method opens a file upon exit, then you will not want the code that closes the file to be bypassed by the exception-handling mechanism. This finally keyword is designed to address this contingency.</p><p>What is UNICODE?</p><p>Unicode is used for internal representation of characters and strings and it uses 16 bits to represent each other.</p><p>What is Garbage Collection and how to call it explicitly?</p><p>When an object is no longer referred to by any variable, java automatically reclaims memory used by that object. This is known as garbage collection. System. gc() method may be used to call it explicitly.</p><p>What is finalize() method?</p><p>finalize () method is used just before an object is destroyed and can be called just prior to garbage collection.</p><p>What are Transient and Volatile Modifiers?</p><p>Transient: The transient modifier applies to variables only and it is not stored as part of its object's Persistent state. Transient variables are not serialized. Volatile: Volatile modifier applies to variables only and it tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of the program.</p><p>What is method overloading and method overriding?</p><p>Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding.</p><p>What is difference between overloading and overriding?</p><p>a) In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method. b) Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass. c) In overloading, separate methods share the same name whereas in overriding, subclass method replaces the superclass. d) Overloading must have different method signatures whereas overriding must have same signature.</p><p>What is meant by Inheritance and what are its advantages?</p><p>Inheritance is the process of inheriting all the features from a class. The advantages of inheritance are reusability of code and accessibility of variables and methods of the super class by subclasses.</p><p>What is the difference between this() and super()?</p><p>this() can be used to invoke a constructor of the same class whereas super() can be used to invoke a super class constructor.</p><p>What is the difference between superclass and subclass?</p><p>A super class is a class that is inherited whereas sub class is a class that does the inheriting.</p><p>What modifiers may be used with top-level class?</p><p>public, abstract and final can be used for top-level class.</p><p>What are inner class and anonymous class?</p><p>Inner class : classes defined in other classes, including those defined in methods are called inner classes. An inner class can have any accessibility including private. Anonymous class : Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors.</p><p>What is a package?</p><p>A package is a collection of classes and interfaces that provides a high-level layer of access protection and name space management.</p><p>What is a reflection package?</p><p>java. lang. reflect package has the ability to analyze itself in runtime.</p><p>What is interface and its use?</p><p>Interface is similar to a class which may contain method's signature only but not bodies and it is a formal set of method and constant declarations that must be defined by the class that implements it. Interfaces are useful for: a)Declaring methods that one or more classes are expected to implement b)Capturing similarities between unrelated classes without forcing a class relationship. c)Determining an object's programming interface without revealing the actual body of the class.</p><p>What is an abstract class?</p><p>An abstract class is a class designed with implementation gaps for subclasses to fill in and is deliberately incomplete.</p><p>What is the difference between Integer and int?</p><p>a) Integer is a class defined in the java. lang package, whereas int is a primitive data type defined in the Java language itself. Java does not automatically convert from one to the other. b) Integer can be used as an argument for a method that requires an object, whereas int can be used for calculations.</p><p>What is a cloneable interface and how many methods does it contain?</p><p>It is not having any method because it is a TAGGED or MARKER interface.</p><p>What is the difference between abstract class and interface?</p><p>a) All the methods declared inside an interface are abstract whereas abstract class must have at least one abstract method and others may be concrete or abstract. b) In abstract class, key word abstract must be used for the methods whereas interface we need not use that keyword for the methods. c) Abstract class must have subclasses whereas interface can't have subclasses.</p><p>Can you have an inner class inside a method and what variables can you access?</p><p>Yes, we can have an inner class inside a method and final variables can be accessed.</p><p>What is the difference between String and String Buffer?</p><p>a) String objects are constants and immutable whereas StringBuffer objects are not. b) String class supports constant strings whereas StringBuffer class supports growable and modifiable strings.</p><p>What is the difference between Array and vector?</p><p>Array is a set of related data type and static whereas vector is a growable array of objects and dynamic.</p><p>What is the difference between exception and error?</p><p>The exception class defines mild error conditions that your program encounters. Exceptions can occur when trying to open the file, which does not exist, the network connection is disrupted, operands being manipulated are out of prescribed ranges, the class file you are interested in loading is missing. The error class defines serious error conditions that you should not attempt to recover from. In most cases it is advisable to let the program terminate when such an error is encountered.</p><p>What is the difference between process and thread?</p><p>Process is a program in execution whereas thread is a separate path of execution in a program.</p><p>What is multithreading and what are the methods for inter-thread communication and what is the class in which these methods are defined?</p><p>Multithreading is the mechanism in which more than one thread run independent of each other within the process. wait (), notify () and notifyAll() methods can be used for inter-thread communication and these methods are in Object class. wait() : When a thread executes a call to wait() method, it surrenders the object lock and enters into a waiting state. notify() or notifyAll() : To remove a thread from the waiting state, some other thread must make a call to notify() or notifyAll() method on the same object.</p><p>What is the class and interface in java to create thread and which is the most advantageous method?</p><p>Thread class and Runnable interface can be used to create threads and using Runnable interface is the most advantageous method to create threads because we need not extend thread class here.</p><p>What are the states associated in the thread?</p><p>Thread contains ready, running, waiting and dead states.</p><p>What is synchronization?</p><p>Synchronization is the mechanism that ensures that only one thread is accessed the resources at a time.</p><p>When you will synchronize a piece of your code?</p><p>When you expect your code will be accessed by different threads and these threads may change a particular data causing data corruption.</p><p>What is deadlock?</p><p>When two threads are waiting each other and can't precede the program is said to be deadlock.</p><p>What is daemon thread and which method is used to create the daemon thread?</p><p>Daemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the java runtime system. setDaemon method is used to create a daemon thread.</p><p>Are there any global variables in Java, which can be accessed by other part of your program?</p><p>No, it is not the main method in which you define variables. Global variables is not possible because concept of encapsulation is eliminated here.</p><p>What is an applet?</p><p>Applet is a dynamic and interactive program that runs inside a web page displayed by a java capable browser.</p><p>What is the difference between applications and applets?</p><p>a)Application must be run on local machine whereas applet needs no explicit installation on local machine. b)Application must be run explicitly within a java-compatible virtual machine whereas applet loads and runs itself automatically in a java-enabled browser. d)Application starts execution with its main method whereas applet starts execution with its init method. e)Application can run with or without graphical user interface whereas applet must run within a graphical user interface.</p><p>How does applet recognize the height and width?</p><p>Using getParameters() method.</p><p>When do you use codebase in applet?</p><p>When the applet class file is not in the same directory, codebase is used.</p><p>What is the lifecycle of an applet?</p><p>init() method - Can be called when an applet is first loaded start() method - Can be called each time an applet is started. paint() method - Can be called when the applet is minimized or maximized. stop() method - Can be used when the browser moves off the applet's page. destroy() method - Can be called when the browser is finished with the applet.</p><p>How do you set security in applets?</p><p>using setSecurityManager() method</p><p>What is an event and what are the models available for event handling?</p><p>An event is an event object that describes a state of change in a source. In other words, event occurs when an action is generated, like pressing button, clicking mouse, selecting a list, etc. There are two types of models for handling events and they are: a) event-inheritance model and b) event-delegation model</p><p>What are the advantages of the model over the event-inheritance model?</p><p>The event-delegation model has two advantages over the event-inheritance model. They are: a)It enables event handling by objects other than the ones that generate the events. This allows a clean separation between a component's design and its use. b)It performs much better in applications where many events are generated. This performance improvement is due to the fact that the event-delegation model does not have to be repeatedly process unhandled events as is the case of the event-inheritance.</p><p>What is source and listener?</p><p>source : A source is an object that generates an event. This occurs when the internal state of that object changes in some way. listener : A listener is an object that is notified when an event occurs. It has two major requirements. First, it must have been registered with one or more sources to receive notifications about specific types of events. Second, it must implement methods to receive and process these notifications.</p><p>What is adapter class?</p><p>An adapter class provides an empty implementation of all methods in an event listener interface. Adapter classes are useful when you want to receive and process only some of the events that are handled by a particular event listener interface. You can define a new class to act listener by extending one of the adapter classes and implementing only those events in which you are interested. For example, the MouseMotionAdapter class has two methods, mouseDragged()and mouseMoved(). The signatures of these empty are exactly as defined in the MouseMotionListener interface. If you are interested in only mouse drag events, then you could simply extend MouseMotionAdapter and implement mouseDragged() .</p><p>What is meant by controls and what are different types of controls in AWT?</p><p>Controls are components that allow a user to interact with your application and the AWT supports the following types of controls: Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components. These controls are subclasses of Component.</p><p>What is the difference between choice and list?</p><p>A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices and only one item may be selected from a choice. A List may be displayed in such a way that several list items are visible and it supports the selection of one or more list items.</p><p>What is the difference between scrollbar and scrollpane?</p><p>A Scrollbar is a Component, but not a Container whereas Scrollpane is a Conatiner and handles its own events and perform its own scrolling.</p><p>What is a layout manager and what are different types of layout managers available in java AWT?</p><p>A layout manager is an object that is used to organize components in a container. The different layouts are available are FlowLayout, BorderLayout, CardLayout, GridLayout and GridBagLayout.</p><p>How are the elements of different layouts organized?</p><p>FlowLayout: The elements of a FlowLayout are organized in a top to bottom, left to right fashion. BorderLayout: The elements of a BorderLayout are organized at the borders (North, South, East and West) and the center of a container. CardLayout: The elements of a CardLayout are stacked, on top of the other, like a deck of cards. GridLayout: The elements of a GridLayout are of equal size and are laid out using the square of a grid. GridBagLayout: The elements of a GridBagLayout are organized according to a grid. However, the elements are of different size and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.</p><p>Which containers use a Border layout as their default layout?</p><p>Window, Frame and Dialog classes use a BorderLayout as their layout.</p><p>Which containers use a Flow layout as their default layout?</p><p>Panel and Applet classes use the FlowLayout as their default layout.</p><p>What are wrapper classes?</p><p>Wrapper classes are classes that allow primitive types to be accessed as objects.</p><p>What are Vector, Hashtable, LinkedList and Enumeration?</p><p>Vector : The Vector class provides the capability to implement a growable array of objects. Hashtable : The Hashtable class implements a Hashtable data structure. A Hashtable indexes and stores objects in a dictionary using hash codes as the object's keys. Hash codes are integer values that identify objects. LinkedList: Removing or inserting elements in the middle of an array can be done using LinkedList. A LinkedList stores each object in a separate link whereas an array stores object references in consecutive locations. Enumeration: An object that implements the Enumeration interface generates a series of elements, one at a time. It has two methods, namely hasMoreElements() and nextElement(). HasMoreElemnts() tests if this enumeration has more elements and nextElement method returns successive elements of the series.</p><p>What is the difference between set and list?</p><p>Set stores elements in an unordered way but does not contain duplicate elements, whereas list stores elements in an ordered way but may contain duplicate elements.</p><p>What is a stream and what are the types of Streams and classes of the Streams?</p><p>A Stream is an abstraction that either produces or consumes information. There are two types of Streams and they are: Byte Streams: Provide a convenient means for handling input and output of bytes. Character Streams: Provide a convenient means for handling input & output of characters. Byte Streams classes: Are defined by using two abstract classes, namely InputStream and OutputStream. Character Streams classes: Are defined by using two abstract classes, namely Reader and Writer.</p><p>What is the difference between Reader/Writer and InputStream/Output Stream?</p><p>The Reader/Writer class is character-oriented and the InputStream/OutputStream class is byte-oriented.</p><p>What is an I/O filter?</p><p>An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.</p><p>What is serialization and deserialization?</p><p>Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects.</p><p>What is JDBC?</p><p>JDBC is a set of Java API for executing SQL statements. This API consists of a set of classes and interfaces to enable programs to write pure Java Database applications.</p><p>What are drivers available?</p><p>a) JDBC-ODBC Bridge driver b) Native API Partly-Java driver c) JDBC-Net Pure Java driver d) Native-Protocol Pure Java driver</p><p>What is the difference between JDBC and ODBC?</p><p>a) OBDC is for Microsoft and JDBC is for Java applications. b) ODBC can't be directly used with Java because it uses a C interface. c) ODBC makes use of pointers which have been removed totally from Java. d) ODBC mixes simple and advanced features together and has complex options for simple queries. But JDBC is designed to keep things simple while allowing advanced capabilities when required. e) ODBC requires manual installation of the ODBC driver manager and driver on all client machines. JDBC drivers are written in Java and JDBC code is automatically installable, secure, and portable on all platforms. f) JDBC API is a natural Java interface and is built on ODBC. JDBC retains some of the basic features of ODBC.</p><p>What are the types of JDBC Driver Models and explain them?</p><p>There are two types of JDBC Driver Models and they are: a) Two tier model and b) Three tier model Two tier model: In this model, Java applications interact directly with the database. A JDBC driver is required to communicate with the particular database management system that is being accessed. SQL statements are sent to the database and the results are given to user. This model is referred to as client/server configuration where user is the client and the machine that has the database is called as the server. Three tier model: A middle tier is introduced in this model. The functions of this model are: a) Collection of SQL statements from the client and handing it over to the database, b) Receiving results from database to the client and c) Maintaining control over accessing and updating of the above.</p><p>What type of driver did you use in project?</p><p>JDBC-ODBC Bridge driver (is a driver that uses native(C language) libraries and makes calls to an existing ODBC driver to access a database engine).</p><p>What are the types of statements in JDBC?</p><p>Statement: to be used createStatement() method for executing single SQL statement PreparedStatement — To be used preparedStatement() method for executing same SQL statement over and over. CallableStatement — To be used prepareCall() method for multiple SQL statements over and over.</p><p>What is stored procedure?</p><p>Stored procedure is a group of SQL statements that forms a logical unit and performs a particular task. Stored Procedures are used to encapsulate a set of operations or queries to execute on database. Stored procedures can be compiled and executed with different parameters and results and may have any combination of input/output parameters.</p><p>How to create and call stored procedures?</p><p>To create stored procedures: Create procedure procedurename (specify in, out and in out parameters) BEGIN Any multiple SQL statement; END; To call stored procedures: CallableStatement csmt = con. prepareCall("{call procedure name(?,?)}"); csmt. registerOutParameter(column no. , data type); csmt. setInt(column no. , column name) csmt. execute();</p><p>What is servlet?</p><p>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 company's order database.</p><p>What are the classes and interfaces for servlets?</p><p>There are two packages in servlets and they are javax. servlet and</p><p>What is the difference between an applet and a servlet?</p><p>a) Servlets are to servers what applets are to browsers. b) Applets must have graphical user interfaces whereas servlets have no graphical user interfaces.</p><p>What is the difference between doPost and doGet methods?</p><p>a) doGet() method is used to get information, while doPost() method is used for posting information. b) doGet() requests can't send large amount of information and is limited to 240-255 characters. However, doPost()requests passes all of its data, of unlimited length. c) A doGet() request is appended to the request URL in a query string and this allows the exchange is visible to the client, whereas a doPost() request passes directly over the socket connection as part of its HTTP request body and the exchange are invisible to the client.</p><p>What is the life cycle of a servlet?</p><p>Each Servlet has the same life cycle: a) A server loads and initializes the servlet by init () method. b) The servlet handles zero or more client's requests through service() method. c) The server removes the servlet through destroy() method.</p><p>Who is loading the init() method of servlet?</p><p>Web server</p><p>What are the different servers available for developing and deploying Servlets?</p><p>a) Java Web Server b) JRun g) Apache Server h) Netscape Information Server i) Web Logic</p><p>How many ways can we track client and what are they?</p><p>The servlet API provides two ways to track client state and they are: a) Using Session tracking and b) Using Cookies.</p><p>What is session tracking and how do you track a user session in servlets?</p><p>Session tracking is a mechanism that servlets use to maintain state about a series requests from the same user across some period of time. The methods used for session tracking are: a) User Authentication - occurs when a web server restricts access to some of its resources to only those clients that log in using a recognized username and password. b) Hidden form fields - fields are added to an HTML form that are not displayed in the client's browser. When the form containing the fields is submitted, the fields are sent back to the server. c) URL rewriting - every URL that the user clicks on is dynamically modified or rewritten to include extra information. The extra information can be in the form of extra path information, added parameters or some custom, server-specific URL change. d) Cookies - a bit of information that is sent by a web server to a browser and which can later be read back from that browser. e) HttpSession- places a limit on the number of sessions that can exist in memory. This limit is set in the session. maxresidents property.</p><p>What is Server-Side Includes (SSI)?</p><p>Server-Side Includes allows embedding servlets within HTML pages using a special servlet tag. In many servlets that support servlets, a page can be processed by the server to include output from servlets at certain points inside the HTML page. This is accomplished using a special internal SSINCLUDE, which processes the servlet tags. SSINCLUDE servlet will be invoked whenever a file with an. shtml extension is requested. So HTML files that include server-side includes must be stored with an . shtml extension.</p><p>What are cookies and how will you use them?</p><p>Cookies are a mechanism that a servlet uses to have a client hold a small amount of state-information associated with the user. a) Create a cookie with the Cookie constructor: public Cookie(String name, String value) b) A servlet can send a cookie to the client by passing a Cookie object to the addCookie() method of HttpServletResponse: public void HttpServletResponse. addCookie(Cookie cookie) c) A servlet retrieves cookies by calling the getCookies() method of HttpServletRequest: public Cookie[ ] HttpServletRequest. getCookie().</p><p>Is it possible to communicate from an applet to servlet and how many ways and how?</p><p>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</p><p>What is connection pooling?</p><p>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.</p><p>Why should we go for interservlet communication?</p><p>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)</p><p>Is it possible to call servlet with parameters in the URL?</p><p>Yes. You can call a servlet with parameters in the syntax as (?Param1 = xxx || m2 = yyy).</p><p>What is Servlet chaining?</p><p>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.</p><p>How do servlets handle multiple simultaneous requests?</p><p>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.</p><p>What is the difference between TCP/IP and UDP?</p><p>TCP/IP is a two-way communication between the client and the server and it is a reliable and there is a confirmation regarding reaching the message to the destination. It is like a phone call. UDP is a one-way communication only between the client and the server and it is not a reliable and there is no confirmation regarding reaching the message to the destination. It is like a postal mail.</p><p>What is Inet address?</p><p>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.</p><p>What is Domain Naming Service(DNS)?</p><p>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.</p><p>What is URL?</p><p>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.</p><p>What is RMI and steps involved in developing an RMI object?</p><p>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</p><p>What is RMI architecture?</p><p>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.</p><p>what is UnicastRemoteObject?</p><p>All remote objects must extend UnicastRemoteObject, which provides functionality that is needed to make objects available from remote machines.</p><p>Explain the methods, rebind() and lookup() in Naming class?</p><p>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.</p><p>What is a Java Bean?</p><p>A Java Bean is a software component that has been designed to be reusable in a variety of different environments.</p><p>What is a Jar file?</p><p>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.</p><p>What is BDK?</p><p>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.</p><p>What is JSP?</p><p>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.</p><p>What are JSP scripting elements?</p><p>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 formthat 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.</p><p>What are JSP Directives?</p><p>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</p><p>What are Predefined variables or implicit objects?</p><p>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.</p><p>What are JSP ACTIONS?</p><p>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</p><p>How do you pass data (including JavaBeans) to a JSP from a servlet?</p><p>(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:<jsp: useBean id="theBean" scope="request" class=". . . . . " />(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:<jsp:useBean id="theBean" scope="session" class=". . . " /> 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:<jsp:useBean id="theBean" scope="application" class=". . . " /></p><p>How can I set a cookie in JSP?</p><p>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); %></p><p>How can I delete a cookie with JSP?</p><p>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); %></p><p>How are Servlets and JSP Pages related?</p><p>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.</p><p>Why is Java not 100% Object-oriented?</p><p>Java is not 100% Object-oriented because it makes use of eight primitive data types such as boolean, byte, char, int, float, double, long, short which are not objects.</p><p>What are wrapper classes in Java?</p><p>Wrapper classes convert the Java primitives into the reference types (objects). Every primitive data type has a class dedicated to it. These are known as wrapper classes because they "wrap" the primitive data type into an object of that class. Refer to the below image which displays different primitive type, wrapper class and constructor argument.</p><p>What are constructors in Java?</p><p>In Java, constructor refers to a block of code which is used to initialize an object. It must have the same name as that of the class. Also, it has no return type and it is automatically called when an object is created.</p><p>There are 3 types of constructors:</p><p>Nullary Constructor: A nullary constructor is a constructor which takes no arguments, and possibly defines logic in its body with the intent to default on instance variable values.</p><p>What is JIT compiler in Java?</p><p>JIT stands for Just-In-Time compiler in Java. It is a program that helps in converting the Java bytecode into instructions that are sent directly to the processor. By default, the JIT compiler is enabled in Java and is activated whenever a Java method is invoked. The JIT compiler then compiles the bytecode of the invoked method into native machine code, compiling it "just in time" to execute. Once the method has been compiled, the JVM summons the compiled code of that method directly rather than interpreting it. This is why it is often responsible for the performance optimization of Java applications at the run time.</p><p>What are access modifiers in Java?</p><p>In Java, access modifiers are special keywords which are used to restrict the access of a class, constructor, data member and method in another class.</p><p>Java supports four types of access modifiers:</p><p>Default Private Protected Public</p><p>What is an object in Java and how is it created?</p><p>An object is a real-world entity that has a state and behavior. An object has three characteristics: State, Behavior, Identity</p><p>What are the 4 main concepts of OOPs in Java?</p><p>Inheritance, Encapsulation, Abstraction, Polymorphism</p><p>What is a local variable ?</p><p>In Java, a local variable is typically used inside a method, constructor, or a block and has only local scope. Thus, this variable can be used only within the scope of a block. The best benefit of having a local variable is that other methods in the class won't be even aware of that variable.</p><p>What is an instance variable?</p><p>Whereas, an instance variable in Java, is a variable which is bounded to its object itself. These variables are declared within a class, but outside a method. Every object of that class will create it's own copy of the variable while using it. Thus, any changes made to the variable won't reflect in any other instances of that class and will be bound to that particular instance only.</p><p>What is the final keyword in Java?</p><p>final is a special keyword in Java that is used as a non-access modifier. When the final keyword is used with a variable then its value can't be changed once assigned. In case the no value has been assigned to the final variable then using only the class constructor a value can be assigned to it</p><p>What is a Map in Java?</p><p>In Java, Map is an interface of Util package which maps unique keys to values. The Map interface is not a subset of the main Collection interface and thus it behaves little differently from the other collection types.</p><p>What are characteristics of Map in Java?</p><p>Map doesn't contain duplicate keys. Each key can map at max one value.</p><p>What are the different types of JSP tags?</p><p>Directives, Declarations,Scriptlets,Expressions</p><p>Describe the Secure Socket Layer (SSL)?</p><p>The technology that is used to communicate between the web server and the web browser is called Secure Socket Layer (SSL). More specifically, SSL is a protocol that describes how algorithms are to be used in encryption.</p><p>What is EJB?</p><p>EJB stands for Enterprise Java Beans. It is the server-side component that executes in EJB container and encapsulates the business logic for the enterprise application.</p><p>
</body>
</html>