nissart.info Handbooks Java Interview Questions And Answers For Freshers Pdf Free

JAVA INTERVIEW QUESTIONS AND ANSWERS FOR FRESHERS PDF FREE

Saturday, June 22, 2019


Java Interview Questions And Answers For Freshers Free Download and answers html - Bing shldirect example questions and answers nissart.info FREE. Java Interview Questions And Answers For Freshers Free - [FREE] JAVA questions and answers html - Bing shldirect example questions and answers nissart.info core java interview questions and answers - journaldev - core java and answers on jsp and servlet. fresher interview question contract rates and also to jsp java multiple choice questions with nissart.info - free -.


Java Interview Questions And Answers For Freshers Pdf Free

Author:BRENDA LAUTARET
Language:English, Spanish, Japanese
Country:Chad
Genre:Academic & Education
Pages:355
Published (Last):08.10.2015
ISBN:170-2-50251-949-6
ePub File Size:18.77 MB
PDF File Size:13.42 MB
Distribution:Free* [*Registration Required]
Downloads:30214
Uploaded by: DUSTY

20 Core Java Interview Questions and Answers from. Pdf nissart.info interview questions and answers for freshers & experienced pdf free. I was getting a lot of emails and comments to create java interview questions and answers PDF eBook. It was hard and time taking, but finally, it's done. Technical interview questions and answers section on "Core Java" with explanation 10 Free Java Programing Books for beginners - download, pdf and HTML.

Which method is to get invoked will depend upon the parameters passed. For example in the class below we have two print methods with same name but different parameters. Depending upon the parameters, appropriate one will be called: How can we make copy of a java object? We can use the concept of cloning to create copy of an object. Using clone, we create copies with the actual state of an object. Clone is a method of Cloneable interface and hence, Cloneable interface needs to be implemented for making object copies.

What's the benefit of using inheritance? Key benefit of using inheritance is reusability of code as inheritance enables sub-classes to reuse the code of its super class. Polymorphism Extensibility is another great benefit which allow new functionality to be introduced without effecting existing derived classes.

What's the default access specifier for variables and methods of a class? Default access specifier for variables and method is package protected i. Give an example of use of Pointers in Java class. There are no pointers in Java.

So we can't use concept of pointers in Java. How can we restrict inheritance for a class so that no class can be inherited from it? If we want a class not to be extended further by any class, we can use the keyword Final with the class name. What's the access scope of Protected Access specifier?

When a method or a variable is declared with Protected access specifier, it becomes accessible in the same class,any other class of the same package as well as a sub-class. What's difference between Stack and Queue? Stack and Queue both are used as placeholder for a collection of data. In java, how we can disallow serialization of variables? If we want certain variables of a class not to be serialized, we can use the keyword transient while declaring them.

How can we use primitive data types as objects? Primitive data types like int can be handled as objects by the use of their respective wrapper classes. For example, Integer is a wrapper class for primitive data type int. We can apply different methods to a wrapper class, just like any other object. Which types of exceptions are caught at compile time?

Checked exceptions can be caught at the time of program compilation. Checked exceptions must be handled by using try catch block in the code in order to successfully compile the code.

Describe different states of a thread. A thread in Java can be in either of the following states: When a thread is created, it's in Ready state.

A thread currently being executed is in running state. A thread waiting for another thread to free certain resources is in waiting state. A thread which has gone dead after execution is in dead state. Can we use a default constructor of a class even if an explicit constructor is defined? Java provides a default no argument constructor if no explicit constructor is defined in a Java class.

But if an explicit constructor has been defined, default constructor can't be invoked and developer can use only those constructors which are defined in the class. Can we override a method by using same method name and arguments but different return types? The basic condition of method overriding is that method name, arguments as well as return type must be exactly same as is that of the method being overridden.

Hence using a different return type doesn't override a method. What will be the output of following piece of code? Hence it's output will be 4. A person says that he compiled a java class successfully without even having a main method in it? Is it possible? It can't be run though. Can we call a non-static method from inside a static method? Non-Static methods are owned by objects of a class and have object level scope and in order to call the non-Static methods from a static block like from a static main method , an object of the class needs to be created first.

Then using object reference, these methods can be invoked. What are the two environment variables that must be set in order to run any Java programs? Java programs can be executed in a machine only once following two environment variables have been properly set: Can variables be used in Java without initialization? In Java, if a variable is used in a code without prior initialization by a valid value, program doesn't compile and gives an error as no default value is assigned to variables in Java.

