Showing posts with label FAQ's. Show all posts
Showing posts with label FAQ's. Show all posts

Most Important Web Services Interview Questions and Answers

What is a Web Service?
A web service is a network accessible interface to application programs, built using standard Internet technologies.Clients of web services do NOT need to know how it is implemented.


What are the benefits of the Web Services ?
Web services use this special architecture because it:

  • Can be used from any platform.
  • Uses a standard, well-know channel.
  • Is routable and will pass through most firewalls.
  • Uses the same security mechanisms as any web site.
What is SOAP?
SOAP is a Lightweight messaging framework based on XML and its supports simple messaging and RPC.

  • SOAP consists of
    • Envelope construct: defines the overall structure of messages
    • Encoding rules: define the serialization of application data types
    • SOAP RPC: defines representation of remote procedure calls and responses
    • Binding framework: binding to protocols such as HTTP, SMTP
    • Fault handling
  • Soap supports advanced message processing:
    • forwarding intermediaries: route messages based on the semantics of message
    • active intermediaries: do additional processing before forwarding messages, may modify message
What Contains SOAP Message ?
SOAP messages consist of
Envelope: top element of XML message (required)
Header: general information on message such as security (optional)
Body: data exchanged (required)

What is Fault element in SOAP ?
Fault element Carries an error message and If present, must appear as a child of <Body>. It must only appear once. Fault element contains the following sub-elements:
<faultcode> : A code for identifying the fault (VersionMismatch, MustUnderstand, Client, Server)
<faultstring> : A human readable explanation of the fault
<faultactor> : Information about who caused the fault to happen
<detail> : Holds application specific error information related to the Body element

What are the Binding Protocols supports in SOAP ?
HTTP & SMTP


What is Static stub client ?
stubs are created before runtime (by wscompile), it is usually called a static stub. .It makes this call through a stub, a local object which acts as a proxy for the remote service.

What isDynamic Proxy client ?
This client creates a Service object which is factory of proxies(stubs are created at runtime dynamically)

What is Web Client ?
This client used .jsp pages to display web form for the user to enter zipcode to get weather forecast by calling getWeatherReport  function on the stubs created before.  


What is WS-Security ?
WS-Security provides soap message protection through message integrity, confidentiality, and single message authentication
extensible and flexible  (multiple security tokens, trust domains, signature formats, and encryption technologies.). A flexible set of mechanisms that can be used to construct a range of security protocols

What is WS - Policy ?

Describes the capabilities and constraints of the security and business policies on intermediaries and endpoints.

What is WS - Trust ?
Framework for trust models that enables web services to interoperate securely.

What is WS-Privacy ?
Model for how web services and requesters state privacy
preferences and organizational privacy practice statements

Explain WS-SecureConversation ?
Manage and authenticate message exchanges between parties, including security context exchange and establishing and deriving
session keys

How to Secure a Web Service?

  • Integrity - information is not modified in transit
    • XML signature in conjunction with security tokens
    • Multiple signature, multiple actors, additional signature formats
  • Confidentiality - only authorized actors or security token owners can view the data
    • XML encryption in conjunction with security tokens
    • Multiple encryption processes, multiple actors
  • Authentication
Explain WSDL ?
WSDL stands for Web Service Description Lanaguage. WSDL is a standard method of describing web services and their specific capabilities (XML). 
WSDL Definition: WSDL is an XML-based language through which a web service conveys to applications the methods that the service provides and how those methods are accessed.

What are elements conatins in WSDL file?
WSDL file contains following elements 
  • <definitions> are root node of WSDL
  • <import> allows other entities for inclusion
  • <types> are data definitions - xsd
  • <message> defines parameters of a Web Service function
  • <portType> defines input and output operations
  • <binding> specifies how each message is sent over the wire
What is UDDI ?
UDDI stands for Universal Description, Discovery, and Integration.UDDI defines XML-based rules for building directories in which companies advertise themselves and their web services

What is "wscompile" ?
The wscompile tool generates stubs, ties,      serializers, and WSDL files used in JAX-RPC clients and services. The tool reads as input a configuration file and either a WSDL file or an RMI interface that defines the service.


