JDBC; Threading

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is distributed application ?

An application made up of distinct components running in separate runtime environments, usually on different platforms connected via a network. Typical distributed applications are two-tier (client-server), three-tier (client-middleware-server), and multitier (client-multiple middleware-multiple servers).

How will u call java method from flex?

Using Remote object.

What is message-driven bean ?

an enterprise bean that is an asynchronous message consumer. A message-driven bean has no state for a specific client, but its instance variables can contain state across the handling of client messages, including an open database connection and an object reference to an EJB object. A client accesses a message-driven bean by sending messages to the destination for which the bean is a message listener.

What are the config files used for connecting java and flex?

*data- management-config.xml *messaging-config.xml *proxy-config.xml *remoting-config.xml *services-config.xml

Different ways of using style sheets?

*using external style sheets *using local style definitions *using the style manager class *using the set style() getstyle() methods *using inline styles loading style sheets at runtime

How do u generate random numbers within a given limit with Action script?

randNum:Number = Math.random()*100;

What is JavaBeans component ?

A Java class that can be manipulated by tools and composed into applications. A JavaBeans component must adhere to certain property and event interface conventions.

What is EJB container ?

A container that implements the EJB component contract of the J2EE architecture. This contract specifies a runtime environment for enterprise beans that includes security, concurrency, life-cycle management, transactions, deployment, naming, and other services. An EJB container is provided by an EJB or J2EE server.

What is "applet container" ?

A container that includes support for the applet programming model.

What is cascade delete ?

A deletion that triggers another deletion. A cascade delete can be specified for an entity bean that has container-managed persistence.

What is EJB module ?

A deployable unit that consists of one or more enterprise beans and an EJB deployment descriptor.

What is "application client" ?

A first-tier J2EE client component that executes in its own Java virtual machine. Application clients have access to some J2EE platform APIs.

What is component-managed sign-on ?

A mechanism whereby security information needed for signing on to a resource is provided by an application component.

What is publish/subscribe messaging system ?

A messaging system in which clients address messages to a specific node in a content hierarchy, called a topic. Publishers and subscribers are generally anonymous and can dynamically publish or subscribe to the content hierarchy. The system takes care of distributing the messages arriving from a node's multiple publishers to its multiple subscribers.

What is context root ?

A name that gets mapped to the document root of a Web application.

What is "application assembler" ?

A person who combines J2EE components and modules into deployable application units.

What is PreparedStatement?

A prepared statement is an SQL statement that is precompiled by the database. Through precompilation, prepared statements improve the performance of SQL commands that are executed multiple times (given that the database supports prepared statements). Once compiled, prepared statements can be customized prior to each execution by altering predefined SQL parameters. PreparedStatement pstmt = conn.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?"); pstmt.setBigDecimal(1, 153833.00); pstmt.setInt(2, 110592);

What is "attribute"?

A qualifier on an XML tag that provides additional information.

What is Document Object Model ?

An API for accessing and manipulating XML documents as tree structures. DOM provides platform-neutral, language-neutral interfaces that enables programs and scripts to dynamically access and modify content and structure in XML documents.

What is deployment descriptor ?

An XML file provided with each module and J2EE application that describes how they should be deployed. The deployment descriptor directs a deployment tool to deploy a module or application with specific container options and describes specific configuration requirements that a deployer must resolve.

What is business logic ?

The code that implements the functionality of an application. In the Enterprise JavaBeans architecture, this logic is implemented by the methods of an enterprise bean.

What is J2EE?

J2EE is an environment for developing and deploying enterprise applications. The J2EE platform consists of a set of services, application programming interfaces (APIs), and protocols that provide the functionality for developing multitier, web-based applications.

What is "archiving" ?

The process of saving the state of an object and restoring it.

What is authentication ?

The process that verifies the identity of a user, device, or other entity in a computer system, usually as a prerequisite to allowing access to resources in a system. The Java servlet specification requires three types of authentication-basic, form-based, and mutual-and supports digest authentication.

What Are RESTful Web Services?

RESTful web services are built to work best on the Web. Representational State Transfer (REST) is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web service induce desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web. In the REST architectural style, data and functionality are considered resources and are accessed using Uniform Resource Identifiers (URIs), typically links on the Web. The resources are acted upon by using a set of simple, well-defined operations. The REST architectural style constrains an architecture to a client/server architecture and is designed to use a stateless communication protocol, typically HTTP. In the REST architecture style, clients and servers exchange representations of resources by using a standardized interface and protocol.

When to use Template method design Pattern in Java

Template pattern is another popular core Java design pattern interview question. I have seen it appear many times in real life project itself. Template pattern outlines an algorithm in form of template method and let subclass implement individual steps. Key point to mention, while answering this question is that template method should be final, so that subclass can not override and change steps of algorithm, but same time individual step should be abstract, so that child classes can implement them.

What is the need of BatchUpdates?

The BatchUpdates feature allows us to group SQL statements together and send to database server in one single trip.

What is Singleton pattern in Java?

Singleton pattern in Java is a pattern which allows only one instance of Singleton class available in whole application. java.lang.Runtime is good example of Singleton pattern in Java. There are lot's of follow up questions on Singleton pattern see 10 Java singleton interview question answers for those followups

What is Observer design pattern in Java? When do you use Observer pattern in Java?

This is one of the most common Java design pattern interview question. Observer pattern is based upon notification, there are two kinds of object Subject and Observer. Whenever there is change on subject's state observer will receive notification. See What is Observer design pattern in Java with real life example for more details.

What is EAR file ?

