Shared Flashcard Set

Details

Java
Senior Java Interview
145
Software
Professional
03/14/2011

Additional Software Flashcards

 


 

Cards

Term
What is Polymorphism?
Definition
overloading and overriding
Term
What is overloading?
Definition
When a subclass re-defines a method it inherits from a superclass
Term
What is overriding?
Definition
Creating a method in a subclass with the same name as one in the super class
Term
Can an overloaded class have a different return type from the method being overloaded?
Definition
Yes
Term
Can an overrided method have a different return type from the class it overrides?
Definition
Only in java 1.5+ and only when using covariant returns
Term
What is a covariant return type?
Definition
a covariant return type means changing a method's return type when overriding it in a subclass.
Covariant return types have been (partially) allowed in the Java language since the release of JDK5.0, so the following example wouldn't compile on a previous release: a situation where the return type of the overriding method is changed to a type related to (but different from) the return type of the original overridden method. The relationship between the two covariant return types is usually one which allows substitution of the one type with the other
Term
What is autoboxing/unboxing?
Definition
Automatically converting primitive variables to their object wrapper and vice versa in java 1.5+. This occurs in cases such as storing primitives in collections (which can only hold references to objects)
Term
Can the access modifier of an overriding class be more restrictive than it's superclass?
Definition
No. Public method in a superclass can only be overriden by a public method, Protected by protected or public, etc.
Term
If a single method is "abstract", the whole class must be declared "abstract"?
Definition
True
Term
In a method with a primitive return type, you can return any value or
variable that can be explicitly cast to the declared return type?
Definition
yes for example
public int foo () {
float f = 32.5f;
return (int) f;
}
Term
All objects in java contain what 3 methods
Definition
wait(), notify(), notifyAll()
Term
What are the two ways to instantiate a thread?
Definition
Extend java.lang.Thread or Implement the Runnable interface.
Term
What are Member Non-Access Modifiers?
Definition
Abstract, Strictfp, Final, Volatile, Native, Transient, Synchronized, Static, Var-args.
Term
Define: Abstract
Definition
Must be implemented by the first concrete class to extend the abstract class it's a member of.
Term
Define: Strictfp
Definition
aheres to IEEE 754 for floating point numbers
Term
Define: Final
Definition
methods cant be overridden, vars are constants
Term
Define: Volatile
Definition
can only be applied to instance variables
Term
Define: Native
Definition
implemented in native code (usually C) and end in ";" just like abstract method.
Term
Define: Transient
Definition
will be skipped during serialization. only applied to instance variables
Term
Define: Synchronized
Definition
Only allows one thread to run it at a time.
Term
Define: Static
Definition
Class variables (available in every instance)
Term
Define: Var-args
Definition
an arg of varying lenght. must be last param in method. can only have one per method.
Term
Can a static variable be overridden?
Definition
No, it can be redefined in a subclass but not overridden.
Term
What are the three pillars of OO Programming?
Definition
Encapsulation
Inheritance
Polymorphism
Term
What is constructor chaining?
Definition
Every constructor invokes the constructor if its superclass with an implicit or explicit call to super()
Term
Does an abstract class have a constructor?
Definition
Abstract classes have constructors, and those constructors are always called when a concrete subclass is instantiated.
Term
What are common characteristics of an inner class?
Definition
A method must instantiate an object of the inner class to use it.
Can only reference outer class variables that are final.
Have the same access modifier as the local variable.
If declared in a static method can only access static members of the outer class.
Term
If two objects are equal, is their hashcode the same also?
Definition
Yes
Term
Can the modifier strictfp modify a variable?
Definition
No, only classes and methods.
Term
What is a label statement
Definition
A statement preceded by a text label and Colon (:)
Used to direct break/continue statements.
Term
Does polymorphism apply to static methods?
Definition
No, static methods cannot be overridden.
Term
Define: Encapsulation
Definition
Encapsulation conceals the functional details of a class from objects that send messages to it. (i.e. getters & setters)
Term
Can a subclass inherit a private member from it's superclass?
Definition
No the member is only accessible inside the declaring method.
Term
What are the non-access modifiers that are applicable to a class?
Definition
final, abstract, and strictfp
Term
Define: MVC
Definition
Model - data and rules that govern access to the data.
View - Renders the contents of the model.
Controller - translates the user's interactions with the view into actions that the model will perform.
Term
Can a constructor be called explicitly by name from another method?
Definition
No, constructors are invoked only by the keyword new, or from another constructor using this() or super()
Term
Define: static
Definition
A method or variable that is not attached to a particular object, but rather to the class as a whole.
Term
What is the purpose of a static import?
Definition
Enables programmers to refer to the imported static members of a class as if they were declared in the class that uses them.
Term
Can a constructor be private?
Definition
Yes, but then only code within the class itself can instantiate an object of that type.
Term
Why use the transient keyword?
Definition
Prevent a member from being serialized.
Term
What modifiers are required for interface constants?
Definition
public static final
Term
Define: UDDI
Definition
Universal Description Discovery and Integration - A platform independent XML registry for web services.
Term
Can access modifiers by applied to local variables?
Definition
NO
Term
Can a class access a default member variable from another class?
Definition
No default access modifier is protected.
Term
Can an abstract class define abstract and non-abstract methods?
Definition
Yes
Term
Can an interface have only abstract methods?
Definition
Yes
Term
Define: varargs
Definition
The varargs, or variable arguments, feature allows a developer to declare that a method can take a variable number of parameters for a given argument. The vararg must be the last argument in the formal argument list.
Term
What can a final class not do?
Definition
Be sub-classed
Term
What must be present as the first call (implicitly or explicitly) in a constructor?
Definition
this() or super()
Term
Define: Interface Inheritance
Definition
Refers to inheriting a set of "signatures" but no associated behavior. Defines method signatures.
Behavior must be implemented in the subclass.
Term
Which allows for multiple inheritance, an interface or an abstract class?
Definition
An interface
Term
When can a class access a protected member of a class in another package?
Definition
When it inherits the member
Term
Define: Interface
Definition
a device or system that unrelated entities use to interact
Term
Define: abstract class
Definition
a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.
Term
Define: abstract method
Definition
a method that is declared without an implementation (without braces, and followed by a semicolon), like this:

