soundofheaven.info Fitness JAVATPOINT INTERVIEW QUESTIONS PDF

Javatpoint interview questions pdf

Monday, June 17, 2019 admin Comments(0)

3/30/ Core Java Interview Questions | OOPs interview questions javatpoint soundofheaven.info 1/ Core Java. Dear readers, these Java Interview Questions have been designed especially to get you acquainted with the nature of questions you may encounter during your. Core Java Interview Questions _ OOPs Interview Questions - Javatpoint - Download as PDF File .pdf), Text File .txt) or read online. IQ.


Author: DARCEL SENSENIG
Language: English, Spanish, Indonesian
Country: Monaco
Genre: Business & Career
Pages: 382
Published (Last): 12.10.2015
ISBN: 894-6-72865-529-8
ePub File Size: 16.39 MB
PDF File Size: 11.77 MB
Distribution: Free* [*Regsitration Required]
Downloads: 42301
Uploaded by: JACOB

There is the list of core java interview questions. If there is any core java interview question that has been asked to you, kindly post it in the ask question. Interview Questions for beginners and professionals with a list of top There are given interview questions and answers on + topics such as HR, C, C++. HR Interview Questions for beginners and professionals with a list of top frequently asked job questions with answers, hr interview questions with java,. net, php.

Exceptions are caught by handlers positioned along the thread's method invocation stack. Same as personal life, even professional life needs more experience for more patience. Possible Answer 2 Yes, as part of growing up. A member has package or default accessibility when no accessibility modifier is specified. Java is interpreted that is why it is platform independent. These methods give you a control over the serialization mechanism. I am ensuring you that I will put all my efforts for the good progress of the organization.

UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF uses bit and larger bit patterns. These are classes that allow primitive types to be accessed as objects.

Integer, Character, Double, Boolean etc. Swing package. The paint method supports painting via a Graphics object. The repaint method is used to cause paint to be invoked by the AWT painting thread. It is used to create objects that provide access to the files and directories of a local file system.

The Class class is used to obtain information about an object's design and java.

Class class instance represent classes, interfaces in a running Java application. A static variable is associated with the class as a whole rather than with specific instances of a class.

Non-static variables take on unique values with each object instance. Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects.

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. Sub class inherits all the public and protected methods and the implementation. It also inherits all the default modifier methods and their implementation. If there is a button instance called b1, you may add menu short cut by calling b1. AWT components are heavy-weight, whereas Swing components are lightweight.

Heavy weight components depend on the local windowing toolkit. For example, java. Button is a heavy weight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button. 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. Yes, since inheritance inherits everything from the super class and interface, it may make the subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading in some situation.

When copying elements between different arrays, if the source or destination arguments are not arrays or their types are not compatible, an ArrayStoreException will be thrown. The code sleep ; puts thread aside for exactly two seconds. The code wait , causes a wait of up to two 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.

The ArithmeticException is thrown when integer is divided by zero or taking the remainder of a number by zero. It is never thrown in floating-point operations. A transient variable is a variable that may not be serialized during Serialization and which is initialized by its default value during de-serialization,. Synchronization is the capability to control the access of multiple threads to shared resources. The Collections API is a set of classes and interfaces that support operations on collections of objects.

Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

Panel is the immediate superclass. A panel provides space in which an application can attach any other component, including other panels. A break statement results in the termination of the statement to which it applies switch, for, do, or while.

Interview questions pdf javatpoint

A continue statement is used to end the current loop iteration and return control to the loop statement. When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting. The garbage collector invokes an object's finalize method when it detects that the object has become unreachable. A class loader is an object that is responsible for loading classes. The class ClassLoader is an abstract class. An abstract class can have instance methods that implement a default behavior.

An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. No, a top level class can not be private or protected. It can have either "public" or no modifier.

Interview questions pdf javatpoint

We can pass them around as method parameters where a method expects an object. It also provides utility methods. An error is an irrecoverable condition occurring at runtime.

201 Core Java Interview Questions _ OOPs Interview Questions

Such as OutOfMemory error. Exceptions are conditions that occur because of bad input etc. FileNotFoundException will be thrown if the specified file does not exist. It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block. The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region. Synchronized methods are methods that are used to control access to an object.

A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

Runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. In this process, an overridden method is called through the reference variable of a superclass. Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run-time.

ArrayList can grow dynamically and provides more powerful insertion and search mechanisms than arrays.

201 Core Java Interview Questions _ OOPs Interview Questions - Javatpoint

Deletion in linked list is fast because it involves only updating the next pointer in the node before the deleted node and updating the previous pointer in the node after the deleted node. If you need to frequently add and remove elements from the middle of the list and only access the list elements sequentially, then LinkedList should be used.

If you need to support random access, without inserting or removing elements from any place other than the end, then ArrayList should be used. It is a collection returned by the values method of the Map Interface, It contains all the objects present as values in the map. The dot operator. It is also used to access classes and sub-packages from a package.

Private constructor is used if you do not want other classes to instantiate the object and to prevent subclassing. The main thread is created automatically and it begins to execute immediately when a program starts. It ia thread from which all other child threads originate. It is a simple drawing surface which are used for painting images or to perform other graphical operations.

It refers to writing programs that execute across multiple devices computers , in which the devices are all connected to each other using a network. Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server. 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. ServerSocket class is used by server applications to obtain a port and listen for client requests.

Socket class represents the socket that both the client and server use to communicate with each other. Generics provide compile-time type safety that allows programmers to catch invalid types at compile time.

Because the object is not required to call the static method. If we make the main method non-static, JVM will have to create its object first and then call main method which will lead to the extra memory allocation.

No, we can't override static methods. Static block is used to initialize the static data member. It is executed before the main method, at the time of classloading. Ans Yes, one of the ways to execute the program without the main method is using static block.