Enterprise Archive file. A JAR archive that contains a J2EE application.

What is the difference between wait() and sleep()?

1) wait() is a method of Object class. sleep() is a method of Object class. 2) sleep() allows the thread to go to sleep state for x milliseconds. When a thread goes into sleep state it doesn't release the lock. wait() allows thread to release the lock and goes to suspended state. The thread is only active when a notify() or notifAll() method is called for the same object.

What is J2EE component ?

A self-contained functional software unit supported by a container and configurable at deployment time. The J2EE specification defines the following J2EE components: Application clients and applets are components that run on the client. Java servlet and JavaServer Pages (JSP) technology components are Web components that run on the server. Enterprise JavaBeans (EJB) components (enterprise beans) are business components that run on the server. J2EE components are written in the Java programming language and are compiled in the same way as any program in the language. The difference between J2EE components and "standard" Java classes is that J2EE components are assembled into a J2EE application, verified to be well formed and in compliance with the J2EE specification, and deployed to production, where they are run and managed by the J2EE server or client container.

What is CSS ?

Cascading style sheet. A stylesheet used with HTML and XML documents to add a style to all elements marked with a particular tag, for the direction of browsers or other presentation mechanisms.

What is binding (XML) ?

Generating the code needed to process a well-defined portion of XML data.

What is HTTPS ?

HTTP layered over the SSL protocol.

How can u call Javascript from MXML?

IExternalInterface.call()

What is durable subscription ?

In a JMS publish/subscribe messaging system, a subscription that continues to exist whether or not there is a current active subscriber object. If there is no active subscriber, the JMS provider retains the subscription's messages until they are received by the subscription or until they expire.

What is the difference between Flex 2.0 & 3.0?

Native support for Adobe AIR - Flex 3 introduces new components and incorporates the Adobe AIR development tools into the SDK and Flex Builder. • Persistent framework caching - We can make Flex 3 applications as small as 50K when leveraging the new Flash Player cache for Adobe platform components. In fact the size of the resulting swf size had reduced for a larger bit. • Flex Builder productivity enhancements - Flex Builder 3 introduces refactoring support, new profilers for performance and memory tuning, and code generation tools for data access. • Integration with Creative Suite 3 - The Flex Component Kit for Flash CS3 allows Flash CS3 users to build components that can be seamlessly integrated into a Flex application, while Flex Builder 3 adds new wizards for importing assets from CS3 applications as skins. • Advanced DataGrid - The Advanced DataGrid is a new component that adds commonly requested features to the DataGrid such as support for hierarchical data, and basic pivot table functionality. • First steps toward open source flex. As a first step toward making Flex an open source project, Adobe have opened up the Flex and Flex Builder bug tracking system to the public, as well as published detailed roadmap information. Enhanced Features like Faster compilation time, SWF file size reduction, Flex/Ajax Bridge, Advanced DataGrid, Interactive debugging, Cross-Domain, Versionable, Easy to Use, Security and Code Signing, Failover and Hosting, Cross-Domain RSL, Advanced DatagridDeep Linking, Resource Bundles and Runtime Localization, Flex Component Kit for Flash CS3, Compilation, Language IntelligenceRefactoring, Class Outline, Code Search, Profiler, Module Support, Multiple SDK Support, Skin Importer, Design View Zoom/Pan, Design Mode support for ItemRenderers, Advanced Constraints, CS3 Suite integration, CSS Outline, CSS Design View, Flex 3 SDK Skinning/Style Enhancements.

Can the variables or classes be Synchronized?

No. Only methods can be synchronized.

What is SOAP?

SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks. It relies on XML Information Set for its message format, and usually relies on other Application Layer protocols, most notably Hypertext Transfer Protocol (HTTP) or Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission.

What does application client module contain?

The application client module contains: --class files, --an application client deployment descriptor. Application client modules are packaged as JAR files with a .jar extension.

What is principal ?

The identity assigned to a user as a result of authentication.

What are the new features added to JDBC 4.0?

The major features added in JDBC 4.0 include : Auto-loading of JDBC driver class Connection management enhancements Support for RowId SQL type DataSet implementation of SQL using Annotations SQL exception handling enhancements SQL XML suppor

Event Bubbling:

The mechanism through which event objs are passed from the objs that generates an event up through the containership hierarchy.

What is document root ?

The top-level directory of a WAR. The document root is where JSP pages, client-side classes and archives, and static Web resources are stored.

What does web module contain?

The web module contains: --JSP files, --class files for servlets, --GIF and HTML files, and --a Web deployment descriptor. Web modules are packaged as JAR files with a .war (Web ARchive) extension.

How can u use 2 styles at the same time?

Using external style sheets and inline style commands.

What is an Event Propagation?

When events are triggered, there are 3 phases in which Flex checks whether there are event listeners. 3 phases are: * Capturing * Targetting * Bubbling

Drawbacks of Flex

* HTML5 is here and is supported by everyone. Even by Adobe and Microsoft. * There is no good alternative flash player like there are alternative web browsers. * Flash is proprietary and not a web standard. * Flex is no longer open source, and neither IDE tools are free.

Benefits of flex?

* It runs on the flash player, which can be found almost everywhere. * It's backed by a major company, Adobe. * There are plenty of frameworks and tools built for and around it from Adobe and the community. * IDE support comes from Adobe with FlashBuilder, and Jetbrains with Intellij. * Developing RIA with Flex can be considered easier than with HTML and JavaScript. * Flex apps can easily run outside the browser, and offline.

Life cycle of flex appln/component?