abstract void moveTo(double deltaX, double deltaY);
Term
If a class includes abstract methods, the class itself must be declared abstract?
Definition
True
Term
When can a subclass implement only part of an abstract class?
Definition
When the subclass itself if also abstract.
Term
When should an abstract class be declared an interface?
Definition
When an abstract class contains only abstract method declarations
Term
A class that implements an interface must implement all of the interface's methods?
Definition
True, except if the class implementing the interface is declared abstract.
Term
What is different about standard classes and interfaces in terms of extending?
Definition
A standard class can only extend one other class, whereas an interface may extend any number of interfaces.
Term
Methods in an interface are lacking what?
Definition
An implementation (aka method body)
Term
Does Java allow multiple inheritance?
Definition
Technically no a class may only extend from a single class, but interfaces may extend multiple interfaces allowing them to inherit the behavior of multiple classes.
Term
Is an interface or an abstract class generally faster to execute?
Definition
An abstract class, because interfaces require more redirection.
Term
Is it easier to add functionality to an existing interface or abstract class?
Definition
An abstract class, because they allow for default implementations. An interface change would require modifying every class implementing the interface.
Term
Is it easier for an existing class to implement an interface or extend an abstract class?
Definition
Implement an interface because this can generally be added with minimal modification. Whereas extending an abstract class would require rewriting the class.
Term
Define: factory method
Definition
A generic constructor that might produce any of a number of different kinds of objects. You have to implement it as a static method, rather than a constructor.
Term
List Common Creational Patterns
Definition
--- Abstract Factory
--- Builder
--- Factory Method
--- Prototype
--- Singleton
Term
List common Structural Patterns
Definition
--- Adapter
--- Bridge
--- Composite
--- Decorator
--- Façade
--- Flyweight
--- Proxy
Term
List Commond Behavioral Patterns
Definition
--- Chain of Responsibility
--- Command
--- Interpreter
--- Iterator
--- Mediator
--- Memento
--- Observer
--- State
--- Strategy
--- Template Method
--- Visitor
Term
List commond J2EE Patterns
Definition
--- MVC
--- Business Delegate
--- Composite Entity
--- Data Access Object
--- Front Controller
--- Intercepting Filter
--- Service Locator
--- Transfer Object
Term
Define: RESTful WS
Definition
Representational State Transfer (REST) is a Web service design pattern. It is different from SOAP based web services. REST services do not require XML, SOAP or WSDL service-API definitions. Only use url and simple HTTP API (GET,POST,PUT,DELETE).
Term
Define: Axis WS
Definition
Axis is essentially a SOAP engine -- a framework for constructing SOAP processors such as clients, servers, gateways, etc.
Term
Axis isn't just a SOAP engine -- it also includes?
Definition
a simple stand-alone server,
a server which plugs into servlet engines such as Tomcat,
extensive support for the Web Service Description Language (WSDL),
emitter tooling that generates Java classes from WSDL.
some sample programs, and
a tool for monitoring TCP/IP packets.
Term
Define: Abstract Factory (designe Pattern)
Definition
Provides one level of interface higher than the factory pattern. It is used to return one of several factories.
Term
Define: Builder (designe Pattern)
Definition
Construct a complex object from simple objects step by step.
Term
Define: Factory Method (designe Pattern)
Definition
Provides an abstraction or an interface and lets subclass or implementing classes decide which class or method should be instantiated or called, based on the conditions or parameters given.
Term
Define: Prototype (design pattern)
Definition
Cloning an object by reducing the cost of creation.
Term
Define: Singleton (design pattern)
Definition
One instance of a class or one value accessible globally in an application.
Term
Define: Adapter (design pattern)
Definition
Convert the existing interfaces to a new interface to achieve compatibility and reusability of the unrelated classes in one application. Also known as Wrapper pattern.
Term
Define: bridge (design pattern)
Definition
Decouple an abstraction or interface from its implementation so that the two can vary independently.
Term
Define: Composite (design pattern)
Definition
Build a complex object out of elemental objects and itself, like a tree structure.
Term
Define: Decorator (design pattern)
Definition
Attach additional responsibilities or functions to an object dynamically or statically. Also known as Wrapper.
Term
Define: Facade (design pattern)
Definition
Make a complex system simpler by providing a unified or general interface, which is a higher layer to these subsystems.
Term
Define: Flyweight (design pattern)
Definition
Make instances of classes on the fly to improve performance efficiently, like individual characters or icons on the screen.
Term
Define: Proxy (design pattern)
Definition
Use a simple object to represent a complex object or provide a placeholder for another object to control access to it.
Term
Define: Proxy (design pattern)
Definition
Use a simple object to represent a complex object or provide a placeholder for another object to control access to it.
Term
Define: Chain of Responsibility (design pattern)
Definition
Let more than one object handle a request without their knowledge of each other. Pass the request to chained objects until it has been handled.
Term
Define: Command (design pattern)
Definition
Streamlize objects by providing an interface to encapsulate a request and make the interface implemented by subclasses in order to parameterize the clients.
Term
Define: Interpreter (design pattern)
Definition
provide a definition of a macro language or syntax and parsing objects in a program.
Term
Define: Iterator (design pattern)
Definition
Provide a way to move through a list of collection or aggregated objects without knowing its internal representations.
Term
Define: Mediator (design pattern)
Definition
Define an object that encapsulates details and other objects interact with such object. The relationships are loosely decoupled.
Term
Define: Momento (design pattern)
Definition
To record an object internal state without violating encapsulation and reclaim it later without knowledge of the original object.
Term
Define: Observer (design pattern)
Definition
One object changes state, all of its dependents are updated automatically.
Term
Define: State (design pattern)
Definition
An object's behavior change is represented by its member classes, which share the same super class.
Term
Define: Strategy (design pattern)
Definition
Group several algorithms in a single module to provide alternatives. Also known as policy.
Term
Define: Template Method (design pattern)
Definition
Provide an abstract definition for a method or a class and redefine its behavior later or on the fly without changing its structure.
Term
Define: Visitor (design pattern)
Definition
Define a new operation to deal with the classes of the elements without changing their structures.
Term
Define: MVC (design pattern)
Definition
The Model/View/Controller(MVC) is an architecture design pattern. Model means data, View means representation and Controller works on data and representation. MVC focuses on decouple the triad relationships among data, representation and controller.
Term
Define: Business Delegate (design pattern)
Definition
An intermediate class decouples between presentation-tier clients and business services.
Term
Define: Composite Entity (design pattern)
Definition
Use a coarse-grained interface to manage interactions between fine-grained or coarse-grained and dependent objects internally. The Composite Entity is a coarse-grained entity bean. It may be the coarse-grained object or hold a reference to the coarse-grained object. Also known as Aggregate Entity.
Term
Define: Data Access Object (design pattern)
Definition
Adapt a uniform interface to access multiple databases like relational, unrelational, object-oriented, etc.
Term
Define: Front Controller (design pattern)
Definition
Using a single component to process application requests.
Term
Define: Intercepting Filter (design pattern)
Definition
A pluggable component design to intercept incomming requests and outgoing responses, provide common services in a standard manner (independently) without changing core processing code.
Term
Define: Service Locator (design pattern)
Definition
Centralizing distributed service object lookups, providing a centralized point of control, acting as a cache that eliminates redundant lookups.
Term
Define: Transfer Object (design pattern)
Definition
Using a serializable class to act as data carrier, grouping related attributes, forming a composite value and working as a return type from remote business method. Also known as Value object.
Term
Define: JAX Web Service
Definition
a Java programming language API for creating web services. It is part of the Java EE platform from Sun Microsystems. Like the other Java EE APIs, JAX-WS uses annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoints.
Term
What are the three primary types of web services?
Definition
RESTful, AXIS, AXIS2
Term
What is the difference between JAX-RPC and AXIS2 web services?
Definition
Trick question, JAX-RPC is a java SOAP API, not a SOAP engine like AXIS. AXIS (and other SOAP based WS) implement JAX-RPC.
Term
What are some SOAP based Web Service pros and cons?
Definition
Pros:
Langauge, platform, and transport agnostic
Designed to handle distributed computing environments
Is the prevailing standard for web services, and hence has better support from other standards (WSDL, WS-*) and tooling from vendors
Built-in error handling (faults)
Extensibility

