Question 1
Question
What is a principal?
Question 2
Question 3
Question
What annotations can be used to specify security privileges?
Question 4
Question
What is the difference between container-managed and application-managed security?
What are the pros and cons of each? When might you choose to use one in preference to the other?
Answer
-
Pros and cons of application-managed security
Pro: complete control
Pro: can fine-tune for performance
Con: you might forget to put it in a method
Con: managing site-wide may be a problem
-
Pros and cons of application-managed security
Question 5
Question
What is a native query?
Question 6
Question
Why is using a named query often more efficient than a JPQL query?
Answer
-
Using named queries may improve code organisation by separating the JPQL query strings from the Java code. It also enforces the use of query parameters rather than embedding literals dynamically into the query string and results in more efficient queries.
-
Using named queries may improve code organisation
Question 7
Question
Why is using a named query often more efficient than a JPQL query?
Question 8
Question
What is the JPA implementation that we use called? What other implementations are there?
Answer
-
Hibernate,
Toplink, we use this for JPA implementation in our coursework
OpenJPA
-
Toplink, we use this for JPA implementation in our coursework
Question 9
Question
What are the pros and cons of using JPQL queries and criteria queries?
Answer
-
JPQL queries are defined as strings, similarly to SQL. JPA criteria queries, on the other hand, are defined by instantiation of Java objects that represent query elements.
Advantage of using the criteria API is that errors can be detected earlier, during compilation rather than at runtime. On the other hand, for many developers string based JPQL queries, which are very similar to SQL queries, are easier to use and understand.
For simple static queries - string based JPQL queries may be preferred.
For dynamic queries that are built at runtime - the criteria API may be preferred. It is cleaner when using the JPA criteria API, because it eliminates the need for building the query using many string concatenation operations.
-
need for building the query using many string concatenation operations.
Question 10
Question
What is a native query?
Question 11
Question
What is the difference between optimistic and pessimistic transaction locking? Which do we normally use?
Question 12
Question
What is the relationship between a persistence unit and an entity manager?
Answer
-
A persistence unit defines a set of all entity classes that are managed by EntityManager
While The EntityManager is the primary interface used by application developers to interact with the JPA runtime
-
A persistence unit defines a set of all entity classes that are managed by EntityManager
Question 13
Question
What is a persistence unit and where are its details usually to be found?
Answer
-
A persistence-unit provides a convenient way of specifying a set of metadata files, and classes, and jars that contain all classes to be persisted in a grouping.
To define a persistence-unit you first need to add a file persistence.xml to the META-INF/ directory of your application jar.
http://www.datanucleus.org/products/datanucleus/jpa/emf.html#persistenceunit
-
A persistence-unit provides a convenient way of specifying a set of metadata files, and classes, and jars that contain all classes to be persisted in a grouping.
Question 14
Question
What is a data access object used for?
Question 15
Question
What is a named query and what is it useful for?
Question 16
Question
What major effort does JPQL save in comparison with SQL?
Answer
-
The main difference between JPQL and SQL lies in that the former deals with JPA entities, while the latter deals directly with relational data. As a Java developer, you also maybe interested to learn that using JPQL, unlike SQL/JDBC, eliminates the need for you to use JDBC API from your Java code—the container does all this work for you behind the scenes.
-
The main
Question 17
Answer
-
The Java Persistence Query Language (JPQL) is a platform-independent object-oriented query language defined as part of the Java Persistence API (JPA) specification. JPQL is used to make queries against entities stored in a relational database.
-
The Java Persistence Query Language (
Question 18
Question
Why is JPQL useful?
Question 19
Question
What do we mean when we say that an entity is detached?
Answer
-
A detached entity is an entity which state must not be reflected by the JPA provider.
In other words, if you change its state (i.e. through setters methods) these changes will not be saved to the underlying database, as the JPA provider doesn't have to "observe" such entities.
-
A detached entity is an entity which state must not be reflected by the JPA provider.
Question 20
Question
How do you obtain an entitymanager when operating in each environment
Answer
-
A container-managed entity manager is obtained in an application through dependency injection or through JNDI lookup. A container-managed entity
manager requires the use of a JTA transaction. An Application managed entity manager is retrieved through the EntityManagerFactory API.
-
A container-managed entity manager is obtained in an application through dependency injection or through JNDI lookup
Question 21
Question
What is an entity manager?
Question 22
Question
Which relationships are by default eager, and which are by default lazy?
Question 23
Question
What strategies are available for mapping inheritance relationships in JPA?we have
Question 24
Question
What do the terms eager and lazy mean in this context?
Answer
-
It gives a hint to the persistence provider runtime that data should be fetched lazily (only when the application asks for the property) or eagerly (when the entity is initially loaded by the provider).
-
the entity is initially loaded by the provider).
Question 25
Question
How do you tell JPA where to store the data that makes up a foreign key? [Be careful!]
Answer
-
@OneToOne @JoinColumn(name="parent_id", referencedColumnName="ID") private Parent parent; }
-
(name="parent_id", referencedColumnName="ID") private Parent parent; }
Question 26
Question
Explain what an HTTP request is
Question 27
Question
How does an HTTP request travel over a network?
Question 28
Question
Explain what an HTTP response is and its relationship to a request
Question 29
Question
Explain what HTTP status codes such as 200 and 404 mean
Answer
-
404 code is the status code from the server to the client indicating the resource not found. 200 it is the code from server to client indicating that the request is received successful
-
request is received successful
Question 30
Question
What is a mime type and what is its relationship to HTTP messages?
Answer
-
Multipurpose Internet Mail Extension. The relation between the HTTP and MIME type is MIMIE type is part of HTTP header response
-
The relation between the HTTP and MIME type is MIMIE type is part of HTTP header response
Question 31
Question
Why in the WWW might there be more HTTP requests than HTTP responses?
Question 32
Question
What is the difference between a static web page and a dynamic one?
Answer
-
Developers generally create static pages with HTML, but use languages like PHP, Javascript, or Actionscript to create dynamic pages. They can also use frameworks like Ruby on Rails, Django, or Flex for dynamic pages. Dynamic languages and frameworks also have the technical capacity to create static Web page content. However, doing so creates source code that is unnecessarily complex for its purpose while being more difficult to maintain
-
html
Question 33
Question
How does the content of a dynamic web page get created?
Question 34
Question
What are the four architectures for dynamic web applications?
Question 35
Question
Why is the architecture that Java uses the most scalable?
Question 36
Question
Why is the architecture that Java uses the most resilient?
Question 37
Question
How can you use Java's architecture to provide an enterprise web application on a global scale
Question 38
Question
What is a servlet?
Question 39
Question 40
Question
What is the relationship between a JSP and a servlet?
Question 41
Question
What advantages does Java's servlet programming model have over (a) CGI? (b) PHP?
Answer
-
threading and at each time CGI has to run a program which is not good practice for OS. The problem of php is in case the module is crashed than the web server is also down
-
The problem of php is in case the module is crashed than the web server is also down
Question 42
Question
What is an exception and what is one used for?
Answer
-
it is used to reporting the error.( exception is an event which occur during the execution of a program, that disrupts the normal flow of the program instructions.
-
( exception is an event which occur during the execution of a program, that disrupts the normal flow of the program instructions.
Question 43
Question
Explain throwing and catching exceptions?
Question 44
Question
What do we mean when we say that one class inherits from another?
Question 45
Question
If an application had classes Person, StaffMember and Student, how might they be related?
Question 46
Question
java.util and jim.sums.entities are examples of what?
Question 47
Question
What is the difference between a field that is private, protected or public?
Question 48
Question
What does static mean when associated with a class's fields or methods? it is a variable which is not changed wherever it called or used
Question 49
Question
Explain what the classes/interfaces Collection, Set, List, ArrayList and Vector represent and what are the distinctions between them?
Question 50
Question 51
Question
What does the declaration Map<String, Person> represent?
Question 52
Question
What is a facelet?
Question 53
Question
What is a managed bean?
Question 54
Question
What is meant by the scope of a managed bean?
Question 55
Question
What are the available scopes to choose from?
Question 56
Question
Which scope is the default?
Question 57
Question
Give at least 10 examples of how different HTML controls can be represented using facelet tags
Answer
-
h:inputText , h:inputHidden, h:inputSecret, h:inputTextarea, h:link, h:commandButton, h:button, h:form, h:panelGrid , h:dataTable
-
h:inputText
Question 58
Question
What do the properties of a managed bean represent?
Question 59
Question
What notation is used in a facelet to associate a property or method with a control?
Question 60
Question
Why is JSF superior to JSP?
Question 61
Question
What are the 3 types of session bean?
Question 62
Question
In what circumstances would you use each of the 3 types?
Answer
-
stateful: The bean needs to hold information about the client across method invocations.
stateless:- The bean’s state has no data for a specific client.
Singleton:-State needs to be shared across the application.
-
Singleton:-State needs to be shared across the application.
Question 63
Question
Which of the 3 types is most commonly used?
Question 64
Question
What is the difference between a session bean and a message bean?
Question 65
Question
What is dependency injection?
Question 66
Question
Who or what does the injecting?
Question 67
Question
What annotation is normally used for dependency injection?
Question 68
Question
How would you specify the start and end of a transaction in a stateful EJB? BY using
Answer
-
@REMOVE annotation
-
@REMOVE annotationl
Question 69
Question
What annotations can be used to control what happens when an EJB is created or destroyed? @PreDestroy @PostConstruct
Question 70
Question
What is the timer service used for?
Answer
-
Enables you to schedule timed notifications for all types of enterprise beans except for stateful session beans. You can schedule a timed notification to occur according to a calendar schedule, at a specific time, after a duration of time, or at timed. How to use it? intervals.timerService.createSingleActionTimer(duration, new TimerConfig());
-
TimerConfig());
Question 71
Question
What is the difference between a local interface, a remote interface and a no-interface view?
Answer
-
When EJB does not explicitly specify as interface type it is assume to be local otherwise it is remote. @localBean @remoteBean No -Interface :Is almost same as local client view, but there are differences. Your bean class is not required to implement client view interfaces in this case. All public methods of the bean class are automatically exposed to the caller. no-interface view always acquires an EJB reference
-
l
Question 72
Question
What do we mean by pooling beans?
Question 73
Question
What is an entity bean?
Question 74
Question
How do you make a bean an entity bean?
Question 75
Question
What does the @Id annotation do?
Question 76
Question
What annotation is used to denote a composite primary key?
Question 77
Question
Under what particular circumstances would you have to use the @Column and/or @Table annotations?
Question 78
Question
Explain what is meant by a unidirectional relationship and a bidirectional relationship?
Answer
-
In a unidirectional relationship, only one entity has a relationship field or property that refers to the other. For example, LineItem would have a relationship field that identifies Product, but Product would not have a relationship field or property for LineItem. In other words,LineItem knows about Product, but Product doesn’t know which LineItem instances refer to it.
while in a bidirectional relationship, each entity has a relationship field or property that refers to the other entity. Through the relationship field or property, an entity class’s code can access its related object. If an entity has a related field, the entity is said to “know” about its related object. For example, if Order knows what LineItem instances it has and if LineItem knows what Order it belongs to, they have a bidirectional relationship.
-
relationship,
Question 79
Question
What are the annotations used to specify the chosen inheritance strategy? Where must those annotations be placed?
Question 80
Question
How do you get JPA to arrange your lists in the right order?