Top 50 J2EE interview questions & Answers. 1) What is J2EE? J2EE means Java 2 Enterprise Edition. The functionality of J2EE is developing multitier web-. The J2EE platform is consists of a set of services, application programming Top 50 J2EE interview questions & Answers .. Download PDF. Advanced J2EE Interview Questions and Answers for Freshers or Experienced Pdf. This interview section questions contains a brief introduction to the Java.
|Language:||English, Spanish, French|
|PDF File Size:||11.71 MB|
|Distribution:||Free* [*Regsitration Required]|
Enterprise Java – Interview questions & answers . The reason I chose “Java /J2EE Job Interview Companion” is because . How many years of experience. These interview questions and answers on Advanced Java will help you strengthen your technical skills Interview preparation PDF was generated at Monday 12th January, J2EE will be more friendly and efficiency in the code. If you're looking for J2EE Interview Questions for Experienced or Freshers, you are at right place. There are lot of opportunities from many reputed companies in .
Difference between Map and HashMap? Map is an interface where HashMap is the concrete class. What is a Property class? The properties class is a subclass of Hashtable that can be read from or written to a stream. If the Object value will not change in a scenario use String Class because a String object is immutable.
If the Object value can change and will only be modified from a single thread, use a StringBuilder because StringBuilder is unsynchronized means faster. If the Object value may change, and can be modified by multiple threads, use a StringBuffer because StringBuffer is thread safe synchronized. Explain java. This Error is thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector. Can we have multiple servlets in a web application and How can we do that?
Yes by making entries in web. How can we manage Error Messages in the web application? Within message.
Is JVM, a compiler or interpretor? Its an interpretor. Difference between implicit and explicit type casting? An explicit conversion is where you use some syntax to tell the program to do a conversion whereas in case of implicit type casting you need not provide the data type. Difference between loadClass and Class. Should we override finalize method?
Finalize is used by Java for Garbage collection. It should not be done as we should leave the Garbage Collection to Java itself. What is assert keyword used for? The assert keyword is used to make an assertion—a statement which the programmer believes is always true at that point in the program.
This keyword is intended to aid in testing and debugging. Factory Pattern deals with creation of objects delegated to a separate factory class whereas Abstract Factory patterns works around a super-factory which creates other factories.
Difference between Factory and Builder Design Pattern? Builder pattern is the extension of Factory pattern wherein the Builder class builds a complex object in multiple steps. Difference between Proxy and Adapter? Adapter object has a different input than the real subject whereas Proxy object has the same input as the real subject. Proxy object is such that it should be placed as it is in place of the real subject.
Difference between Adapter and Facade? The Difference between these patterns in only the intent. Adapter is used because the objects in current form cannot communicate where as in Facade , though the objects can communicate , A Facade object is placed between the client and subject to simplify the interface.
Difference between Builder and Composite? Builder is a creational Design Pattern whereas Composite is a structural design pattern. Composite creates Parent - Child relations between your objects while Builder is used to create group of objects of predefined types.
Example of Chain of Responsibility Design Pattern? Exception Handling Throw mechanism. Example of Observer Design Pattern? Difference between Factory and Strategy Design Pattern? Factory is a creational design pattern whereas Strategy is behavioral design pattern.
Factory revolves around the creation of object at runtime whereas Strategy or Policy revolves around the decision at runtime. Strategy deals only with decision making at runtime so Interfaces should be used. Which kind of memory is used for storing object member variables and function local variables? Local variables are stored in stack whereas object variables are stored in heap.
Why do member variables have default values whereas local variables don't have any default value? In case of local variables, they are stored in stack until they are being used. What is a Default Constructor? The no argument constructor provided by Java Compiler if no constructor is specified.
Will Compiler creates a default no argument constructor if we specify only multi argument constructor? No, Compiler will create default constructor only if we don't specify any constructor. Can we overload constructors? What will happen if we make the constructor private?
We can't create the objects directly by invoking new operator. How can we create objects if we make the constructor private? We can do so through a static public member method or static block. What will happen if we remove the static keyword from main method? Program will compile but will give a "NoSuchMethodError" during runtime. Why Java don't use pointers?
Pointers are vulnerable and slight carelessness in their use may result in memory problems and hence Java intrinsically manage their use. Can we use both "this" and "super" in a constructor? No, because both this and super should be the first statement.
Do we need to import java. No, It is loaded by default by the JVM. Is it necessary that each try block to be followed by catch block? It should be followed by either catch or finally block. Can finally block be used without catch? Yes but should follow "try" block then.
What is exception propogation? Passing the exception object to the calling method. Difference between nested and inner classes? Inner classes are non static nested classes. What is a nested interface? Any interface declared inside a class or an interface. It is static by default.
What is an Externalizable interface? Externalizable interface is used to write the state of an object into a byte stream in compressed format. Difference between serializable and externalizable interface? Serializable is a marker interface whereas externalizable is not.
What is reflection? Can we instantiate the object of derived class if parent constructor is protected? Can we declare an abstract method private? No Abstract methods can only be declared protected or public. What are the design considerations while making a choice between using interface and abstract class? Keep it as Interface if its a "Should Do" relationship. What is a config Object? The config object is an instantiation of javax.
ServletConfig and is a direct wrapper around the ServletConfig object for the generated servlet. This object allows the JSP programmer access to the Servlet or JSP engine initialization parameters such as the paths or file location. What is a pageContext Object?
The pageContext object is an instance of a javax. PageContext object. The pageContext object is used to represent the entire JSP page. This object stores references to the request and response objects for each request. The application, config, session, and out objects are derived by accessing attributes of this object. The pageContext object also contains information about the directives issued to the JSP page, including the buffering information, the errorPageURL, and page scope.
What is suspend method used for? We can then restart the thread by using resume method. Difference between suspend and stop? Suspend method is used to suspend thread which can be restarted by using resume method. What are the benefits of using Spring Framework? Spring enables developers to develop enterprise-class applications using POJOs. Spring is organized in a modular fashion. Even though the number of packages and classes are substantial, you have to worry only about ones you need and ignore the rest.
Spring does not reinvent the wheel instead, it truly makes use of some of the existing technologies like several ORM frameworks, logging frameworks, JEE, Quartz and JDK timers, other view technologies.
Testing an application written with Spring is simple because environment-dependent code is moved into this framework. Lightweight IoC containers tend to be lightweight, especially when compared to EJB containers, for example.
This is beneficial for developing and deploying applications on computers with limited memory and CPU resources. Spring provides a consistent transaction management interface that can scale down to a local transaction.
Collections class is a utility class having static methods for doing operations on objects of classes which implement the Collection interface.
For example, Collections has methods for finding the max element in a Collection. Will this code give error if i try to add two heterogeneous elements in the arraylist. If we don't declare the list to be of specific type, it treats it as list of objects. Difference between Java beans and Spring Beans? What is the difference between System. What are various types of Class loaders used by JVM?
Bootstrap - Loads JDK internal classes, java. How are classes loaded by JVM? Class loaders are hierarchical. The very first class is specially loaded with the help of static main method declared in your class. All the subsequently loaded classes are loaded by the classes, which are already loaded and running.
Java does not support pointers. Java does not support multiple inheritances. Java does not support destructors but rather adds a finalize method. Finalize methods are invoked by the garbage collector prior to reclaiming the memory occupied by the object, which has the finalize method.
Java does not include structures or unions because the traditional data structures are implemented as an object oriented framework. Java use import to include different Classes and methods. There is no goto statement in Java. There is no scope resolution operator:: It has. You can manipulate machine addresses to look at anything you want. Java access is controlled. Difference between static vs. Tell something about BufferedWriter?
What are flush and close used for? A Buffer is a temporary storage area for data.
The BufferedWriter class is an output stream. It is an abstract class that creates a buffered character-output stream. Flush is used to clear all the data characters stored in the buffer and clear the buffer.
Close is used to closes the character output stream. What is Scanner class used for? Scanner class introduced in Java 1. Previously we used to write code to read a input using DataInputStream. After reading the stream , we can convert into respective data type using in. Struts 1 actions are singleton. So all threads operates on the single action object and hence makes it thread unsafe.
Struts 2 actions are not singleton and a new action object copy is created each time a new action request is made and hence its thread safe.
What are some Java related technologies used for distributed computing? Whats the purpose of marker interfaces? They just tell the compiler that the objects of the classes implementing the interfaces with no defined methods need to be treated differently. What is the difference between final, finally and finalize? The finally block is optional and provides a mechanism to clean up regardless of what happens within the try block. Use the finally block to close files or to release other system resources like database connections, statements etc.
A method that is invoked before an object is discarded by the garbage collector, allowing it to clean up its state. When do you get ClassCastException? As we only downcast class in the hierarchy, The ClassCastException is thrown to indicate that code has attempted to cast an object to a subclass of which it is not an instance. Explain Thread States? Runnable - waiting for its turn to be picked for execution by the thread schedular based on thread priorities.
Running - The processor is actively executing the thread code. It runs until it becomes blocked, or voluntarily gives up its turn. Sleeping - Java threads are forcibly put to sleep suspended with Thread. Blocked on synchronization - Will move to Runnable when a lock is acquired. Dead - The thread is finished working. What are strong, soft, weak and phantom references in Java?
A soft reference will only get removed if memory is low. A weak reference will get removed on the next garbage collection cycle. A phantom reference will be finalized but the memory will not be reclaimed.
Can be useful when you want to be notified that an object is about to be collected. Difference between yield and sleeping? When a task invokes yield , it changes from running state to runnable state. What is a daemon thread? Give an Example? These are threads that normally run at a low priority and provide a basic service to a program or programs when activity on a machine is reduced.
What is the difference between AWT and Swing? Swing provides extras for components, such as icons on many components, decorative borders for components, tool tips for components etc.
Swing components are lightweight than AWT. Swing provides built-in double buffering ,which means an off-screen buffer is used during drawing and then the resulting bits are copied onto the screen.
Swing provides paint debugging support for when you build your own component. What is the order of method invocation in an applet?
Name few tools for probing Java Memory Leaks? JProbe, OptimizeIt. Which memory areas does instance and static variables use? What is J2EE? What are J2EE components and services? J2EE or Java 2 Enterprise Edition is an environment for developing and deploying enterprise applications. What are the components of J2EE? What is XML? A SAX parser serves the client application always only with pieces of the document at any given time whereas A DOM parser always serves the client application with the entire document no matter how much is actually needed by the client.
A SAX parser, however, is much more space efficient in case of a big input document whereas DOM parser is rich in functionality. Use a DOM Parser if you need to refer to different document areas before giving back the information. Use SAX is you just need unrelated nuclear information from different areas. What is DTD? Your application can use a standard DTD to verify that data that you receive from the outside world is valid and can be parsed by your parser. What is XSD?
What is JAXP? What is JAXB? What is marshalling? What is unmarshalling? Which load testing tools have you used? What are LDAP servers used for? LDAP servers are hierarchical and are optimized for read access, so likely to be faster than database in providing read access.
What is the difference between comparable and comparator in java. Comparable interface is used for single sequence sorting i. What are different modules of spring? The DispatcherServlet configured in web. The DispatcherServlet finds the appropriate Controller with the help of HandlerMapping and then invokes associated Controller.
Then the DispatcherServlet passes the model object to the View. The View is rendered and the Dispatcher Servlet sends the output to the Servlet container. Finally Servlet Container sends the result back to the user. What is Spring configuration file?
Spring configuration file is an XML file. This file contains the classes information and describes how these classes are configured and introduced to each other. What is default scope of bean in Spring framework? The default scope of bean is Sing leton for Spring framework. What bean scopes does Spring support? Explain them. The Spring Framework supports following five scopes - Singleton prototype request session global-session. What is bean auto wiring? The Spring container is able to autowire relationships between collaborating beans.
This means that it is possible to automatically let Spring resolve collaborators other beans for your bean by inspecting the contents of the BeanFactory without using and elements. Difference between socket and servlet? A network socket is an endpoint of an inter-process communication flow across a computer network. We can think of it as a difference between door and gate. They are similar as they both are entry points but they are different as they are put up at different areas. Sockets are for low-level network communication whereas Servlets are for implementing websites and web services.
Difference Between this and super? What are the phases of the JSP life cycle? Initialization jspInit method is invoked by the container. Destroy jspDestroy method is invoked by the container. Difference between the jsp scriptlet tag and jsp declaration tag? The jsp scriptlet tag can only declare variables not methods whereas jsp declaration tag can declare variables as well as methods.
What are JSP directives? What are different types of directives? The jsp directives are messages that tells the web container how to translate a JSP page into the corresponding servlet. What is Java bytecode? Java programs are compiled into Java bytecode, which can then be executed by the JVM.
What is a Listener? In GUI programming, an object that can be registered to be notified when events of some given type occur. What is MVC? The model is the data for the component. The view is the visual presentation of the component on the screen. The controller is responsible for reacting to events by changing the model. According to the MVC pattern, these responsibilities should be handled by different objects. What is race condition? A source of possible errors in parallel programming, where one thread can cause an error in another thread by changing some aspect of the state of the program that the second thread is depending on such as the value of variable.
What is unicode? A way of encoding characters as binary numbers. The Unicode character set includes characters used in many languages, not just English. Unicode is the character set that is used internally by Java.
What is ThreadFactory? ThreadFactory is an interface that is meant for creating threads instead of explicitly creating threads by calling new Thread. Its an object that creates new threads on demand. Using thread factories removes hardwiring of calls to new Thread, enabling applications to use special thread subclasses, priorities, etc. What is PermGen or Permanent Generation? The memory pool containing all the reflective data of the java virtual machine itself, such as class and method objects.
With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas. The Permanent generation contains metadata required by the JVM to describe the classes and methods used in the application. The permanent generation is populated by the JVM at runtime based on classes in use by the application. In addition, Java SE library classes and methods may be stored here.
What is metaspace? The Permanent Generation PermGen space has completely been removed and is kind of replaced by a new space called Metaspace. PermGen error. You can put related classes together as a single logical group. Nested classes can access all class members of the enclosing class, which might be useful in certain cases.
Nested classes are sometimes useful for specific purposes. Explain Static nested Classes? The accessibility public, protected, etc. A static nested class is not an inner class, it's a top-level nested class. The name of the static nested class is expressed with OuterClassName. NestedClassName syntax. When you define an inner nested class or interface inside an interface, the nested class is declared implicitly public and static. Static nested classes can be declared abstract or final.
Static nested classes can extend another class or it can be used as a base class. Static nested classes can have static members. Static nested classes can access the members of the outer class only static members, obviously. The outer class can also access the members even private members of the nested class through an object of nested class. Explain Inner Classes? Just like top-level classes, an inner class can extend a class or can implement interfaces.
Similarly, an inner class can be extended by other classes, and an inner interface can be implemented or extended by other classes or interfaces. An inner class can be declared final or abstract. Explain Method Local Inner Classes? You can create a non-static local class inside a body of code.
Interfaces cannot have local classes, and you cannot create local interfaces. Local classes are accessible only from the body of the code in which the class is defined. The local classes are completely inaccessible outside the body of the code in which the class is defined.
You can extend a class or implement interfaces while defining a local class. A local class can access all the variables available in the body of the code in which it is defined. You can pass only final variables to a local inner class. Explain about anonymous inner classes? Anonymous classes are defined in the new expression itself, so you cannot create multiple objects of an anonymous class.
You cannot explicitly extend a class or explicitly implement interfaces when defining an anonymous class. An anonymous inner class is always created as part of a statement; don't forget to close the statement after the class definition with a curly brace.
This is a rare case in Java, a curly brace followed by a semicolon. Anonymous inner classes have no name, and their type must be either a subclass of the named type or an implementer of the named interface.
What will happen if class implement two interface having common method?
That would not be a problem as both are specifying the contract that implement class has to follow. What is the advantage of using arrays over variables? Arrays provide a structure wherein multiple values can be accessed using single reference and index.
This helps in iterating over the values using loops. What are the disadvantages of using arrays? Arrays are of fixed size and have to reserve memory prior to use. Hence if we don't know size in advance arrays are not recommended to use. Arrays can store only homogeneous elements.
Arrays store its values in contentious memory location. Not suitable if the content is too large and needs to be distributed in memory. There is no underlying data structure for arrays and no ready made method support for arrays, for every requriment we need to code explicitly. Difference between Class getInstance and new operator? Can we create an object if a Class doesn't have any constructor not even the default provided by constructor?
Yes , using Class. What is a cloneable interface and what all methods does it contain? When you will synchronize a piece of your code?
When you expect your code will be accessed by different threads and these threads may change a particular data causing data corruption. Are there any global variables in Java, which can be accessed by other part of your program? Global variables are not allowed as it wont fit good with the concept of encapsulation. What is an applet? What is the lifecycle of an applet? Applet is a dynamic and interactive program that runs inside a web page displayed by a java capable browser.
Lifecycle methods of Applet - init method - Can be called when an applet is first loaded start method - Can be called each time an applet is started paint method - Can be called when the applet is minimized or maximized stop method - Can be used when the browser moves off the applet's page destroy method - Can be called when the browser is finished with the applet.
These controls are subclasses of Component. What is a stream and what are the types of Streams and classes of the Streams? A Stream is an abstraction that either produces or consumes information. There are two types of Streams: Byte Streams: Provide a convenient means for handling input and output of bytes. Character Streams: Byte Streams classes: Are defined by using two abstract classes, namely InputStream and OutputStream.
Character Streams classes: Are defined by using two abstract classes, namely Reader and Writer. What is session tracking and how do you track a user session in servlets? Session tracking is a mechanism that servlets use to maintain state about a series requests from the same user across some period of time.
The methods used for session tracking are: User Authentication - occurs when a web server restricts access to some of its resources to only those clients that log in using a recognized username and password Hidden form fields - fields are added to an HTML form that are not displayed in the client's browser. When the form containing the fields is submitted, the fields are sent back to the server URL rewriting - every URL that the user clicks on is dynamically modified or rewritten to include extra information.
The extra information can be in the form of extra path information, added parameters or some custom, server-specific URL change. Cookies - a bit of information that is sent by a web server to a browser and which can later be read back from that browser. HttpSession- places a limit on the number of sessions that can exist in memory. What is connection pooling?
It's a technique to allow multiple clients to make use of a cached set of shared and reusable connection objects providing access to a database or other resource. Advantage of Collection classes over Arrays? Collections are re-sizable in nature. We can increase or decrease the size as per recruitment. Collections can hold both homogeneous and heterogeneous data's. Every collection follows some standard data structures.
Collection provides many useful built in methods for traversing,sorting and search. What are the Disadvantages of using Collection Classes over Arrays? Collections can only hold objects, It can't hold primitive data types. Collections have performance overheads as they deal with objects and offer dynamic memory expansion. This dynamic expansion could be a bigger overhead if the collection class needs consecutive memory location like Vectors.
Collections doesn't allow modification while traversal as it may lead to concurrentModificationException. Can we call constructor explicitly? Does a class inherit the constructor of its super class?
What is the difference between float and double?
Float can represent up to 7 digits accurately after decimal point, where as double can represent up to 15 digits accurately after decimal point. It always fills 0 in the sign bit. But System. Is it possible to compile and run a Java program without writing main method? Yes, it is possible by using a static block in the Java program. What are different ways of object creation in Java? Using new operator - new xyzClass Using factory methods - xyzFactory.
What is Generalization and Specialization in terms of casting? Generalization or UpCasting is a phenomenon where a sub class is prompted to a super class, and hence becomes more general. Generalization needs widening or up-casting. Specialization or DownCasting is a phenomenon where a super class is narrowed down to a sub class. Specialization needs narrowing or down-casting. Can we call the garbage collector explicitly? Yes, We can call garbage collector of JVM to delete any unused variables and unreferenced objects from memory using gc method.
This gc method appears in both Runtime and System classes of java.
How does volatile affect code optimization by compiler? Volatile is an instruction that the variables can be accessed by multiple threads and hence shouldn't be cached. As volatile variables are never cached and hence their retrieval cannot be optimized. Do you think that Java should have had pointers? Open ended Questions. How would you go about debugging a NullPointerException?
How does Java differ from other programming languages you've worked with? Should good code be self-documenting, or is it the responsibility of the developer to document it? What are points to consider in terms of access modifier when we are overriding any method?
Overriding method can not be more restrictive than the overridden method. If by means subclass were allowed to change the access modifier on the overriding method, then suddenly at runtime—when the JVM invokes the true object's version of the method rather than the reference type's version then it will be problematic 2. In case of subclass and superclass define in different package, we can override only those method which have public or protected access.
We can not override any private method because private methods can not be inherited and if method can not be inherited then method can not be overridden. How compiler handles the exceptions in overriding? In this case , if superclass method throws any checked exception , then while overriding the method in subclass we can not throw any new checked exception or any checked exception which are higher in hierarchy than the exception thrown in superclass method.
Why is Java considered Portable Language? Java is a portable-language because without any modification we can use Java byte-code in any platform which supports Java.
So this byte-code is portable and we can use in any other major platforms. Tell something about history of Java? At first it was called as "Oak". In then it was later renamed to "Java". Currently Oracle, America owns Java. How to find if JVM is 32 or 64 bit from Java program. You can find JVM - 32 bit or 64 bit by using System. Does every class needs to have one non parameterized constructor? Every Class only needs to have one constructor - With parameters or without parameters.
Compiler provides a default non parameterized constructor if no constructors is defined. Difference between throw and throws? We cannot throw multiple exceptions using throw statement but we can declare that a method can throw multiple exceptions using throws and comma separator. Can we use "this" within static method? Even though "this" would mean a reference to current object id the method gets called using object reference but "this" would mean an ambiguity if the same static method gets called using Class name.
Similarity and Difference between static block and static method? Both belong to the class as a whole and not to the individual objects. Static methods are explicitly called for execution whereas Static block gets executed when the Class gets loaded by the JVM. What are the platforms supported by Java Programming Language? How Java provide high Performance?
Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java bytecode into instructions that can be sent directly to the processor. What is IDE? List few Java IDE? What is an Object?
Object is a run time entity whose state is stored in fields and behavior is shown via methods. Methods operate on an object's internal state and serve as the primary mechanism for object-to-object communication. What is a Class? A class is a blue print or Mold using which individual objects are created. A class can contain fields and methods to describe the behavior of an object. According to Java Operator precedence, which operator is considered to be with highest precedence?
Postfix operators i. What data type Variable can be used in a switch statement? Variables used in a switch statement can only be a byte, short, int, or char. What are the sub classes of Exception class? The Exception class has two main subclasses: How finally used under Exception Handling? The finally keyword is used to create a block of code that follows a try block. A finally block of code always executes, whether or not an exception has occurred.
What things should be kept in mind while creating your own exceptions in Java? All exceptions must be a child of Throwable. If you want to write a checked exception that is automatically enforced by the Handle or Declare Rule, you need to extend the Exception class. You want to write a runtime exception, you need to extend the RuntimeException class. What is Comparable Interface? It is used to sort collections and arrays of objects using the collections.
The objects of the class implementing the Comparable interface can be ordered. Explain Set Interface? It is a collection of element which cannot contain duplicate elements.
The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited. What are use cases? It is part of the analysis of a program and describes a situation that a program might encounter and what behavior the program should exhibit in that circumstance. Which Java operator is right associative?
What is the difference between a break statement and a continue statement? Break statement results in the termination of the statement to which it applies switch, for, do, or while. A continue statement is used to end the current loop iteration and return control to the loop statement. What is the purpose of the System class? The purpose of the System class is to provide access to system resources. Variable of the boolean type is automatically initialized as?
The default value of the boolean type is false.
Can try statements be nested? What will happen if static modifier is removed from the signature of the main method? Program throws "NoSuchMethodError" error at runtime.
What is the Locale class? The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region. Define Network Programming? It refers to writing programs that execute across multiple devices computers , in which the devices are all connected to each other using a network.
What are the advantages and Disadvantages of Sockets? Sockets are flexible and sufficient. Efficient socket based programming can be easily implemented for general communications. It cause low network traffic. Socket based communications allows only to send packets of raw data between applications. Both the client-side and server-side have to provide mechanisms to make the data useful in any way. What environment variables do I need to set on my machine in order to be able to run Java programs?
What is Externalizable interface? Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism. What is the difference between the size and capacity of a Vector? The size is the number of elements actually stored in the vector, while capacity is the maximum number of elements it can store at a given instance of time. What is an enum or enumeration?
An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It allows sequential access to all the elements stored in the collection. What is constructor chaining and how is it achieved in Java?
A child object constructor always first needs to construct its parent. In Java it is done via an implicit call to the no-args constructor as the first statement. What is the best practice configuration usage for files - pom.
The best practice guideline between settings. Why Java provides default constructor? At the beginning of an object's life, the Java virtual machine JVM allocates memory on the heap to accommodate the object's instance variables. When that memory is first allocated, however, the data it contains is unpredictable.
If the memory were used as is, the behavior of the object would also be unpredictable. To guard against such a scenario, Java makes certain that memory is initialized, at least to predictable default values before it is used by any code. In a case where there are no instance variables what does the default constructor initialize? Java expects the superclass Object Class constructor to be called while creation of any object.
So super constructor is called in case there are no instance variables to initialize. How can I change the default location of the generated jar when I command "mvn package"?
We can change this by configuring the outputDirectory of maven-jar-plugin. What is Maven's order of inheritance? CLI parameters. What is a Mojo? A mojo is a Maven plain Old Java Object. Each mojo is an executable goal in Maven, and a plugin is a distribution of one or more related mojos. How do I determine which POM contains missing transitive dependency? Difference between Encapsulation and Data Hiding? Data Hiding is a broader concept. Difference between Abstraction and Implementation hiding?
Implementation Hiding is a broader concept. Abstraction is a way of implementation hiding in OOP's. What are the features of encapsulation? Combine the data of our application and its manipulation at one place. Encapsulation Allow the state of an object to be accessed and modified through behaviors. Reduce the coupling of modules and increase the cohesion inside them.
What are the examples of Abstraction in Java? What are different ways to create String Object? If found, it just returns the reference to that String object else it creates a new String object with given value and stores it in the String pool.
We can use intern method to store the String object into String pool or return the reference if there is already a String with equal value present in the pool. Write a method to check if input String is Palindrome? First, you need to find the PID of your process, which you can find by using the "ps" command as shown in the previous question. Alternatively, you can also use the prstat command as shown here. These are parameters to specify heap size in Java.
The -Xms defines the size of the heap when JVM starts up and -Xmx is used to specify the maximum heap size for Java application i. You install JRE to run Java application e. Applet or Core Java application or Web server like Tomcat. There is some threshold set if a code runs more than the threshold it becomes the candidate of just in time compilation by JIT.
There are many ways to take the heap dump of a Java process e. Tomcat, but most common is by using tools available in JDK e. Here is the command you can use to take the heap dump of Java process: Remember, you also need PID of Java process which you can find by using "ps" and "grep" command as discussed in the first question. You can see Java Performance Companion by Charlie Hunt to learn more about taking and analyzing heap dump in Java to find memory leak and other memory related errors.