100000380
Points
Questions
185
Answers
186
-
To make a class immutable below mentioned steps should be followed:
1. Don’t provide “setter” methods — methods that modify fields or objects referred to by fields.
2. Make all fields final and private.
3. Don’t allow subclasses to override methods. The simplest way to do this is to declare the class as final. A more sophisticated approach is to make the constructor private and construct instances in factory methods.
4. If the instance fields include references to mutable objects, don’t allow those objects to be changed:-
– Don’t provide methods that modify the mutable objects.
– Don’t share references to the mutable objects. Never store references to external, mutable objects passed to the constructor; if necessary, create copies, and store references to the copies. Similarly, create copies of your internal mutable objects when necessary to avoid returning the originals in your methods.public final class Person { private final String name; private final Integer age; public Person(final String name, final Integer age) { super(); this.name = name; this.age = age; } public Integer getAge() { return age; } public String getName() { return name; } }
This answer accepted by JavaNinja. on 18th September 2018 Earned 15 points.
- 1197 views
- 1 answers
- 0 votes
-
In Collections, List is an ordered sequence of elements whereas Set is a distinct list of elements which is unordered.
List is an ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.
Set is a collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction.
........ List<Integer> list = new ArrayList<Integer>(); list.add(1); list.add(2); list.add(3); list.add(1); for (Integer i : list){ System.out.println(i); }
Output will be…..
1
2
3
1Set<Integer> set = new HashSet<Integer>(); set.add(1); set.add(2); set.add(3); set.add(1); set.add(2); set.add(5); for (Integer i : set){ System.out.println(i); }
Output will be …..
3
2
1
5This answer accepted by JavaNinja. on 18th September 2018 Earned 15 points.
- 1360 views
- 1 answers
- 0 votes
-
The top-down and bottom-up web services differ in the way they are created.
When a web service is created using top-down approach, the WSDL file is created first. The Java skeleton classes and interfaces are generated from the WSDL file using tools. Then the web service is implemented in Java.When a web service is created using bottom-up approach, the web service is defined in the Java class. The WSDL file is generated from the Java class.
The top-down approach is recommended way of creating web service, but the bottom-up approach is faster and easier.This answer accepted by JavaNinja. on 18th September 2018 Earned 15 points.
- 1495 views
- 1 answers
- 0 votes
-
Web Services support 4 types of operations:
a) one-way – client sends the request to the service and no response is expected
b) request response – client sends the request to the service and expects a response back
c) solicit response – the service sends a request to the client and expects a response back
d) notification – the service sends a request to the client and no response is expected
request response is the most commonly used operation for web services.
This answer accepted by JavaNinja. on 18th September 2018 Earned 15 points.
- 1313 views
- 1 answers
- 0 votes
-
Service-oriented architecture (SOA) is a software design and software architecture design pattern based on discrete pieces of software providing application functionality as services to other applications. It is independent of any vendor, product or technology. As per SOA principles a service is a self-contained unit of functionality, for e.g. getting a quotation for a stock. Services can be combined by software applications to provide complete functionality of a software application.
This answer accepted by JavaNinja. on 18th September 2018 Earned 15 points.
- 1281 views
- 1 answers
- 0 votes
-
The main differences between REST and SOAP style Web Services are:
a) REST assumes point to point communication model and is not usable for scenarios where clients go through several intermediaries. SOAP is designed to handle distributed computing environments.
b) REST requires minimal tooling/middleware, only HTTP support is required. SOAP requires significant tooling/middleware support.
c) REST does not enforce any constraint on payload. SOAP services must use SOAP formats for payload.
d) REST is tied to HTTP protocol, SOAP services are protocol agnostic and can use various transport protocol like HTTP, SMTP.
e) SOAP services support a large number of supporting standards for security, reliability, transactions etc.
f) REST is more lightweight and can be implemented using any tool leading to lower learning curve.
g) REST uses URL based access, whereas SOAP uses message based access.
This answer accepted by JavaNinja. on 18th September 2018 Earned 15 points.
- 1380 views
- 1 answers
- 0 votes
-
RESTful Web Services should be used when we need integration over the web. JAX-RS is the Java API for creating RESTful web services. It makes it easier to write web applications that are loosely coupled and have architectural simplicity.
SOAP web Services are more applicable in Enterprise Application Integration scenarios which have advanced QoS requirements. JAX-WS is the latest Java API used for creating SOAP based web services. It makes it easier to support WS-* set of protocols which provide standards for security, reliability and interoperate with other WS-* conforming clients and servers.
This answer accepted by JavaNinja. on 18th September 2018 Earned 15 points.
- 1459 views
- 1 answers
- 0 votes
-
RESTful web services are loosely coupled, lightweight web services that are particularly well suited for creating APIs for clients spread out across the internet. REpresentational State Transfer (REST) is an architectural style of client-server application centered around the transfer of representations of resources through requests and responses.
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 represented by documents and are acted upon by using a set of simple, well-defined operations.
This answer accepted by JavaNinja. on 18th September 2018 Earned 15 points.
- 1306 views
- 1 answers
- 0 votes
-
RMI can be used to write distributed programs in Java. Clients, remote interfaces and servers are written completely in Java and there is no need to learn a separate interface definition language.
IIOP is CORBA’s communication protocol that defines the way bits are sent over a wire between CORBA clients and servers. Interfaces to remote objects are described in a platform-neutral interface definition language (IDL). Mappings from IDL to specific programming languages are implemented, binding the language to CORBA/IIOP.
RMI/IIOP places some restrictions on RMI which enables RMI server objects to use the IIOP protocol and communicate with CORBA client objects written in any language. Thus RMI-IIOP combines RMI ease of use with CORBA cross language interoperability. The entire coding is done in Java language and rmic compiler is used to generate the code necessary for connecting the application via IIOP protocol to others written in any other CORBA compliant language.
This answer accepted by JavaNinja. on 18th September 2018 Earned 15 points.
- 1416 views
- 1 answers
- 0 votes
-
The WSDL port (represented by portType tag) is the most important element of WSDL. It defines the web service, the operations that can be performed and the messages that are involved. It is similar to a function library in a traditional programming language.
This answer accepted by JavaNinja. on 18th September 2018 Earned 15 points.
- 1428 views
- 1 answers
- 0 votes