Cons:
Conceptually more difficult, more "heavy-weight" than REST
More verbose
Harder to develop, requires tools
Term
What are some REST WS pros and cons?
Definition
Pros:
Language and platform agnostic
Much simpler to develop than SOAP
Small learning curve, less reliance on tools
Concise, no need for additional messaging layer
Closer in design and philosophy to the Web

Cons:
Assumes a point-to-point communication model--not usable for distributed computing environment where message may go through one or more intermediaries
Lack of standards support for security, policy, reliable messaging, etc., so services that have more sophisticated requirements are harder to develop ("roll your own")
Tied to the HTTP transport model
Term
What are the six built-in annotations in J2SE 5?
Definition
@Overrides
@Documented
@Deprecated
@Inherited
@Retention
@Target
Term
Define: @Overrides
Definition
used to indicate that a method declaration in the current class is intended to override a method declaration in its (direct or indirect) superclass.
Term
Define: The foundation of annotations
Definition
Annotations are essentially interfaces preceeded by the @ character.
Term
Define: @Documented
Definition
indicates that the annotation to which this is applied is to be documented by javadoc and similar tools. Note that this annotation is just a hint, and a tool can ignore the annotation if it desires to do so.
Term
Define: @Deprecated
Definition
This annotation provides a hint to the Java compiler to warn users if they use the class, method, or field annotated with this annotation. Typically, programmers are discouraged from using a deprecated method (or class), because either it is dangerous or a better alternative exists.
Term
Define: @Inherited
Definition
The best way to understand this annotation is through an example. Let's say you created your own annotation called Serializable. A developer would use your annotation if his class implemented the Serializable interface. If the developer created any new classes that derived from his original class, then marking those classes as Serializable would make sense. To force that design principal, you decorate your Serializable annotation with the Inherited annotation. Stated more generally, if an annotation A is decorated with the Inherited annotation, then all subclasses of a class decorated by the annotation A will automatically inherit the annotation A as well.
Term
Define: @Retention
Definition
The Retention annotation takes a single parameter that determines the decorated annotation's availability. The values of this parameter are:

