lesforgesdessalles.info Environment JAVA INTERVIEW QUESTIONS AND ANSWERS FOR FRESHERS PDF FREE

Java interview questions and answers for freshers pdf free

Wednesday, March 6, 2019 admin Comments(0)

20 Core Java Interview Questions and Answers from. Pdf lesforgesdessalles.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.


Author: SHARI PUSHCAR
Language: English, Spanish, German
Country: Thailand
Genre: Science & Research
Pages: 267
Published (Last): 20.04.2016
ISBN: 733-1-20140-801-8
ePub File Size: 30.43 MB
PDF File Size: 15.48 MB
Distribution: Free* [*Regsitration Required]
Downloads: 22348
Uploaded by: LORINA

Java Interview Questions And Answers For Freshers Free Download and answers html - Bing shldirect example questions and answers lesforgesdessalles.info FREE. Java Interview Questions And Answers For Freshers Free - [FREE] JAVA questions and answers html - Bing shldirect example questions and answers lesforgesdessalles.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 lesforgesdessalles.info - free -.

Thanks sir. A thread currently being executed is in running state. What is Final Keyword in Java? Multi threaded applications can be developed in Java by using any of the following two methodologies: Can main method in Java can return any data? What are the two environment variables that must be set in order to run any Java programs?

In below example, reference str refers to a string object having value "Value one". What's the difference between an array and Vector?

An array groups data of same primitive type and is static in nature while vectors are dynamic in nature and can hold data of different data types. What is multi-threading?

Multi threading is a programming concept to run multiple tasks in a concurrent manner within a single program. Threads share same process stack and running in parallel.

It helps in performance improvement of any program. Why Runnable Interface is used in Java? Runnable interface is used in java for implementing multi threaded applications. Runnable interface is implemented by a class to support multi threading. What are the two ways of implementing multi-threading in Java? Multi threaded applications can be developed in Java by using any of the following two methodologies: By using Java.

Runnable Interface. Classes implement this interface to enable multi threading. There is a Run method in this interface which is implemented. By writing a class that extend Java. Thread class. When a lot of changes are required in data, which one should be a preference to be used? String or StringBuffer? Since StringBuffers are dynamic in nature and we can change the values of StringBuffer objects unlike String which is immutable, it's always a good choice to use StringBuffer when data is being changed too much.

If we use String in such a case, for every data change a new String object will be created which will be an extra overhead. What's the purpose of using Break in each case of Switch Statement? Break is used after each case except the last one in a switch so that code breaks after the valid case and doesn't flow in the proceeding cases too. If break isn't used after each case, all cases after the valid case also get executed resulting in wrong results.

How garbage collection is done in Java? In java, when an object is not referenced any more, garbage collection takes place and the object is destroyed automatically.

For automatic garbage collection java calls either System. How we can execute any code even before main method? If we want to execute any statements before even creation of objects at load time of class, we can use a static block of code in the class.

Any statements inside this static block of code will get executed once at the time of loading the class even before creation of objects in the main method.

Answers and pdf freshers questions interview java free for

Can a class be a super class and a sub-class at the same time? If there is a hierarchy of inheritance used, a class can be a super class for another class and a sub-class for another one at the same time.

In the example below, continent class is sub-class of world class and it's super class of country class. How objects of a class are created if no constructor is defined in the class? Even if no explicit constructor is defined in a java class, objects get created successfully as a default constructor is implicitly used for object creation.

This constructor has no parameters. In multi-threading how can we ensure that a resource isn't used by multiple threads simultaneously? In multi-threading, access to the resources which are shared among multiple threads can be controlled by using the concept of synchronization. Using synchronized keyword, we can ensure that only one thread can use shared resource at a time and others can get control of the resource only once it has become free from the other one using it.

Can we call the constructor of a class more than once for an object? Constructor is called automatically when we create an object using new keyword. It's called only once for an object at the time of object creation and hence, we can't invoke the constructor again for an object after its creation. There are two classes named classA and classB. Both classes are in the same package. Can a private member of classA can be accessed by an object of classB?

Private members of a class aren't accessible outside the scope of that class and any other class even in the same package can't access them. Can we have two methods in a class with the same name?

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.

Top 100 Java Interview Questions with Answers

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?

Interview pdf for answers free java and freshers questions

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.

And questions for free pdf freshers java interview answers

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? 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?

Top Java Interview Questions with Answers

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?

Java Interview Questions and Answers PDF eBook Free Download (250+ Questions, 60 Pages)

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.

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? Leave this field empty. I would love to connect with you personally. You are here: Comments please send me ebook link. Subscription link is not working for me. I want core java interview question ebook.

Please send me the ebook for Java interview questions. I am now fresher So i need java interview questions and answers. So please forward me. Thank you. Please check your emails, you must have got the link to download. Please subscribe to the email newsletter and you will receive it in the email. Link to Subscribe and get the eBook in the email has been added at the end of post.

Please send me the ebook for Java interview questions pdf. Please send me java interview questions ebook thanx. Please send me the java interview questions and answers pdf….. Hi sir, Plz send me the Ebook of java interview questions.

Sir please send me ebook for java question and answer. Pls send the interview besed question in my email. I want to a java-interview-questions-and-answers pdf thanks. Hii sir, Plz send me the Ebook of java interview questions. Please send me interview questions and answers ebook.

Please send me core Java interview questions to my email. Please send me ebook i have not got ebook on email. Hi sir plz send me java question answer with example in PDF. You should get it in email as soon as you will subscribe to newsletter.

Please send the book. Your initiative is very much useful to us. I appreciate you so much. Thanks a lot! Please send me copy of Java interview questions pdf. I am following this website and it is very helpful for interviews. Hi Please send me the ebook for Java interview questions pdf Anil. Please send me, I have already subscribe the page. Thanks gandharav katyal. Please send me the interview questions pdf ebook. Please Send me this ebook…java interview questions.

Please send me the latest FAQ questions with answers. Hi sir, i subscribed to your newsletter so request you to send me this book. I have so many doubts can you clarify my doubts in Java. Hi Pankaj, Where can I subscribe to your newsletter? Im subscribing for the book..