subiecte.info Personal Growth JAVA LANGUAGE INTERVIEW QUESTIONS AND ANSWERS FOR FRESHERS PDF

Java language interview questions and answers for freshers pdf

Saturday, June 1, 2019 admin Comments(0)

Java Interview Questions And Answers Pdf Yes, We can execute A native method is a method that is applied in a language other than Java. 5) Difference between method overloading and method overriding in java? . .. 9. 6) Difference between . Core java Interview questions on Coding Standards. ) List out benefits of object oriented programming language?. India's No.1 Job Portal for freshers - subiecte.info · Register Free . Java Interview Questions updated on Apr 1. Java is a platform independent language. 3. What do .. Answer: Only 2 objects are created, c1 and c3.


Author: ROBERTO SEPTELKA
Language: English, Spanish, Dutch
Country: Malaysia
Genre: Environment
Pages: 401
Published (Last): 03.05.2016
ISBN: 740-2-76116-504-1
ePub File Size: 29.86 MB
PDF File Size: 12.52 MB
Distribution: Free* [*Regsitration Required]
Downloads: 50635
Uploaded by: LUCIO

Java Interview Questions Why is Java called the Platform Independent Programming Language? .. Both implementations share some common. Dear readers, these Java Interview Questions have been designed especially to get you acquainted with the subject and later they continue based on further discussion and what you answer − What are the supported platforms by Java Programming Language? If you are fresher then interviewer does not expect you. Get Interview Questions and answers on JAVA for freshers with pdf, learn Answer- The features of this programming language are as follows-.

This raises compile time error if we try to handle checked exceptions when there is no possibility of causing exception. This propogation continues till it finds an appropriate exception handler ,if it finds handler it would be handled otherwise program terminates Abruptly. Java Interview Questions And Answers What are checked exceptions? Civil Interview Questions. If there is exception thrown in try block finally block executes immediately after catch block.

What are the states associated in the thread? Synchronization is the mechanism that ensures that only one thread is accessed the resources at a time.

Applet is a dynamic and interactive program that runs inside a web page displayed by a java capable browser. What is the lifecycle of an applet? How do you set security in applets? What is a layout manager and what are different types of layout managers available in java AWT?

Pdf answers and java language for questions interview freshers

A layout manager is an object that is used to organize components in a container. This API consists of a set of classes and interfaces to enable programs to write pure Java Database applications. Stored procedure is a group of SQL statements that forms a logical unit and performs a particular task.

Stored Procedures are used to encapsulate a set of operations or queries to execute on database. The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface GUI widgets. Why there are no global variables in Java? Global variables are globally accessible. Java does not support globally accessible variables due to following reasons: What are Encapsulation, Inheritance and Polymorphism?

Encapsulation is the mechanism that binds together code and data it manipulates and keeps both safe from outside interference and misuse. Inheritance is the process by which one object acquires the properties of another object.

Polymorphism is the feature that allows one interface to be used for general class actions. What is the use of bin and lib in JDK?

Bin contains all tools such as javac, appletviewer, awt tool, etc. What is method overloading and method overriding? Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding: When a method in a class having the same method name with same arguments is said to be method overriding. What is the difference between this and super?

It is very difficult to remember a set of numbers IP address to connect to the Internet. It maps one particular IP address to a string of characters. For example, www. URL has four components: Remote Method Invocation RMI allows java object that executes on one machine and to invoke the method of a Java object to execute on another machine.

The steps involved in developing an RMI object are: RMI architecture consists of four layers and each layer performs specific functions: A Java Bean is a software component that has been designed to be reusable in a variety of different environments. Checked exception are those which the Java compiler forces you to catch. IOException are checked Exceptions. Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc.

These are not checked by the compiler at compile time. What is the difference between error and an exception? An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. These JVM errors and you can not repair them at runtime. While exceptions are conditions that occur because of bad input etc. FileNotFoundException will be thrown if the specified file does not exist. Or a NullPointerException will take place if you try using a null reference.

In most of the cases it is possible to recover from an exception probably by giving user a feedback for entering proper values etc.

Java Interview Questions

What is the purpose of finalization? The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected. For example, closing a opened file, closing a opened database Connection. What is the difference between yielding and sleeping? When a task invokes its yield method, it returns to the ready state. When a task invokes its sleep method, it returns to the waiting state.

What is the difference between preemptive scheduling and time slicing? Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks.

The scheduler then determines which task should execute next, based on priority and other factors. What is mutable object and immutable object? If a object value is changeable then we can call it as Mutable object.

Answers and for java questions interview freshers pdf language

What is the purpose of Void class? The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.

Really, just a very fast compiler… In this incarnation, pretty much a one-pass compiler — no offline computations. If all the methods of a inner class is static then it is a nested class.

What are different types of access modifiers? Any thing declared as public can be accessed from anywhere. Any thing declared as protected can be accessed by classes in the same package and subclasses in the other packages. Can be accessed only to classes in the same package. A constructor is a special method whose task is to initialize the object of its class. It is special because its name is the same as the class name.

They do not have return types, not even void and therefore they cannot return values. They cannot be inherited, though a derived class can call the base class constructor. Constructor is invoked whenever an object of its associated class is created. What is an Iterator? The Iterator interface is used to step through the elements of a Collection. Iterators let you process each element of a Collection. Iterators are a generic way to go through all the elements of a Collection no matter how it is organized.

Iterator is an Interface implemented a different way for every Collection. The List interface provides support for ordered collections of objects. Lists may contain duplicate elements. A memory leak is where an unreferenced object that will never be used again still hangs around in memory and doesnt get garbage collected. 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.