* Pre initialize : The Appln has been initiated but has not yet created any child components. * Initialize :The Appln has created child components but has not yet laid out those components. * Creation Complete : The Appln has been completely initiated and has laid out all components.

What are the 2 ways to compile flex source file?

* directly save .mxml file in bin directory of your flex folder(bin dir is the place where the flex compiler is located) * apache's ant technology, a build.xml file is created & is used to call the flex compiler and compile the flex.mxml file.

How do u implement PUSH on a flex appln?

* using BlazeDS server, livecycle data services.

What are channels & their types in flex?

*Channel is the base class of message channel class *Here all the channel in messaging must extend this class *Channels are specific protocol based conduits for messages sent between message agents and remote destinations.

What are the three ways to skin a component?

*Graphical skins *Programatic skins *Stateful skins

.Similarities between Flex & Java?

*both can be used as client applns *both have packages *Oop based *Support xml *import external packages *Upcasting *Support Array collection *Amost same primitive data types *both support class library packaging(.jar,.swc)

Types of binding:

*using curly braces ({}) *using Action script expressions in curly braces *using the tag in mxml *using bindings in Actionscript (Binding utils)

What are the four types of J2EE modules

. Application client module 2. Web module 3. Enterprise JavaBeans module 4. Resource adapter module

What is difference between thread and process?

1. Threads share the address space of the process that created it; processes have their own address. 2. Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process. 3. Threads can directly communicate with other threads of its process; processes must use interprocess communication to communicate with sibling processes. 4. Threads have almost no overhead; processes have considerable overhead. 5. New threads are easily created; new processes require duplication of the parent process. 6. Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes. 7. Changes to the main thread (cancellation, priority change, etc.) may affect the behavior of the other threads of the process; changes to the parent process do not affect child processes.

What is a DataSource?

A DataSource object is the representation of a data source in the Java programming language. In basic terms, A DataSource is a facility for storing data. DataSource can be referenced by JNDI. Data Source may point to RDBMS, file System , any DBMS etc..

What are the components of J2EE application?

A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and communicates with other components. The J2EE specification defines the following J2EE components: Application clients and applets are client components. Java Servlet and JavaServer PagesTM (JSPTM) technology components are web components. Enterprise JavaBeansTM (EJBTM) components (enterprise beans) are business components. Resource adapter components provided by EIS and tool vendors.

What is enterprise bean ?

A J2EE component that implements a business task or business entity and is hosted by an EJB container; either an entity bean, a session bean, or a message-driven bean.

What is "applet" ?

A J2EE component that typically executes in a Web browser but can execute in a variety of other applications or devices that support the applet programming model.

What is the J2EE module?

A J2EE module consists of one or more J2EE components for the same container type and one component deployment descriptor of that type.

What is EJB JAR file ?

A JAR archive that contains an EJB module.

What is "asant" ?

A Java-based build tool that can be extended using Java classes. The configuration files are XML-based, calling out a target tree where various tasks get executed.

What is connection pooling? what is the main advantage of using connection pooling?

A connection pool is a mechanism to reuse connections created. Connection pooling can increase performance dramatically by reusing connections rather than creating a new physical connection each time a connection is requested..

What is "application client container" ?

A container that supports application client components.

What is "application client module" ?

A software unit that consists of one or more classes and an application client deployment descriptor.

What is connector ?

A standard extension mechanism for containers that provides connectivity to enterprise information systems. A connector is specific to an enterprise information system and consists of a resource adapter and application development tools for enterprise information system connectivity. The resource adapter is plugged in to a container through its support for system-level contracts defined in the Connector architecture.

What is bean-managed transaction ?

A transaction whose boundaries are defined by an enterprise bean.

What is certificate authority ?

A trusted organization that issues public key certificates and provides identification to the bearer.

What is "application component provider" ?

A vendor that provides the Java classes that implement components' methods, JSP page definitions, and any required deployment descriptor

What is EJB context ?

A vendor that supplies an EJB container. An object that allows an enterprise bean to invoke services provided by the container and to obtain the information about the caller of a client-invoked method.

What is Java Naming and Directory Interface (JNDI) ?

An API that provides naming and directory functionality.

What is "application configuration resource file" ?

An XML file used to configure resources for a Java Server Faces application, to define navigation rules for the application, and to register converters, Validator, listeners, renders, and components with the application.

Associative Arrays in flex

An associative array, sometimes called a hash or map, uses keys instead of a numeric index to organize stored values. Each key in an associative array is a unique string that is used to access a stored value. There are two ways to create associative arrays in ActionScript 3.0. The first way is to use the Object constructor, which has the advantage of allowing you to initialize your array with an object literal. An instance of the Object class, also called a generic object, is functionally identical to an associative array. Each property name of the generic object serves as the key that provides access to a stored value. The following example creates an associative array named monitorInfo, using an object literal to initialize the array with two key and value pairs: var monitorInfo:Object = {type:"Flat Panel", resolution:"1600 x 1200″}; trace(monitorInfo["type"], monitorInfo["resolution"]); // output: Flat Panel 1600 x 1200 If you do not need to initialize the array at declaration time, you can use the Object constructor to create the array, as follows: var monitorInfo:Object = new Object()

What is basic authentication ?

An authentication mechanism in which a Web server authenticates an entity via a user name and password obtained using the Web application's built-in authentication mechanism.

What is client-certificate authentication ?

An authentication mechanism that uses HTTP over SSL, in which the server and, optionally, the client authenticate each other with a public key certificate that conforms to a standard that is defined by X.509 Public Key Infrastructure.

What is EJB object ?

An object whose class implements the enterprise bean's remote interface. A client never references an enterprise bean instance directly; a client always references an EJB object. The class of an EJB object is generated by a container's deployment tools.

Difference between Decorator and Proxy pattern in Java?

Another tricky Java design pattern question and trick here is that both Decorator and Proxy implements interface of the object they decorate or encapsulate. As I said, many Java design pattern can have similar or exactly same structure but they differ in there intent. Decorator pattern is used to implement functionality on already created object, while Proxy pattern is used for controlling access to object. One more difference between Decorator and Proxy design pattern is that, Decorator doesn't create object, instead it get object in it's constructor, while Proxy actually creates objects.

What happens when start() is called?

Ans) A new thread of execution with a new call stack starts. The state of thread changes from new to runnable. When the thread gets chance to execute its target run() method starts to run.

