Java based web services interview questions pdf download
Give an example. Ans: In java, a constant is declared using the keyword Final. When a method is declared as final,it can NOT be overridden by the subclasses. This method are faster than any other method,because they are resolved at complied time. When a class is declares as final,it cannot be subclassed. Example String,Integer and other wrapper classes.
Ans: Ternary operator , also called conditional operator is used to decide which value to assign to a variable based on a Boolean value evaluation. What is default switch case? Give example. Ans: In a switch statement , default case is executed when no other switch condition matches.
Default case is an optional case. It can be declared only once all other switch cases have been coded. Ans: In Java, package is a collection of classes and interfaces which are bundled together as they are related to each other. Use of packages helps developers to modularize the code and group the code for proper re-use.
Once code has been packaged in Packages, it can be imported in other classes and used. However, if a class has even one abstract method, it must be declared as abstract otherwise it will give an error. Ans: The primary difference between an abstract class and interface is that an interface can only possess declaration of public static methods with no concrete implementation while an abstract class can have members with any access specifiers public, private etc with or without concrete implementation.
A class can implement multiple interfaces but it can extend only one abstract class. What are the performance implications of Interfaces over abstract classes? Ans: Interfaces are slower in performance as compared to abstract classes as extra indirections are required for interfaces. Another key factor for developers to take into consideration is that any class can extend only one abstract class while a class can implement many interfaces. Use of interfaces also puts an extra burden on the developers as any time an interface is implemented in a class; developer is forced to implement each and every method of interface.
For example, if a developer imports a package university. To load the classes from its sub-package say department , developer has to import it explicitly as follows:. Ans: In java, main method must be public static in order to run any application correctly. How can we pass argument to a function by reference instead of pass by value? Ans: In java, to convert an object into byte stream by serialization, an interface with the name Serializable is implemented by the class.
All objects of a class implementing serializable interface get serialized and their state is saved in byte stream. Ans: Serialization is used when data needs to be transmitted over the network. The byte stream is transferred over the network and the object is re-created at destination.
Ans: Try block needs to be followed by either Catch block or Finally block or both. Any exception thrown from try block needs to be either caught in the catch block or else any specific tasks to be performed before code abortion are put in the Finally block.
Is there any way to skip Finally block of exception even if some exception occurs in the exception block? Ans: If an exception is raised in Try block, control passes to catch block if it exists otherwise to finally block. Finally block is always executed when an exception occurs and the only way to avoid execution of any statements in Finally block is by aborting the code forcibly by writing following line of code at the end of try block:.
For example, in the following class two objects are created using new keyword and hence, constructor is invoked two times. Ans: Yes, a class can have multiple constructors with different parameters.
Which constructor gets used for object creation depends on the arguments passed while creating the objects. Can we override static methods of a class? Ans: We cannot override static methods. Static methods belong to a class and not to individual objects and are resolved at the time of compilation not at runtime. Even if we try to override static method,we will not get an complitaion error,nor the impact of overriding when running the code.
It is the discovery layer in the web services protocol stack. This service verifies entities that attempt to access a web service. For Example, the authentication service, the Entitlements Service ensures security in business operations. As its name implies, it deals with security and confidentiality. This service encrypts data to ensure that only concerned parties can access the data.
SOA is a design and architecture to implement other services. While Web service, itself is an implemented technology. In fact one can implement SOA using the web service. We can develop SOAP based web service with two different types of approaches such as contract-first and contract-last. In the first approach, the contract is defined first and then the classes are derived from the contract while in the later one, the classes are defined first and then the contract is derived from these classes.
In my point of view, the first approach that is the contract-first approach is more feasible as compared to the second one but still it depends on other factors too. You can access web service from any application that supports XML based object request and response.
NET and Java 6. JavaScript XmlHttpRequest object is required to access web service via browsers. All you need to do is to write open table which is basically an XML schema that point to a web service. It provides three different communication channels to clients. Client can choose any communication method as per requirements.
Web services are contemplated as self-documenting because they provide entire information regarding the available methods and parameters used for XML based standard, known as WSDL.
One can also provide more information to explain web services via their own WebService and WebMethod attributes. NET web services are used when one need to implement three tier architecture in a web service. Ashraf says:. March 5, at pm. February 29, at am. Shraddha says:. February 6, at pm. Mani says:. January 21, at pm. January 31, at pm. Govind Kumar says:. November 30, at am. Saritha says:. November 23, at am. Madooooo says:. October 28, at am. Bhumi Meher says:. January 11, at am. Suchi says:.
October 4, at pm. August 1, at am. Asha Madgundi says:. June 13, at am. May 21, at pm. Pankaj says:. March 1, at pm. Manjunath says:. May 5, at am. Ravi says:. April 17, at am. Irfan khan says:. April 10, at am. April 8, at am. Ali Raza says:. December 31, at pm. Vivek Vishwakarma says:. February 23, at pm. January 28, at pm. Usha says:. January 27, at pm. Priya says:. January 26, at pm. Manish Jain says:. January 10, at am. Suraj kumar says:. December 2, at am. Sujeet Kumar Prajapati says:.
November 2, at am. November 2, at pm. Gopal Jain says:. June 11, at am. June 5, at pm. May 30, at am. Answer: Java supports primitive types such as int, byte, short, long, etc that why it is not said to be a pure object-oriented language. What are the access modifiers? Answer: Java provides three access controls such as public, private and protected access modifier. Can we overload the main method?
Answer: Yes, we can overload the main method with syntax as public static void main String args[]. What is the method in java? Answer: It contains the executable body that can be applied to the specific object of the class. The method includes method name, parameters or arguments and return type and a body of executable code. Separate with commas when we have multiple arguments. Can we use catch statement for checked exceptions? This raises a compile-time error if we try to handle checked exceptions when there is no possibility of causing an exception.
Explain a situation where finally block will not be executed? Answer: Finally, the block will not be executed whenever JVM shutdowns. If we use system. Explain about the main method in java? Answer: The main method is the starting point of execution for all java applications. Every Java application must have at least one main method.
What is constructor in java? Answer: A constructor is a special method used to initialize objects in the java. As and when an object is created it is initialized automatically with the help of constructor in java. We have two types of constructors Default Constructor Parameterized Constructor. How can we find the actual size of an object on the heap? Answer: In Java, there is no way to find out the actual size of an object on the heap. In how many ways we can do synchronization in java?
Answer: There are two ways to do synchronization in java: 1 Synchronized methods 2 Synchronized blocks To do synchronization we use the synchronized keyword.
Explain about Automatic type conversion in java? Answer: Java automatic type conversion is done if the following conditions are met: 1 When two types are compatible Ex: int, float int can be assigned directly to float variable. Ex: int, long. Int can be assigned directly to long.
Automatic type conversion takes place if int is assigned to long because long is larger datatype than int. Widening Conversion comes under Automatic type conversion.
In how many ways we can do exception handling in java? Answer: We can handle exceptions in either of the two ways : 1 By specifying a try-catch block where we can catch the exception. Extensibility 3. Machine processable descriptions. Q2 What is the difference between SOA and a web service?
SOA is a system-level architectural style that tries to expose business. WOA is an interface-level architectural style that focuses on the means by which these service capabilities are exposed to consumers. It makes reading and writing of XML via Java relatively easy. Yes, we can send different formats such as PDF document, image or other binary file with soap messages as an attachment.
Messages send using the binary data. Message information
0コメント