What is "wsdeploy" ?
It reads a WAR file (something like Jar file) and the jaxrpc-ri.xml  file and then generates another WAR file that is ready for deployment.

Recently Asked Java Interview Questions and Answers for 1+ Years

How could Java classes direct program messages to the system console, but error messages, say to a file?
The class System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default, they both point at the system console. This how the standard output could be re-directed:
Stream st =  new Stream (new FileOutputStream ("techinterviews_com.txt"));
System.setErr(st);
System.setOut(st); 

What’s the difference between an interface and an abstract class?
An abstract class may contain code in method bodies, which is not allowed  in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.

Why would you use a synchronized block vs. synchronized method?
Synchronized blocks place locks for shorter periods than synchronized methods.

Explain the usage of the keyword transient?
This keyword indicates that the value of this member variable does not have to be serialized with the object. When the class will be de-serialized, this variable will be initialized with a default value of its data type (i.e. zero for integers).

How can you force garbage collection?
You can’t force GC, but could request it by calling System.gc(). JVM does not guarantee that GC will be started immediately.

How do you know if an explicit object casting is needed?
If you assign a superclass object to a variable of a subclass’s data type, you need to do explicit casting. For example:
Object a;Customer b; b = (Customer) a;
When you assign a subclass to a variable having a supeclass type, the casting is performed automatically.

What’s the difference between the methods sleep() and wait() ?
The code sleep(1000); puts thread aside for exactly one second. The code wait(1000), causes a wait of up to one second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread.

Can you write a Java class that could be used both as an applet as well as an application?
Yes. Add a main() method to the applet.

What’s the difference between constructors and other methods?
Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

Can you call one constructor from another if a class has multiple constructors ?
Yes. Use this() syntax.

Explain the usage of Java packages ?
This is a way to organize files when a project consists of multiple modules.  It also helps resolve naming conflicts when different packages have classes with the same names. Packages access level also allows you to protect data from being used by the non-authorized classes.

If a class is located in a package, what do you need to change in the OS environment to be able to use it?
You need to add a directory or a jar file that contains the package directories to the CLASSPATH environment variable. Lets say a class Employee belongs to a package com.xyz.hr; and is located in the file c:/dev/com.xyz.hr.Employee.java. In this case, you’d need to add c:/dev to the variable CLASSPATH. If this class contains the method main(), you could test it from a command prompt window as follows:
c:\>java com.xyz.hr.Employee

What’s the difference between J2SDK 1.5 and J2SDK 5.0?
There’s no difference, Sun Microsystems just re-branded this version.

What would you use to compare two String variables - the operator == or the method equals()?
I’d use the method equals() to compare the values of the Strings and the = = to check if two variables point at the same instance of a String object.

Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written?
A. Yes, it does. The FileNoFoundException is inherited from the IOException. Exception’s subclasses have to be caught first.

Can an inner class declared inside of a method access local variables of this method?
It’s possible if these variables are final.

What can go wrong if you replace && with & in the following code:
String a=null;
if (a!=null && a.length()>10)
{...}
A single ampersand here would lead to a NullPointerException.

What’s the main difference between a Vector and an ArrayList ?
Java Vector class is internally synchronized and ArrayList is not.

When should the method invokeLater()be used?
This method is used to ensure that Swing components are updated through the event-dispatching thread.

How can a subclass call a method or a constructor defined in a superclass?
Use the following syntax: super.myMethod(); To call a constructor of the superclass, just write super(); in the first line of the subclass’s constructor.

What’s the difference between a queue and a stack?
Stacks works by last-in-first-out rule (LIFO), while queues use the FIFO rule.

You can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces? 
Sometimes. But your class may be a descendent of another class and in this case the interface is your only option.

If you’re overriding the method equals() of an object, which other method you might also consider?
hashCode()

You are planning to do an indexed search in a list of objects. Which of the two Java collections should you use: ArrayList or LinkedList?
ArrayList

How would you make a copy of an entire Java object with its state?
Have this class implement Cloneable interface and call its method clone().