Can a class in Java be inherited from more than one class? In Java, a class can be derived from only one class and not from multiple classes. Multiple inheritances is not supported by Java. Can a constructor have different name than a Class name in Java?

Social Icons

Constructor in Java must have same name as the class name and if the name is different, it doesn't act as a constructor and compiler thinks of it as a normal method. What will be the output of Round 3. Round 3. Can we use goto in Java to go to a particular line? In Java, there is not goto keyword and java doesn't support this feature of going to a particular labeled line. Can a dead thread be started again? In java, a thread which is in dead state can't be started again.

There is no way to restart a dead thread. Is the following class declaration correct? The above class declaration is incorrect as an abstract class can't be declared as Final.

Is JDK required on each machine to run a Java program? Only JRE is required. In the following example, equals returns true as the two string objects have same values. Is it possible to define a method in Java class but provide it's implementation in the code of another language like C? Yes, we can do this by use of native methods. In case of native method based development, we define public static methods in our Java class without its implementation and then implementation is done in another language like C separately.

How are destructors defined in Java? In Java, there are no destructors defined in the class as there is no need to do so. Java has its own garbage collection mechanism which does the job automatically by destroying the objects when no longer referenced. Can a variable be local and static at the same time?

No a variable can't be static as well as local at the same time. Defining a local variable as static gives compilation error. Can we have static methods in an Interface? Static methods can't be overridden in any class while any methods in an interface are by default abstract and are supposed to be implemented in the classes being implementing the interface. So it makes no sense to have static methods in an interface in Java.

In a class implementing an interface, can we change the value of any variable defined in the interface? No, we can't change the value of any variable of an interface in the implementing class as all variables defined in the interface are by default public, static and Final and final variables are like constants which can't be changed later.

Is it correct to say that due to garbage collection feature in Java, a java program never goes out of memory? Even though automatic garbage collection is provided by Java, it doesn't ensure that a Java program will not go out of memory as there is a possibility that creation of Java objects is being done at a faster pace compared to garbage collection resulting in filling of all the available memory resources.

So, garbage collection helps in reducing the chances of a program going out of memory but it doesn't ensure that. Can we have any other return type than void for main method? No, Java class main method can have only void return type for the program to get successfully executed. Nonetheless , if you absolutely must return a value to at the completion of main method , you can use System.

I want to re-reach and use an object once it has been garbage collected. How it's possible? Once an object has been destroyed by garbage collector, it no longer exists on the heap and it can't be accessed again. There is no way to reference it again. In Java thread programming, which method is a must implementation for all threads?

Run is a method of Runnable interface that must be implemented by all threads. I want to control database connections in my program and want that only one thread should be able to make database connection at a time. How can I implement this logic? This can be implemented by use of the concept of synchronization.

Database related code can be placed in a method which hs synchronized keyword so that only one thread can access it at a time.

How can an exception be thrown manually by a programmer? In order to throw an exception in a block of code manually, throw keyword is used. Then this exception is caught and handled in the catch block. I want my class to be developed in such a way that no other class even derived class can create its objects. How can I do so? If we declare the constructor of a class as private, it will not be accessible by any other class and hence, no other class will be able to instantiate it and formation of its object will be limited to itself only.

How objects are stored in Java? In java, each object when created gets a memory space from a heap. When an object is destroyed by a garbage collector, the space allocated to it from the heap is re-allocated to the heap and becomes available for any new objects. How can we find the actual size of an object on the heap? In java, there is no way to find out the exact size of an object on the heap. Which of the following classes will have more memory allocated?

Class A: Three methods, four variables, no object Class B: Five methods, three variables, no object Ans: Memory isn't allocated before creation of objects.

Top 50+ Core Java Interview Questions and Answers

Since for both classes, there are no objects created so no memory is allocated on heap for any class. What happens if an exception is not handled in a program?

If an exception is not handled in a program using try catch blocks, program gets aborted and no statement executes after the statement which caused exception throwing. I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor's body? If a class has multiple constructors, it's possible to call one constructor from the body of another one using this.

What's meant by anonymous class? An anonymous class is a class defined without any name in a single line of code using new keyword.