As we know that the static context method, block, or variable belongs to the class, not the object. Since Constructors are invoked only when the object is created, there is no sense to make the constructors static. However, if you try to do so, the compiler will show the compiler error. In Java, if we make the abstract methods static, It will become the part of the class, and we can directly call it which is unnecessary.

Calling an undefined method is completely useless therefore it is not allowed. Yes, we can declare static variables and methods in an abstract method. As we know that there is no requirement to make the object to access the static context, therefore, we can access the static context declared inside the abstract class by using the name of the abstract class.

The this keyword is a reference variable that refers to the current object. There are the various uses of this keyword in Java. It can be used to refer to current class properties such as instance methods, variable, constructors, etc. It can also be passed as an argument into the methods or constructors.

It can also be returned from the method as the current class instance. No, this cannot be assigned to any value because it always points to the current class object and this is the final reference in Java.

Interview Questions and Answers - javatpoint

However, if we try to do so, the compiler error will be shown. Yes, It is possible to use this keyword to refer static members because this is just a reference variable which refers to the current class object.

However, as we know that, it is unnecessary to access static variables through objects, therefore, it is not the best practice to use this to refer static members.

Output 10 55 How can constructor chaining be done using this keyword? Constructor chaining enables us to call one constructor from another constructor of the class with respect to the current class object. We can use this keyword to perform constructor chaining within the same class.

Consider the following example which illustrates how can we use this keyword to achieve constructor chaining.

As we know, that this refers to the current class object, therefore, it must be similar to the current class object. However, there can be two main advantages of passing this into a method instead of the current class object.

Inheritance is a mechanism by which one object acquires all the properties and behavior of another object of another class. It is used for Code Reusability and Method Overriding. The idea behind inheritance in Java is that you can create new classes that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of the parent class. Moreover, you can add new methods and fields in your current class also. Inheritance represents the IS-A relationship which is also known as a parent-child relationship.

To reduce the complexity and simplify the language, multiple inheritance is not supported in java. Consider a scenario where A, B, and C are three classes.

The C class inherits A and B classes. If A and B classes have the same method and you call it from child class object, there will be ambiguity to call the method of A or B class. Since the compile-time errors are better than runtime errors, Java renders compile-time error if you inherit 2 classes. So whether you have the same method or different, there will be a compile time error. Aggregation can be defined as the relationship between two classes where the aggregate class contains a reference to the class it owns.

Aggregation is best described as a has-a relationship. For example, The aggregate class Employee having various fields such as age, name, and salary also contains an object of Address class having various fields such as Address-Line 1, City, State, and pin-code. In other words, we can say that Employee class has an object of Address class. Holding the reference of a class within some other class is known as composition. When an object contains the other object, if the contained object cannot exist without the existence of container object, then it is called composition.

In other words, we can say that composition is the particular case of aggregation which represents a stronger relationship between two objects. A class contains students. A student cannot exist without a class. There exists composition between class and students. Aggregation represents the weak relationship whereas composition represents the strong relationship. For example, the bike has an indicator aggregation , but the bike has an engine composition. The pointer is a variable that refers to the memory address.

They are not used in Java because they are unsafe unsecured and complex to understand. The super keyword in Java is a reference variable that is used to refer to the immediate parent class object. Whenever you create the instance of the subclass, an instance of the parent class is created implicitly which is referred by super reference variable.

The super is called in the class constructor implicitly by the compiler if there is no super or this. The super is implicitly invoked by the compiler if no super or this is included explicitly within the derived class constructor.

Therefore, in this case, The Person class constructor is called first and then the Employee class constructor is called.

The object cloning is used to create the exact copy of an object. The clone method of the Object class is used to clone an object. The java. Cloneable interface must be implemented by the class whose object clone we want to create.

Method overloading is the polymorphism technique which allows us to create multiple methods with the same name but different signature. We can achieve method overloading in two ways.

Interview pdf javatpoint questions

Method overloading increases the readability of the program. Method overloading is performed to figure out the program quickly.

In Java, method overloading is not possible by changing the return type of the program due to avoid the ambiguity.

No, We cannot overload the methods by just applying the static keyword to them number of parameters and types are the same. By Type promotion is method overloading, we mean that one data type can be promoted to another implicitly if no exact matching is found.

As displayed in the above diagram, the byte can be promoted to short, int, long, float or double.

Interview pdf javatpoint questions

The short datatype can be promoted to int, long, float or double. The char datatype can be promoted to int, long, float or double and so on. There are two methods defined with the same name, i. The first method accepts the integer and long type whereas the second method accepts long and the integer type. We can not tell that which method will be called as there is no clear differentiation mentioned between integer literal and long literal.

This is the case of ambiguity. Therefore, the compiler will throw an error. If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding.

It is used for runtime polymorphism and to implement the interface methods. It is because the static method is the part of the class, and it is bound with class whereas instance method is bound with the object, and static gets memory in class area, and instance gets memory in a heap.

No, we cannot override the private methods because the scope of private methods is limited to the class and we cannot access them outside of the class. Yes, we can change the scope of the overridden method in the subclass. Array List does not define the increment size. Vector defines the increment size.

Array List can only use Iterator for traversing an Array List. Except Hashtable, Vector is the only other class which uses both Enumeration and Iterator.

Features Stack Heap Memory Stack memory is used only by one thread of execution. Heap memory is used by all the parts of the application. Objects stored in the heap are globally accessible. Memory management is based on generation associated to each object. Lifetime Exists until the end of execution of the thread.

Heap memory lives from the start till the end of application execution. Usage Stack memory only contains local primitive and reference variables to objects in heap space.

In case you are facing any challenges with these java interview questions, please comment on your problems in the section below. An interface cannot provide any code at all,just the signature.