How can you minimize the need of garbage collection and make the memory use more effective?
Use object pooling and weak object references.

There are two classes: A and B. The class B need to inform a class A when some important event has happened. What Java technique would you use to implement it?
If these classes are threads I’d consider notify() or notifyAll(). For regular classes you can use the Observer interface.

What access level do you need to specify in the class declaration to ensure that only classes from the same directory can access it?
You do not need to specify any access level, and Java will use a default package access level.

Java 2+Yrs Interview Questions and Answers

Company Name :  Infosys

Sent By:  Kiran Kumar

Interview Questions:
  1. when we go for abstract class and interface?
  2. Difference between abstract class and interface . View Answer
  3. difference between final,finally,finalize in java.
  4. how to handle the exceptions in java and is finally necessary statement ?
  5. what are the Steps to create JDBC application.
  6. difference between Statement and PreparedStatement.
  7. what is lazy fetching in hibernate? 
  8. Can we have number of main() in same class?
  9. can we have multiple main() in different classes?
  10. difference between method overloading and method overriding.
  11. difference between checked and unchecked exceptions.examples View Answer
  12. give me an example for NullPointerException.
  13. Explain me a flow of application in Struts. View Answer
  14. difference between forward() and sendRedirect() 
  15. difference between equals() and ==in java. View Answer

Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email

Recently asked Oracle Telephonic Interview Question and Answers

What  Design Patterns are you using in your project?
i)MVC separates roles using different technologies,
ii)Singleton Java class To satisfy the Servlet Specification,a servlet must be a   

single Instance  multiple thread component.
iii)Front Controller A Servlet developed as Front Controller can traps only the requests.
iv) D.T.O/ V.O Data Transfer Object/Value object is there to send huge amount of data from one layer to another layer. It avoids Network Round trips.
v)IOC/Dependency Injection F/w s/w or container can automatically instantiates the objects  implicitly and  injects  the dependent data to that object.
vi)Factory method It won’t allows object instantiation from out-side of the class.
vii)View Helper It is there to develop a JSP without Java code so that readability,re-usability will become easy.

What is Singleton Java class & its importance?
A Java class that allows to create only one object per JVM is called Singleton Java class.
Ex:  In Struts f/w, the ActionServlet is a Singleton Java class.
Use: Instead of creating multiple objects for a Java class having same data, it is recommended to create only one object & use it for multiple no. of times.

What are the differences b/w perform() & execute()?

perform() is an deprecated method.

What are the drawbacks of Struts? Is it MVC-I or II?   
  

Struts is MVC-II
1) Struts 1.x components are API dependent.  Because Action & FormBean classes must extend from the Struts 1.x APIs pre-defined classes.
2)  Since applications are API dependent hence their “Unit testing” becomes complex.
3)  Struts allows only JSP technology in developing View-layer components.
4)  Struts application Debugging is quite complex.
5)  Struts gives no built-in AJAX support. (for asynchronous communication)
Note:In Struts 1.x, the form that comes on the Browser-Window can be displayed under no control of F/W s/w  & Action class.

What are the differences b/w struts, spring and hibernate?
Struts:  allows to develop only webapplications and it can’t support POJO/POJI model programming.
Spring: is useful in developing all types of Java applications and support POJO/POJI model programming.
Hibernate: is used to  develop DB independent persistence logic It also supports POJO/POJI model programming.

What are differences b/w Servlets & Jsp?

Servlets:
 i)It  requires Recompilation and  Reloading when we do modifications in a    Servlet.(some servers)

ii)Every Servlet must be configured in “web.xml”.
iii)It is providing less amount of implicit objects support.
iv)Since it consists both HTML & B.logic hence modification in one logic may disturbs the other logic.
v)No implicit Exception Handling support.
vi)Since it requires strong Java knowledge hence non-java programmers shows no interest.
vii)Keeping HTML code in Servlets is quite complex.
JSP:
i)No need of Recompilation & Reloading when we do modifications in a JSP page.
ii)We need not to Configure a JSP in a “web.xml”.
iii)It is providing huge amount of Implicit Objects support.
iv)Since Html & Java code are separated hence no disturbance while changing logic.
v)It is providing implicit XML Exception Handling support.
vi)It is easy to learn & implement since it is tags based.
vii)It allows to develop custom tags.
viii)It gives JSTL support. (JSP Standard Tag LibraryIt provides more tags that will help to develop a JSP without using Java code).
 ix)It gives all benefits of Servlets.

 What is the difference b/w ActionServlet & Servlet?