What are the daemon threads?

Ans) Daemon thread are service provider threads run in the background,these not used to run the application code generally.When all user threads(non-daemon threads) complete their execution the jvm exit the application whatever may be the state of the daemon threads. Jvm does not wait for the daemon threads to complete their execution if all user threads have completed their execution. To create Daemon thread set the daemon value of Thread using setDaemon(boolean value) method. By default all the threads created by user are user thread. To check whether a thread is a Daemon thread or a user thread use isDaemon() method. Example of the Daemon thread is the Garbage Collector run by jvm to reclaim the unused memory by the application. The Garbage collector code runs in a Daemon thread which terminates as all the user threads are done with their execution.

What happens if a start method is not invoked and the run method is directly invoked?

Ans) If a thread has been instantiated but not started its is said to be in new state. Unless until a start() method is invoked on the instance of the thread, it will not said to be alive. If you do not call a start() method on the newly created thread instance thread is not considered to be alive. If the start() method is not invoked and the run() method is directly called on the Thread instance, the code inside the run() method will not run in a separate new thread but it will start running in the existing thread.

What is a volatile keyword?

Ans) In general each thread has its own copy of variable, such that one thread is not concerned with the value of same variable in the other thread. But sometime this may not be the case. Consider a scenario in which the count variable is holding the number of times a method is called for a given class irrespective of any thread calling, in this case irrespective of thread access the count has to be increased so the count variable is declared as volatile. The copy of volatile variable is stored in the main memory, so every time a thread access the variable even for reading purpose the local copy is updated each time from the main memory. The volatile variable also have performance issues.

What are the different states of a thread's lifecycle?

Ans) The different states of threads are as follows: 1) New - When a thread is instantiated it is in New state until the start() method is called on the thread instance. In this state the thread is not considered to be alive. 2) Runnable - The thread enters into this state after the start method is called in the thread instance. The thread may enter into the Runnable state from Running state. In this state the thread is considered to be alive. 3) Running - When the thread scheduler picks up the thread from the Runnable thread's pool, the thread starts running and the thread is said to be in Running state. 4) Waiting/Blocked/Sleeping - In these states the thread is said to be alive but not runnable. The thread switches to this state because of reasons like wait method called or sleep method has been called on the running thread or thread might be waiting for some i/o resource so blocked. 5) Dead - When the thread finishes its execution i.e. the run() method execution completes, it is said to be in dead state. A dead state can not be started again. If a start() method is invoked on a dead thread a runtime exception will occur.

) If code running is a thread creates a new thread what will be the initial priority of the newly created thread?

Ans) When a code running in a thread creates a new thread object , the priority of the new thread is set equal to the priority of the thread which has created it.

What is the difference when the synchronized keyword is applied to a static method or to a non static method?

Ans) When a synch non static method is called a lock is obtained on the object. When a synch static method is called a lock is obtained on the class and not on the object. The lock on the object and the lock on the class don’t interfere with each other. It means, a thread accessing a synch non static method, then the other thread can access the synch static method at the same time but can’t access the synch non static method.

What is difference between notify() and notfiyAll()?

Ans) notify( ) wakes up the first thread that called wait( ) on the same object. notifyAll( ) wakes up all the threads that called wait( ) on the same object. The highest priority thread will run first.

What is use of synchronized keyword?