What is the difference between a constructor and a method? A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.

A method is an ordinary member function of a class. It has its own name, a return type which may be void , and is invoked using the dot operator. What will happen to the Exception object after exception handling? Difference between static and dynamic class loading. Static class loading: The process of loading a class using new operator is called static class loading.

Dynamic class loading: The process of loading a class at runtime is called dynamic class loading. Dynamic class loading can be done by using Class. The EJBs can be used to incorporate business logic in a web-centric application.

In Enterprise Application Integration applications, EJBs can be used to house processing and mapping between different applications. It contains Presentation logic and business logic of a web application. What is the purpose of apache tomcat? Apache server is a standalone server that is used to test servlets and create JSP pages.

It is free and open source that is integrated in the Apache web server. It is fast, reliable server to configure the applications but it is hard to install. It is a servlet container that includes tools to configure and manage the server to run the applications. It can also be configured by editing XML configuration files. Pragma is used inside the servlets in the header with a certain value.

The value is of no-cache that tells that a servlets is acting as a proxy and it has to forward request. Pragma directives allow the compiler to use machine and operating system features while keeping the overall functionality with the Java language.

These are different for different compilers. Briefly explain daemon thread. Daemon thread is a low priority thread which runs in the background performs garbage collection operation for the java runtime system. A native method is a method that is implemented in a language other than Java. There are two types of platforms, software-based and hardware-based. Java provides the software-based platform. The bytecode. Java compiler converts the Java programs into the class file Byte Code which is the intermediate language between source code and machine code.

This bytecode is not platform specific and can be executed on any computer. Classloader is a subsystem of JVM which is used to load class files. Whenever we run the java program, it is loaded first by the classloader. There are three built-in classloaders in Java.

Yes, Java allows to save our java file by. The local variables are not initialized to any default value, neither primitives nor object references. In Java, access specifiers are the keywords which are used to define the access scope of the method, class, or a variable.

In Java, there are four access specifiers given below. The methods or variables defined as static are shared among all the objects of the class.

The static is the part of the class and not of the object. The static variables are stored in the class area, and we do not need to create the object to access such variables.

Therefore, static is used in the case, where we need to define variables or methods which are common to all the objects of the class. For example, In the class simulating the collection of the students in a college, the name of the college is the common attribute to all the students.

Therefore, the college name will be defined as static. In the first case, 10 and 20 are treated as numbers and added to be Now, their sum 30 is treated as the string and concatenated with the string Javatpoint. Therefore, the output will be 30Javatpoint. In the second case, the string Javatpoint is concatenated with 10 to be the string Javatpoint10 which will then be concatenated with 20 to be Javatpoint In the first case, The numbers 10 and 20 will be multiplied first and then the result is treated as the string and concatenated with the string Javatpoint to produce the output Javatpoint.

In the second case, The numbers 10 and 20 will be multiplied first to be because the precedence of the multiplication is higher than addition. The result will be treated as the string and concatenated with the string Javatpoint to produce the output as Javatpoint The above code will give the compile-time error because the for loop demands a boolean value in the second part and we are providing an integer value, i. However, they have been categorized in many sections such as constructor interview questions, static interview questions, Inheritance Interview questions, Abstraction interview question, Polymorphism interview questions, etc.

It is a programming paradigm based on objects having data and methods defined in the class to which it belongs.

Top 75 Java Interview Questions You Must Prepare In 2019

Object-oriented paradigm aims to incorporate the advantages of modularity and reusability. Objects are the instances of classes which interacts with one another to design applications and programs. There are the following features of the object-oriented paradigm. The Object is the real-time entity having some state and behavior. In Java, Object is an instance of the class having the instance variables as the state of the object and the methods as the behavior of the object.

The object of a class can be created by using the new keyword. There are the following basic differences between the object-oriented language and object-based language. The constructor can be defined as the special type of method that is used to initialize the state of an object.

It is invoked when the class is instantiated, and the memory is allocated for the object. Every time, an object is created using the new keyword, the default constructor of the class is called. The name of the constructor must be similar to the class name.

The constructor must not have an explicit return type. The purpose of the default constructor is to assign the default value to the objects. The java compiler creates a default constructor implicitly if there is no constructor in the class. In the above class, you are not creating any constructor, so compiler provides you a default constructor. Here 0 and null values are provided by default constructor. More Details. Yes, the constructors can be overloaded by changing the number of arguments accepted by the constructor or by changing the data type of the parameters.

Consider the following example. In the above program, The constructor Test is overloaded with another constructor. In the first call to the constructor, The constructor with one argument is called, and i will be initialized with the value However, In the second call to the constructor, The constructor with the 2 arguments is called, and i will be initialized with the value There is no copy constructor in java.

In this example, we are going to copy the values of one object into another using java constructor. Here, the data type of the variables a and b, i. The output of the program is 0 because the variable i is initialized to 0 internally.

As we know that a default constructor is invoked implicitly if there is no constructor in the class, the variable i is initialized to 0 since there is no constructor in the class. There is a compiler error in the program because there is a call to the default constructor in the main method which is not present in the class.

However, there is only one parameterized constructor in the class Test. Therefore, no default constructor is invoked by the constructor implicitly. The static variable is used to refer to the common property of all objects that is not unique for each object , e. Static variable gets memory only once in the class area at the time of class loading.

Using a static variable makes your program more memory efficient it saves memory. Static variable belongs to the class rather than the object. 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.

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.

Latest 60 Java Interview Questions And Answers Pdf

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.