ActionServlet: It is a predefined Singleton Java class and it traps all the requests coming to Server.It acts as a Front-Controller in Struts 1.x.
Servlet:  a Java class that extends HttpServlet/GenericServlet or implements Servlet interface and is a Server side technology to develop dynamic web pages.It is a Single instance multiple thread component. It need not be a Singleton Java class.

What are Access Specifiers & modifiers?
 i)public - Universal access specifier.
        can be used along with: class, innerclass, Interface, variable, constructor, method.                     
ii)protected - Inherited access specifier.
        can be used along with: innerclass, variable, method, constructor.
 iii)default - Package access specifier(with in the package).
        can be used along with: class, innerclass, interface, variable, constructor, method.
iv) private -Native access specifier.
        can be used along with: innerclass, variable, constructor, method         Some other access modifiers:
i) static------------innerclass,variable,block,method.
ii) abstract—----- class,method.
iii) final--------------class,variable,method.
iv) synchronized---block,method.
v) transient---------variable.
vi) native-------------method.
vii) volatile-----------variable
viii) strict fp-----------variable
         
Which JSP tag is  used to display error validation?
In Source page:   
    <%@page  errorPage=”error-page-name.jsp”>
In  Error page:
     <%@page  isErrorPage=”true”>


What are the roles of  EJBContainer ?
• An EJB container is the world in which an EJB bean lives.
• The container services requests from the EJB, forwards requests from the client to the EJB, and interacts with the EJB server.
• The container provider must provide transaction support, security and persistence to beans.
• It is also responsible for running the beans and for ensuring that the beans are protected from the outside world.

Important Spring Interview Question and Answers

What is Spring?
Spring performs two major roles for a Java application.

First Spring is a container that manages all or some of the objects used by the application. Behind the scenes Spring configures your objects with what they need to in order to perform their roles in the application. If you need a Data Access Object, you ask the Spring container to provide one that is already configured with values for its data source and other properties. 

Spring is also a framework because it provides libraries of classes that make it easier to accomplish common tasks such as transaction management, database integration, email, and web applications.

What does Spring provide ?

Spring is a lightweight framework.  Most of your Java classes will have nothing about Spring in their source code.  This means that you can easily transition your application from the Spring framework to something else.  It also means that transferring an existing application to use the Spring framework doesn’t have to mean a complete code rewrite.

All Java applications that consist of multiple classes have inter-dependencies or coupling between classes.  Spring helps us develop applications that minimize the negative effects of coupling and encourages the use of interfaces in application development.  Using interfaces in our applications to specify type helps make our applications easier to maintain and enhance later.

The Spring framework helps developers clearly separate responsibilities.  Many Java applications suffer from class bloat – that is a class that has too many responsibilities.  For example a service class that is also logging information about what its doing.  Think of two situations – one is you’ve been told by your supervisor to do your normal work but also to write down everything you do and how long it takes you.  You’d be even busier and less responsive.  

A better situation would be you do your normal work, but another person observers what you’re doing and records it and measures how long it took.  Even better would be if you were totally unaware of that other person and that other person was able to also observe and record other people’s work and time.  