RetentionPolicy.SOURCE: The decorated annotation is available at the source code level only

RetentionPolicy.CLASS: The decorated annotation is available in the source code and compiled class file, but is not loaded into the JVM at runtime

RetentionPolicy.RUNTIME: The decorated annotation is available in the source code, the compiled class file, and is also loaded into the JVM at runtime
Term
Define: @Target
Definition
used to indicate the type of program element (such as a class, method, or field) to which the declared annotation is applicable. If the Target annotation is not present on an annotation type declaration, then the declared type may be used on any program element. If the Target annotation is present, then the compiler will enforce the specified usage restriction. Legal values for the Target annotation are contained in the java.lang.annotation.ElementType enumeration. An annotation can be applied to any combination of a class, a method, a field, a package declaration, a constructor, a parameter, a local variable, and another annotation.
Term
What's the difference between MVC1 and MVC2
Definition
MVC1: used JSP pages and the JavaBeans component architecture to implement the MVC architecture for the Web. HTTP requests are sent to a JSP page that implements Controller logic and calls out to the “Model” for data to update the “View.” This approach combines Controller and View functionality within a JSP page and therefore breaks the MVC paradigm. MVC1 is appropriate for simple development and prototyping. It is not, however, recommended for serious development.

MVC2: term invented by Sun to describe an MVC architecture for Web-based applications in which HTTP requests are passed from the client to a “Controller” servlet which updates the “Model” and then invokes the appropriate “View” renderer-for example, JSP technology, which in turn renders the View from the updated Model.
The hallmark of the MVC2 approach is the separation of Controller code from
content. (Implementations of presentation frameworks such as Struts, adhere to the MVC2 approach).
Term
What are the differences between and interface and an abstract class with respect to default implementation?
Definition
An interface cannot provide any code at all, much less default code.