Ans) synchronized keyword can be applied to static/non-static methods or a block of code. Only one thread at a time can access synchronized methods and if there are multiple threads trying to access the same method then other threads have to wait for the execution of method by one thread. Synchronized keyword provides a lock on the object and thus prevents race condition. E.g. public void synchronized method(){} public void synchronized staticmethod(){} public void myMethod(){ synchronized (this){ // synchronized keyword on block of code }

What is the difference between yield() and sleep()?

Ans) yield() allows the current the thread to release its lock from the object and scheduler gives the lock of the object to the other thread with same priority. sleep() allows the thread to go to sleep state for x milliseconds. When a thread goes into sleep state it doesn't release the lock.

What is J2EE application ?

Any deployable unit of J2EE functionality. This can be a single J2EE module or a group of modules packaged into an EAR file along with a J2EE application deployment descriptor. J2EE applications are typically engineered to be distributed across multiple computing tiers.

What is the difference between httpService & Data Service?

Basically, Flex allows three types of RPC services: HttpService, WebServices, and RemoteObject Services. In Flex, using the "RemoteObjects specifies named or unnamed sources and connects to an Action Message Format (AMF) gateway, whereas using the HTTPService and WebService use named services or raw URLs and connect to an HTTP proxy using text-based query parameters or XML". Specifically, HTTPServices use raw HTTP requests, WebServices use the SOAP protocol and RemoteObjects uses AMF3. The Flex presentation layer communicates with the business layer by using Flex data services, which are objects we insert in a Flex file. Specifically, we can use Flex data services to interact with the following: * Web services * HTTP services * Remote objects A Flex data service is an object we insert in an MXML file to communicate with the business layer of a multi-tier application. We use data services to send and receive data from web services, HTTP URLs, and remote objects such as server-based Java objects. An HTTP service is nothing more than an HTTP request to a URL. The primary purpose of HTTP services is to retrieve XML data from an external source. "RemoteObject provides two advantages over HTTP or SOAP. First, while the AMF protocol uses HTTP to transfer packets, the data is transferred in a binary format that is natively understood by the Flash Player. As a result, data can move across the network more quickly and it can be deserialized more rapidly than text-based formats such as XML. Both of these result in performance gains, particularly where large sets of data are involved. Secondly, RemoteObject provides significant productivity advantages. The remoting service, which runs on our server, automatically marshals data between AMF and our server-side language (e.g., PHP, Java, C#). As a result, we can directly call methods on our PHP objects without having to write an XML REST interface or create web service interfaces". There are other ways to pass the data from Flex to a server-side Web application. For example, we can create an instance of the URLVariables object, create the data to be passed as its properties,attach URLVariables to URLRequest.data, and call navigateToURL().

What is Builder design pattern in Java? When do you use Builder pattern ?

Builder pattern in Java is another creational design pattern in Java and often asked in Java interviews because of its specific use when you need to build an object which requires multiple properties some optional and some mandatory. See When to use Builder pattern in Java for more details

What is CORBA ?

Common Object Request Broker Architecture. A language-independent distributed object model specified by the OMG.

What is callback methods ?

Component methods called by the container to notify the component of important events in its life cycle.

How can u access a variable defined in 1 MXML file to another?

Create 1 obj of mxml file into another mxml file.

What is decorator pattern in Java? Can you give an example of Decorator pattern?

Decorator pattern is another popular java design pattern question which is common because of its heavy usage in java.io package. BufferedReader and BufferedWriter are good example of decorator pattern in Java. See How to use Decorator pattern in Java fore more details.

What is DTD ?

Document type definition. An optional part of the XML document prolog, as specified by the XML standard. The DTD specifies constraints on the valid tags and tag sequences that can be in the document. The DTD has a number of shortcomings, however, and this has led to various schema proposals. For example, the DTD entry says that the XML element called username contains parsed character data-that is, text alone, with no other structural elements under it. The DTD includes both the local subset, defined in the current file, and the external subset, which consists of the definitions contained in external DTD files that are referenced in the local subset using a parameter entity.

What is Factory pattern in Java? What is advantage of using static factory method to create object?

Factory pattern in Java is a creation Java design pattern and favorite on many Java interviews.Factory pattern used to create object by providing static factory methods. There are many advantage of providing factory methods e.g. caching immutable objects, easy to introduce new objects etc. See What is Factory pattern in Java and benefits for more details.

Difference between flex and flash?

Flash * specifically designed s/w for designer cos they can create anything without code * provides number of tools for drawing to create graphics * u have to spend countless hours for creating attractive framework for your project or website Flex * more oriented for developers,includes almost every feature of web development * does not provide any tools for designing , but with use of stylesheets,properties or components we can design * flex provides the framework applications which includes in built components to design or develop complex appln and with the use of components can save ur time....

What is HTTP ?

Hypertext Transfer Protocol. The Internet protocol used to retrieve hypertext objects from remote hosts. HTTP messages consist of requests from client to server and responses from server to client.

What is a Thread?

In Java, "thread" means two different things: An instance of class java.lang.Thread. A thread of execution. An instance of Thread is just...an object. Like any other object in Java, it has variables and methods, and lives and dies on the heap. But a thread of execution is an individual process (a "lightweight" process) that has its own call stack. In Java, there is one thread per call stack—or, to think of it in reverse, one call stack per thread. Even if you don't create any new threads in your program, threads are back there running. The main() method, that starts the whole ball rolling, runs in one thread, called (surprisingly) the main thread. If you looked at the main call stack (and you can, any time you get a stack trace from something that happens after main begins, but not within another thread), you'd see that main() is the first method on the stack— the method at the bottom. But as soon as you create a new thread, a new stack materializes and methods called from that thread run in a call stack that's separate from the main() call stack.

Indexed Arrays in flex

Indexed arrays store a series of one or more values organized such that each value can be accessed using an unsigned integer value. The first index is always the number 0, and the index increments by 1 for each subsequent element added to the array. As the following code shows, you can create an indexed array by calling the Array class constructor or by initializing the array with an array literal: // Use Array constructor. var myArray:Array = new Array(); myArray.push("one"); myArray.push("two"); myArray.push("three"); trace(myArray); // output: one,two,three // Use Array literal. var myArray:Array = ["one", "two", "three"]; trace(myArray); // output: one,two,three The Array class also contains properties and methods that allow you to modify indexed arrays. These properties and methods apply almost exclusively to indexed arrays rather than associative arrays. Indexed arrays use an unsigned 32-bit integer for the index number. The maximum size of an indexed array is 232 - 1 or 4,294,967,295. An attempt to create an array that is larger than the maximum size results in a run-time error.

What is IDL ?

Interface Definition Language. A language used to define interfaces to remote CORBA objects. The interfaces are independent of operating systems and programming languages.

Explain Basic Steps in writing a Java program using JDBC?

JDBC makes the interaction with RDBMS simple and intuitive. When a Java application needs to access database : Load the RDBMS specific JDBC driver because this driver actually communicates with the database (Incase of JDBC 4.0 this is automatically loaded). Open the connection to database which is then used to send SQL statements and get results back. Create JDBC Statement object. This object contains SQL query. Execute statement which returns resultset(s). ResultSet contains the tuples of database table as a result of SQL query. Process the result set. Close the connection.

Difference between Java & Flex Getters Setters

Java * never a good idea to make member variable public * java only has explicit getter Flex * Creating public memeber variable is "Safe" * flex can have both implicit & explicit getters

What is the JDBC?

Java Database Connectivity (JDBC) is a standard Java API to interact with relational databases form Java. JDBC has set of classes and interfaces which can use from Java application and talk to database without learning RDBMS details and using Database Specific JDBC Drivers.

What is Open closed design principle in Java?

Open closed design principle is one of the SOLID principle defined by Robert C. Martin, popularly known as Uncle Bob. This principle advices that a code should be open for extension but close for modification. At first this may look conflicting but once you explore power of polymorphism, you will start finding patterns which can provide stability and flexibility of this principle. One of the key example of this is State and Strategy design pattern, where Context class is closed for modification and new functionality is provided by writing new code by implementing new state of strategy. See this article to know more about Open closed principle.

What is Oracle BPM

Oracle Business Process Management, a member of the Oracle Business Process Management Suite, is a complete set of tools for creating, executing, and optimizing business processes. The suite enables unparalleled collaboration between business and IT to automate and optimize business processes

What is Oracle ESB

Oracle Service Bus is a proven, lightweight and scalable SOA integration platform that delivers low-cost, standards-based integration for high-volume, mission critical SOA environments. It is designed to connect, mediate, and manage interactions between heterogeneous services, legacy applications, packaged applications and multiple enterprise service bus (ESB) instances across an enterprise-wide service network. Oracle Service Bus provides built-in management and monitoring capabilities and supports out-of-the-box integration with SOA Governance products. Oracle Service Bus is a core component in the Oracle SOA Suite as a back-bone for SOA messaging. Oracle Service Bus also integrates with Oracle SOA Governance for improved enterprise-wide SOA Governance.

Can you write code to implement producer consumer design pattern in Java?

Producer consumer design pattern is a concurrency design pattern in Java which can be implemented using multiple way. if you are working in Java 5 then its better to use Concurrency util to implement producer consumer pattern instead of plain old wait and notify in Java. Here is a good example of implementing producer consumer problem using BlockingQueue in Java.

The following principles encourage RESTful applications to be simple, lightweight, and fast:

Resource identification through URI: A RESTful web service exposes a set of resources that identify the targets of the interaction with its clients. Resources are identified by URIs, which provide a global addressing space for resource and service discovery. See The @Path Annotation and URI Path Templates for more information. Uniform interface: Resources are manipulated using a fixed set of four create, read, update, delete operations: PUT, GET, POST, and DELETE. PUT creates a new resource, which can be then deleted by using DELETE. GET retrieves the current state of a resource in some representation. POST transfers a new state onto a resource. See Responding to HTTP Methods and Requests for more information. Self-descriptive messages: Resources are decoupled from their representation so that their content can be accessed in a variety of formats, such as HTML, XML, plain text, PDF, JPEG, JSON, and others. Metadata about the resource is available and used, for example, to control caching, detect transmission errors, negotiate the appropriate representation format, and perform authentication or access control. See Responding to HTTP Methods and Requests and Using Entity Providers to Map HTTP Response and Request Entity Bodies for more information. Stateful interactions through hyperlinks: Every interaction with a resource is stateless; that is, request messages are self-contained. Stateful interactions are based on the concept of explicit state transfer. Several techniques exist to exchange state, such as URI rewriting, cookies, and hidden form fields. State can be embedded in response messages to point to valid future states of the interaction. See Using Entity Providers to Map HTTP Response and Request Entity Bodies and "Building URIs" in the JAX-RS Overview document for more information.

How can u implement singleton in flex?

Singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. if u create a class as a singleton , then no way to create more than one instance.

What is EJB server ?

Software that provides services to an EJB container. For example, an EJB container typically relies on a transaction manager that is part of the EJB server to perform the two-phase commit across all the participating resource managers. The J2EE architecture assumes that an EJB container is hosted by an EJB server from the same vendor, so it does not specify the contract between these two entities. An EJB server can host one or more EJB containers.

What is Statement ?

Statement acts like a vehicle through which SQL commands can be sent. Through the connection object we create statement kind of objects. Through the connection object we create statement kind of objects. Statement stmt = conn.createStatement(); This method returns object which implements statement interface.

When to use Strategy Design Pattern in Java?

Strategy pattern in quite useful for implementing set of related algorithms e.g. compression algorithms, filtering strategies etc. Strategy design pattern allows you to create Context classes, which uses Strategy implementation classes for applying business rules. This pattern follow open closed design principle and quite useful in Java. One example of Strategy pattern from JDK itself is a Collections.sort() method and Comparator interface, which is a strategy interface and defines strategy for comparing objects. Because of this pattern, we don't need to modify sort() method (closed for modification) to compare any object, at same time we can implement Comparator interface to define new comparing strategy (open for extension).

Exaplain the JDBC Architecture.

The JDBC Architecture consists of two layers: The JDBC API, which provides the application-to-JDBC Manager connection. The JDBC Driver API, which supports the JDBC Manager-to-Driver Connection. The JDBC API uses a driver manager and database-specific drivers to provide transparent connectivity to heterogeneous databases. The JDBC driver manager ensures that the correct driver is used to access each data source. The driver manager is capable of supporting multiple concurrent drivers connected to multiple heterogeneous databases. The location of the driver manager with respect to the JDBC drivers and the Java application is shown in Figure 1.

What is a tag library

The JavaServer Pages Standard Tag Library (JSTL), is a component of the Java EE Web application development platform. It extends the JSP specification by adding a tag library of JSP tags for common tasks, such as XML data processing, conditional execution, database access, loops and internationalization. JSTL provides an effective way to embed logic within a JSP page without using embedded Java code directly. The use of a standardised tag set, rather than breaking in and out of Java code, leads to more maintainable code and enables separation of concerns between the development of the application code and user interface.

What is the difference between Session bean and Entity bean ?

The Session bean and Entity bean are two main parts of EJB container. Session Bean --represents a workflow on behalf of a client --one-to-one logical mapping to a client. --created and destroyed by a client --not permanent objects --lives its EJB container(generally) does not survive system shut down --two types: stateless and stateful beans Entity Bean --represents persistent data and behavior of this data --can be shared among multiple clients --persists across multiple invocations --findable permanent objects --outlives its EJB container, survives system shutdown --two types: container managed persistence(CMP) and bean managed persistence(BMP)

Suppose you have a logger class that is used to log error and warning messages. How can you implement this class while using the Singleton design pattern?

The Singleton design pattern - when applied to a given class - basically limits the class itself to having just one instance created. So, if we want to implement the Singleton design pattern with a logger class, it means that there can be at most one instance of the logger class. How can we accomplish this? First, let's rephrase that question into something more specific to the problem at hand - how can we control the initialization of a class? Well, through the constructor of course.

What is WSDL

The Web Services Description Language is an XML-based interface description language that is used for describing the functionality offered by a web service. A WSDL description of a web service (also referred to as a WSDL file) provides a machine-readable description of how the service can be called, what parameters it expects, and what data structures it returns. It thus serves a purpose that corresponds roughly to that of a method signature in a programming language.

What is component contract ?

The contract between a J2EE component and its container. The contract includes life-cycle management of the component, a context interface that the instance uses to obtain various information and services from its container, and a list of services that every container must provide for its components.

What is an event class in Flex?

The flash.events.Event class is an ActionScript class with properties that contain information about the event that occurred. An Event object is an implicitly created object, similar to the request and response objects in a JavaServer Page (JSP) that are implicitly created by the application server. Flex creates an Event object each time an event is dispatched. You can use the Event object inside an event listener to access details about the event that was dispatched, or about the component that dispatched the event. Passing an Event object to, and using it in, an event listener is optional. However, if you want to access the Event object's properties inside your event listeners, you must pass the Event object to the listener. Flex creates only one Event object when an event is dispatched. During the bubbling and capturing phases, Flex changes the values on the Event object as it moves up or down the display list, rather than creating a new Event object for each node.

What are the main components of JDBC ?

The life cycle of a servlet consists of the following phases: DriverManager: Manages a list of database drivers. Matches connection requests from the java application with the proper database driver using communication subprotocol. The first driver that recognizes a certain subprotocol under JDBC will be used to establish a database Connection. Driver: The database communications link, handling all communication with the database. Normally, once the driver is loaded, the developer need not call it explicitly. Connection : Interface with all methods for contacting a database.The connection object represents communication context, i.e., all communication with database is through connection object only. Statement : Encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed. ResultSet: The ResultSet represents set of rows retrieved due to query execution.

What is container-managed persistence ?

The mechanism whereby data transfer between an entity bean's variables and a resource manager is managed by the entity bean's container.

What is bean-managed persistence ?

The mechanism whereby data transfer between an entity bean's variables and a resource manager is managed by the entity bean.

What is caller or caller principal ?

The principal that identifies the invoker of the enterprise bean method.

What is authorization ?

The process by which access to a method or resource is determined. Authorization depends on the determination of whether the principal associated with a request through authentication is in a given security role. A security role is a logical grouping of users defined by the person who assembles the application. A deployer maps security roles to security identities. Security identities may be principals or groups in the operational environment.

What is an event sub class?

There are many classes that extend the flash.events.Event class. These classes are defined mostly in the following two packages: * mx.events.* * flash.events.* The mx.events package defines event classes that are specific to Flex controls, including the DataGridEvent, DragEvent, and ColorPickerEvent. The flash.events package describes events that are not unique to Flex but are instead defined by Flash Player. These event classes include MouseEvent, DataEvent, and TextEvent. All of these events are commonly used in Flex applications. In addition to these packages, some packages also define their own event objects: for example, mx.messaging.events.ChannelEvent and mx.logging.LogEvent. Child classes of the Event class have additional properties and methods that may be unique to them. In some cases, you will want to use a more specific event type rather than the generic Event object so that you can access these unique properties or methods. For example, the LogEvent class has a getLevelString() method that the Event class does not.

Can you write thread-safe Singleton in Java?

There are multiple ways to write thread-safe singleton in Java e.g by writing singleton using double checked locking, by using static Singleton instance initialized during class loading. By the way using Java enum to create thread-safe singleton is most simple way. See Why Enum singleton is better in Java for more details.

What are the differences between Ear, Jar and War files? Under what circumstances should we use each one?

There are no structural differences between the files; they are all archived using zip-jar compression. However, they are intended for different purposes. --Jar files (files with a .jar extension) are intended to hold generic libraries of Java classes, resources, auxiliary files, etc. --War files (files with a .war extension) are intended to contain complete Web applications. In this context, a Web application is defined as a single group of files, classes, resources, .jar files that can be packaged and accessed as one servlet context. --Ear files (files with a .ear extension) are intended to contain complete enterprise applications. In this context, an enterprise application is defined as a collection of .jar files, resources, classes, and multiple Web applications. Each type of file (.jar, .war, .ear) is processed uniquely by application servers, servlet containers, EJB containers, etc.

When to use Composite design Pattern in Java? Have you used previously in your project?

This design pattern question is asked on Java interview not just to check familiarity with Composite pattern but also, whether candidate has real life experience or not. Composite pattern is also a core Java design pattern, which allows you to treat both whole and part object to treat in similar way. Client code, which deals with Composite or individual object doesn't differentiate on them, it is possible because Composite class also implement same interface as there individual part. One of the good example of Composite pattern from JDK is JPanel class, which is both Component and Container. When paint() method is called on JPanel, it internally called paint() method of individual components and let them draw themselves. On second part of this design pattern interview question, be truthful, if you have used then say yes, otherwise say that you are familiar with concept and used it by your own. By the way always remember, giving an example from your project creates better impression.

Difference between Strategy and State design Pattern in Java?

This is an interesting Java design pattern interview questions as both Strategy and State pattern has same structure. If you look at UML class diagram for both pattern they look exactly same, but there intent is totally different. State design pattern is used to define and mange state of object, while Strategy pattern is used to define a set of interchangeable algorithm and let's client to choose one of them. So Strategy pattern is a client driven pattern while Object can manage there state itself.

What are the advantages or usage of threads?

Threads support concurrent operations. For example, • Multiple requests by a client on a server can be handled as an individual client thread. • Long computations or high-latency disk and network operations can be handled in the background without disturbing foreground computations or screen updates. Threads often result in simpler programs. • In sequential programming, updating multiple displays normally requires a big while-loop that performs small parts of each display update. Unfortunately, this loop basically simulates an operating system scheduler. In Java, each view can be assigned a thread to provide continuous updates. • Programs that need to respond to user-initiated events can set up service routines to handle the events without having to insert code in the main routine to look for these events. Threads provide a high degree of control. • Imagine launching a complex computation that occasionally takes longer than is satisfactory. A "watchdog" thread can be activated that will "kill" the computation if it becomes costly, perhaps in favor of an alternate, approximate solution. Note that sequential programs must muddy the computation with termination code, whereas, a Java program can use thread control to non-intrusively supervise any operation. Threaded applications exploit parallelism. • A computer with multiple CPUs can literally execute multiple threads on different functional units without having to simulating multi-tasking ("time sharing"). • On some computers, one CPU handles the display while another handles computations or database accesses, thus, providing extremely fast user interface response times.

When to use Adapter pattern in Java? Have you used it before in your project?

Use Adapter pattern when you need to make two class work with incompatible interfaces. Adapter pattern can also be used to encapsulate third party code, so that your application only depends upon Adapter, which can adapt itself when third party code changes or you moved to a different third party library. By the way this Java design pattern question can also be asked by providing actual scenario.

When to use Setter and Constructor Injection in Dependency Injection pattern?

Use Setter injection to provide optional dependencies of an object, while use Constructor injection to provide mandatory dependency of an object, without which it can not work. This question is related to Dependency Injection design pattern and mostly asked in context of Spring framework, which is now become an standard for developing Java application. Since Spring provides IOC container, it also gives you way to specify dependencies either by using setter methods or constructors. You can also take a look my previous post on same topic.

Remote Object in Flex/ActionScript

Using RemoteObject, you can directly invoke methods of Java objects deployed in your application server, and consume the return value. The return value can be a value of a primitive data type, an object, a collection of objects, an object graph, etc. The value of the destination property of RemoteObject is a logical name that is mapped to a fully qualified java class in remoting-config.xml. Java objects returned by server-side methods are deserialized into either dynamic or typed ActionScript objects. Like HTTPService and WebService, RemoteObject calls are asynchronous. You use the result and fault events of the RemoteObject to handle results and errors. In remoting-config.xml file, <destination id="product"> <properties> <source>flex.samples.product.ProductService</source> </properties> </destination>

When jvm starts up, which thread will be started up first?

When jvm starts up the thread executing main method is started.

What are the two ways of creating thread?

here are two ways to create a new thread. 1)Extend the Thread class and override the run() method in your class. Create an instance of the subclass and invoke the start() method on it, which will create a new thread of execution. e.g. public class NewThread extends Thread{ public void run(){ // the code that has to be executed in a separate new thread goes here } public static void main(String [] args){ NewThread c = new NewThread(); c.start(); } 2)Implements the Runnable interface.The class will have to implement the run() method in the Runnable interface. Create an instance of this class. Pass the reference of this instance to the Thread constructor a new thread of execution will be created. e.g. class public class NewThread implements Runnable{ public void run(){ // the code that has to be executed in a separate new thread goes here } public static void main(String [] args){ NewThread c = new NewThread(); Thread t = new Thread(c); t.start(); }


Ensembles d'études connexes

Biology, Cell Division and Reproduction, Q3

View Set

AP Chemistry - AP Classroom Unit 1 Progress Check: MCQ

View Set

PN NCLEX 6th Edition- Leadership/Ethical/Legal

View Set

Anatomy-somatic and special senses

View Set

BIOLOGY - UNIT 7: PLANTS: GREEN FACTORIES QUIZ 1:

View Set

Biology - Evolution Exam (Exam #1)

View Set