What are the modules Spring Provides ?

  • The Core package is the most fundamental part of the framework and provides the IoC and Dependency Injection features. The basic concept here is the BeanFactory, which provides a sophisticated implementation of the factory pattern which removes the need for programmatic singletons and allows you to decouple the configuration and specification of dependencies from your actual program logic.
  • The Context package build on the solid base provided by the Core package: it provides a way to access objects in a framework-style manner in a fashion somewhat reminiscent of a JNDI-registry. The context package inherits its features from the beans package and adds support for internationalization (I18N) (using for example resource bundles), event-propagation, resource-loading, and the transparent creation of contexts by, for example, a servlet container.
  • The DAO package provides a JDBC-abstraction layer that removes the need to do tedious JDBC coding and parsing of database-vendor specific error codes. Also, the JDBC package provides a way to do programmatic as well as declarative transaction management, not only for classes implementing special interfaces, but for all your POJOs (plain old Java objects).
  • The ORM package provides integration layers for popular object-relational mapping APIs, including JPA, JDO, Hibernate, and iBatis. Using the ORM package you can use all those O/R-mappers in combination with all the other features Spring offers, such as the simple declarative transaction management feature mentioned previously.
  • Spring's AOP package provides an AOP Alliance-compliant aspect-oriented programming implementation allowing you to define, for example, method-interceptors and pointcuts to cleanly decouple code implementing functionality that should logically speaking be separated. Using source-level metadata functionality you can also incorporate all kinds of behavioral information into your code, in a manner similar to that of .NET attributes.
  • Spring's Web package provides basic web-oriented integration features, such as multipart file-upload functionality, the initialization of the IoC container using servlet listeners and a web-oriented application context. When using Spring together with WebWork or Struts, this is the package to integrate with.
  • Spring's MVC package provides a Model-View-Controller (MVC) implementation for web-applications. Spring's MVC framework is not just any old implementation; it provides a clean separation between domain model code and web forms, and allows you to use all the other features of the Spring Framework.
What are the benefits of Spring Framework?
  • Not a J2EE container. Doesn’t compete with J2EE app servers. Simply provides alternatives.
  • POJO-based, non-invasive framework which allows a la carte usage of its components. 
  • Promotes decoupling and reusability  
  • Reduces coding effort and enforces design discipline by providing out-of-box implicit pattern implementations such as singleton, factory, service locator etc.
  • Removes common code issues like leaking connections and more
  • Support for declarative transaction management
  • Easy integration with third party tools and technologies.
What is Inversion of Control ?
  • Instead of objects invoking other objects, the dependant objects are added through an external entity/container.
  • Also known as the Hollywood principle – “don’t call me I will call you”
  • Dependency injection
    • Dependencies are “injected” by container during runtime.
    • Beans define their dependencies through constructor arguments or properties
  • Prevents hard-coded object creation and object/service lookup.
  • Loose coupling
  • Helps write effective unit tests
Explain the Spring Bean Definition ?
  • The bean class is the actual implementation of the bean being described by the BeanFactory. 
  • Bean examples – DAO, DataSource, Transaction Manager, Persistence Managers, Service objects, etc
  • Spring config contains implementation classes while your code should program to interfaces.
  • Bean behaviors include:
    • Singleton or prototype
    • Autowiring
    • Initialization and destruction methods 
      • init-method
      • destroy-method
  • Beans can be configured to have property values set.  
    • Can read simple values, collections, maps, references to other beans, etc.
Explain Spring BeanFactory ?

BeanFactory is core to the Spring framework

  • Lightweight container that loads bean definitions and manages your beans.
  • Configured declaratively using an XML file, or files, that determine how beans can be referenced and wired together.
  • Knows how to serve and manage a singleton or prototype defined bean
  • Responsible for lifecycle methods.
  • Injects dependencies into defined beans when served 
  • Removes the need for ad-hoc singletons and factories

Explain the Spring ApplicationContext ?

  • A Spring ApplicationContext allows you to get access to the objects that are configured in a BeanFactory in a framework manner.
  • ApplicationContext extends BeanFactory
    • Adds services such as international messaging capabilities.
    • Add the ability to load file resources in a generic fashion.
  • Several ways to configure a context: 
    • XMLWebApplicationContext – Configuration for a web application.
    • ClassPathXMLApplicationContext – standalone XML application context
    • FileSystemXmlApplicationContext
  • Allows you to avoid writing Service Locators

How Spring Support Struts?

  • ContextLoaderPlugin
    • Loads a Spring application context for the Struts ActionServlet. 
    • Struts Actions are managed as Spring beans.
  • ActionSupport and DispatchActionSupport 
    • Pre-built convenience classes to provide access to the context.  
    • Provides methods in superclass for easy context lookup.

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">

    <set-property property="contextConfigLocation"

      value="/WEB-INF/applicationContext.xml"/>