For example, in below code we have defined an anonymous class in one line of code: Is there a way to increase the size of an array after its declaration? Arrays are static and once we have specified its size, we can't change it. If we want to use such collections where we may require a change of size no of items , we should prefer vector over array. If an application has multiple classes in it, is it okay to have a main method in more than one class?

If there is main method in more than one classes in a java application, it won't cause any issue as entry point for any application will be a specific class and code will start from the main method of that particular class only. I want to persist data of objects for later use.

What's the best approach to do so? The best way to persist data for future use is to use the concept of serialization. What is a Local class in Java? In Java, if we define a new class inside a particular block, it's called a local class. Such a class has local scope and isn't usable outside the block where its defined.

String and StringBuffer both represent String objects. Can we compare String and StringBuffer in Java? Although String and StringBuffer both represent String objects, we can't compare them with each other and if we try to compare them, we get an error.

Which API is provided by Java for operations on set of objects? Java provides a Collection API which provides many useful methods which can be applied on a set of objects. Can we cast any other type to Boolean Type with type casting?

No, we can neither cast any other primitive type to Boolean data type nor can cast Boolean data type to any other primitive data type. Can we use different return types for methods when overridden? The basic requirement of method overriding in Java is that the overridden method should have same name, and parameters. But a method can be overridden with a different return type as long as the new return type extends the original.

For example , method is returning a reference type. What's the base class of all exception classes?

Job Interviews Questions and Answers PDF Free Download

In Java, Java. Throwable is the super class of all exception classes and all exception classes are derived from this base class. What's the order of call of constructors in inheritiance? In case of inheritance, when a new object of a derived class is created, first the constructor of the super class is invoked and then the constructor of the derived class is invoked.

Quick Sort algorithm is one of the most used and popular algorithms in any programming language What is Armstrong Number?

In an Armstrong Number, the sum of power of individual digits is equal How does Selection Sort work? Selection Sort implements a simple sorting algorithm as follows SAP Tutorials. Net C CodeIgniter. Blockchain Go Programming Reviews. Tableau Talend ZooKeeper. Artificial Intelligence Keras. R Programming TensorFlow. Data Science PyTorch. Top Java Interview Questions with Answers. Java Tutorials. What is a Prime Number?

A prime number is a number that is only divisible by 1 or itself. What is Palindrome Number? A Palindrome Number is a number that even when reversed is same as There are many tools available for Java management.

What is the Vector class? Answer: The term Vector class provides the ability to implement a growable array of objects. What is a native method? Answer: A native method is a method that is applied in a language other than Java. What value does read Line return when it has reached the end of a file? Answer: The readLine method returns null, when it has reached the end of a file. What is clipping? Clipping is the process of confining paint operations to a limited area or shape.

Can a for statement loop indefinitely? Answer: Yes, a for statement can loop indefinitely. For example, consider the following:for ;;. Explain Java Coding standards for Methods? Answer: 1 Method names should start with small letters. Explain Java Coding Standards for Constants? Answer: Constants in java are created using static and final keywords.

What is synchronization and why is it important? Answer: The term synchronization is the ability to control the access of multiple threads to shared resources.

This often leads to major errors. Explain Java Coding Standards for variables? Answer: 1 Variable names should start with small letters. Ex : string,value,empName,empSalary Name three Component subclasses that support painting? Why Java is not pure Object Oriented language? Answer: Java support primitive types such as int, byte, short, long etc that why it is not said to be pure object oriented language.

What are access modifiers? Answer: Java provides three access controlssuch as public, private and protected access modifier. Can we overload main method? Answer: Yes, we can overload the main methodwith syntax as public static void main String args[]. What is method in java?

You might also like: IBM AND THE HOLOCAUST PDF

Answer: It contains the executable body that can be applied to the specific object of the class. Method includes method name, parameters or arguments and return type and a body of executable code. Separate with commas when we have multiple arguments. Can we use catch statement for checked exceptions? This raises compile time error if we try to handle checked exceptions when there is Explain a situation where finally block will not be executed?Ans: Join method is used to join one thread with the end of the currently running thread.

Memory isn't allocated before creation of objects. Even though automatic garbage collection is provided by Java, it doesn't ensure that a Java program will not go out of memory as there is a possibility that creation of Java objects is being done at a faster pace compared to garbage collection resulting in filling of all the available memory resources.

Define JSON? It is mostly used in synchronization.