An abstract class can provide complete code, default code, and/or just stubs that have to be overridde
Term
Define: JSON
Definition
JavaScript Object Notation
Term
What is JSON
Definition
ightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects.
Term
What is JSON Used for
Definition
The JSON format is often used for serializing and transmitting structured data over a network connection. Essentially a replacement for XML
Term
Why use JSON over XML?
Definition
It's lighter.
Its faster.
Its typed;string, number, array, boolean (xml is all strings)
Data is in native JS format.
Term
What is the standard JSON format?
Definition
An unordered collection of name/value pairs.
A JSON object begins with a { and ends with }
Each name is followed by : (colon) and the name/value pairs are separated by , (comma)
Term
What does this JSON object consist of?

var myJSONObject = {"bindings": [ {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
{"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
{"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
]
};
Definition
a single member "bindings", which contains
an array containing three objects, each containing
"ircEvent", "method", and "regex" members
Term
How do you convert JSON text into an JSON object?
Definition
use
the eval() function > eval() invokes the JavaScript compiler.
Since JSON is a proper subset of JavaScript, the compiler will
correctly parse the text and produce an object structure.
Term
What is JSON-RPC?
Definition
JSON-RPC is a simple remote procedure call protocol similar to XML-RPC although it uses the lightweight JSON format instead of XML
Term
What is JSON-RPC-Java?
Definition
JSON-RPC-Java is a Java implementation of the JSON-RPC protocol
Term
Why use JSON-RPC-Java?
Definition
It allows you to transparently call server-side Java code from JavaScript with an included lightweight JSON-RPC JavaScript client
It is designed to run in a Servlet container such as Tomcat and can be used with J2EE Application servers to allow calling of plain Java or EJB methods from within a JavaScript DHTML web application
Term
What are some features of JSON-RPC-Java?
Definition
• Dynamically call server-side Java methods from JavaScript DHTML web applications. No Page reloading.
• Asynchronous communications.
• Transparently maps Java objects to JavaScript objects.
• Lightweight protocol similar to XML-RPC although much faster.
• Leverages J2EE security model with session specific exporting of objects.
• Supports Internet Explorer, Mozilla, Firefox, Safari, Opera and Konqueror
Term
Can I run Seam in a J2EE environment?
Definition
Yes, as of Seam 1.1, you can use Seam in any J2EE application server, with one caveat: you will not be able to use EJB 3.0 sessio beans. However, you can use either Hibernate or JPA for persistence, and you can use Seam JavaBean components instead of session beans.
Term
What does SEAM support for the view framework?
Definition
Seam only supports JSF as a view framework at this time. We plan to support other web frameworks in the future. We like JSF because it is a component -based UI framework, which fits really well with Seam's component -based approach to business objects and persistence objects. Seam made a major improvement to JSF by eliminating almost all XML configuration for backing beans --you can now define back beans from POJOs or EJB3 components using simple annotations. We recommend you use Facelets , instead of JSP, with JSF. Facelets provide a powerful templating framework, better appplication performance, and allows us to write much simpler JSF pages. Please see the Seam booking example application for an example on how to use Facelets.
Term
How does Seam support Ajax?
Definition
Yes, Seam provides excellent support for AJAX. First, Seam supports the ICEfaces and Ajax4JSF Ajax component libraries for JSF. If you prefer a more "old fashioned" approach, Seam provides a complete JavaScript remoting framework which lets you call Seam components and subscribe to JMS topics directly from the client.
Seam's concurrency model is designed especially for use with Ajax.
Term
Can I unit test Seam applications without starting the Application Server?
Definition
Yes, Seam provides its own integration test framework based on TestNG. You can easily mock all Seam services using those facilities without ever loading an application server or a database.
Term
: What's so special about Seam's "state management"?
Definition
Most other web frameworks store all application state in the HTTP session. Seam can manage business and persistence components in several stateful scopes: conversation scope (pages); session scope; business process scope (multiple users, persisted even after app restart).
Term
Does Seam support multiple browser windows or tabs?
Definition
Yes it supports fine-grained user state managemen.
Each browser window / tab can have independent history and context.
Multiple user "conversations" can be supported.
Term
Can Seam handle back-button navigation ?
Definition
Seam's nested conversation model makes it really easy to build complex, stateful applications that tolerate use of the back button.
Term
Does Seam support REST style bookmarkable URLs ?
Definition
Yes, it is very easy to expose REST style bookmarkable URLs in a Seam application. In addition, the Seam application can initialize all the necessary backend business logic and persistence components when the user loads that URL. This way, the RESTful URL is not only an information endpoint but also an application interaction start point.
Term
Seam conversations are propagated through JSF POST request. Can I do redirect-after-post or even GET in the same conversation ?
Definition
Yes, on both accounts! To use redirect -after-post, you just need to enable theSeamRedirectFilter inweb.xml. To propagate a conversation through a GET request, pass the conversation id in a request parameter named conversationId. By default, GET (non-faces) requests always occur in a new conversation.
Term
Can I use Seam in a portal? A: Seam 1.0 features full integration
Definition
Seam 1.0 features full integration with JSR-168 compliant portals.
Term
Does Seam have continuations?
Definition
jBPM "wait state" is a continuation. Each node in a pageflow definition or node in a business process definition is a jBPM wait state. Speaking more approximately, you might like to think of the conversation state as a continuation. (We do not usually talk in this kind of language because it is too mysterious-sounding and obfuscates simple concepts to make them seem more impressive.)
Term
Can I use Seam in a portal? A: Seam 1.0 features full integration
Definition
Seam 1.0 features full integration with JSR-168 compliant portals.
Term
Does Seam have continuations?
Definition
jBPM "wait state" is a continuation. Each node in a pageflow definition or node in a business process definition is a jBPM wait state. Speaking more approximately, you might like to think of the conversation state as a continuation. (We do not usually talk in this kind of language because it is too mysterious-sounding and obfuscates simple concepts to make them seem more impressive.)
Term
What jdk is required for SEAM, why?
Definition
Jdk 1.5+, because Seam uses annotations.
Supporting users have an ad free experience!