</plug-in>

Explain Transaction Management in Spring ?

1. DataSourceTransactionManager - PlatformTransactionManager implementation for single JDBC data sources. Binds a JDBC connection from the specified data source to the thread, potentially allowing for one thread connection per data source. 

2. HibernateTransactionManager- PlatformTransactionManager implementation for single Hibernate session factories. Binds a Hibernate Session from the specified factory to the thread, potentially allowing for one thread Session per factory. SessionFactoryUtils and HibernateTemplate are aware of thread-bound Sessions and participate in such transactions automatically. Using either is required for Hibernate access code that needs to support this transaction handling mechanism. 

3. JdoTransactionManager - PlatformTransactionManager implementation for single JDO persistence manager factories. Binds a JDO PersistenceManager from the specified factory to the thread, potentially allowing for one thread PersistenceManager per factory. PersistenceManagerFactoryUtils and JdoTemplate are aware of thread-bound persistence managers and take part in such transactions automatically. Using either is required for JDO access code supporting this transaction management mechanism.

4. JtaTransactionManager - PlatformTransactionManager implementation for JTA, i.e. J2EE container transactions. Can also work with a locally configured JTA implementation. This transaction manager is appropriate for handling distributed transactions, i.e. transactions that span multiple resources, and for managing transactions on a J2EE Connector (e.g. a persistence toolkit registered as JCA Connector). 


Explian some of the DAO Support classes in Spring Framework ?

  • JdbcDaoSupport 
    • Provides callback methods for row iteration
  • HibernateDaoSupport 
    • Initializes Hibernate session factory
    • Provides templates to invoke Hibernate API or the session
  • SqlMapDaoSupport
    • Provides template for iBatis SQLMaps
    • Support similar to Hibernate template

What is Spring MVC?

A single shared controller instance handles a particular request type
controllers, interceptors run in the IoC container
Allows multiple DispatcherServlets that can share an “application context”
Interface based not class-based

Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email

Basic Core Java Interview QUestions With Answers

Q. What is static variable?
Ans. A static variable is one that is not removed from memory after creation, even when it goes out of scope. The concept is very similar to that of a global variable, except that while a global variable is accessible from anywhere, a static variable is only accessible within certain parts of the program code.


Q. How will you pass values from HTML page to the Servlet?
Ans. We can pass values from HTMLpage to servlet using "request.getParameter(string);" method, which is a method in the HttpServletRequest interface.


Q. What is the difference between Hashmap and Hashtable?
Ans. HashMap is not Synchronized where as Hashtable is.
HashMap allows null as both key and value, where as Hashtable does not allow null.
HashMap retrieval is not in order (random) while Hashtable provides ordered retrieval.


Q. Can a lock be acquired on a class?
Ans. Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.


Q. What is the difference between the paint() and repaint() methods?
Ans. The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() tobe invoked by the AWT painting thread.


Q. What is the Collections API?
Ans. The Collections API is a set of classes and interfaces that support operations on collections of objects.


Q. What is the difference between the prefix and postfix forms of the ++ operator?
Ans. The prefix form performs the increment operation and returns the value of the increment operation. The postfix form returns the current value all of the expression and then performs the increment operation on that value.


Q. What is the difference between an Applet and an Application?
Ans. 1. Applets can be embedded in HTML pages and downloaded over the Internet whereas Applications have no special support in HTML for embedding or downloading.
2. Applets can only be executed inside a java compatible container, such as a browser or appletviewer whereas Applications are executed at command line by java.exe orjview.exe.
3. Applets execute under strict security limitations that disallow certain operations(sandbox model security) whereas Applications have no inherent security restrictions.
4. Applets don't have the main() method as in applications. Instead they operate on an entirely different mechanism where they are initialized by init(),started bystart(),stopped by stop() or destroyed by destroy().

 
Q. What is the difference between yielding and sleeping?
Ans. When a task invokes its yield() method, it returns to the ready state. When a task invokesits sleep()method, it returns to the waiting state.


Q. What value does readLine() return when it has reached the end of a file?
Ans. The readLine() method returns null when it has reached the end of a file.


Q. How does multithreading take place on a computer with a single CPU?
Ans. The operating system's task scheduler allocates execution time to multiple threads. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.


Q. What is the differences between script language and programming language?
Ans. Generally scripting languages can be used to validating the client side,it means reducing the burden on the server side and ruducing network traffic in order to facilitating the higher performance for client who will access application.It has some limitations when compared to programming languages.These limitations as follows:1.Scripting languages cannot support File operations.2. It does not support Database connections.3.It is not suited for network environment.

Q. Can we make construtor 'static'?
Ans. A constructor can never be declared as static, because the role of a constructor is to initialize the object variables and static is never involved with the object so constructor cannot be static


Q. Is there any way in java to find of size of an object ?
Ans. There is no particular command to find of size of an object in java (like sizeof() operator of C/C++ ) but you can check Runtime r = Runtime.getRuntime() ;r.freeMemory() ;before and after the creation of the new Object.By subtraction u can get the used memory.


Q. Can u kill thread manually. What is the disadvantage?
Ans. You can stop (kill) a thread by calling the method 'stop()' on the thread object. But it is not preferable to kill a thread, because it may cause system failure when writing to important data structures.


Q. What is casting?
Ans. There are two types of casting, casting between primitive numeric types and casting between objectreferences. Casting between numeric types is used to convert larger values, such asdouble values, tosmaller values, such as byte values. Casting between object references is used to refer toan object by acompatible class, interface, orarray type reference.


Q. Does a class inherit the constructors of its superclass?
Ans. No, A class does not inherit constructors from any of its superclasses.


Q. What is transient variable?
Ans. A transient variable is not stored with its Object; therefore, it is not serialized when the method writeObject( ) is invoked.


Q. Can the abstract class be final?
Ans. No the abstract class cannot be final, coz the main purpose of the creating abstract class is to inherit them and override there methods. If it is made final then the main purpose of the creating the abstract class is violated. i.e we can't inherit those classes.


Q. In How many ways we can request the System for the garbage collection to cleanup the memory?
Ans. There are 2 ways -
1) System.gc();
2) RunTime r = RunTime.getRunTime();r.gc();


Q. What happens when a thread cannot acquire a lock on an object?
Ans. If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object's lock, it enters the waiting state until the lock becomes available


Q. Can a lock be acquired on a class?
Ans. Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.



Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email

Recent ADP Java Interview Questions

Company Name : ADP

Sent By :  Jagath Chandra 

Interview Questions:
  • how can execute the prepared statement is executed in more than one in application? Where the ps object is created either db or application?
  • What is Cloneable Interface?
  • How to decide whether to use Interface or Abstract Class?
  • What are the types of Executor Interfaces ?
  • What are the core interfaces in Hibernate?
  • If two Interfaces have same Method, how to handle that Method in a Class implementing these two Interfaces?
  • Which type of EJB can use bean pooling?
  • Difference between Include Directive & Include Tag?
  • what use of Ajax?
  • What parsers are supported in Ajax?
  • what situation validation framework is applied in struts framework?
  • what is difference between the validation.xml and validation-rules.xml?
  • whats difference between the HTML and Dhtml?
Please share your faced interview questions by faqs@javastuff.in, which can help job seekers as well as java learners. 

Thanks  Jagath Chandra . All the best !!!!!!!
Now its our job to answer the above.


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email

What is Polymorphism?

Polymorphism is an important Object oriented concept and widely used in Java and other programming language.  Polymorphism in java is supported along with other concept like abstraction, encapsulation and inheritance. bit on historical side polymorphism word comes from ancient Greek where poly means many so polymorphic are something which can take many form. In this java polymorphism tutorial we will see what polymorphism in Java is, how polymorphism is implemented in Java, why should we use polymorphism and how can we take advantage of polymorphism while writing code in Java. Along the way we will also see a real world example of using polymorphism in Java


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email