Java language interview questions and answers pdf

Published on 

 

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. Java Interview Questions Why is Java called the Platform Independent Programming Language? .. Both implementations share some common. Get Interview Questions and answers on JAVA for freshers with pdf, learn Answer- The features of this programming language are as follows-.

Author:CHANELL GOEING
Language:English, Spanish, German
Country:Italy
Genre:Art
Pages:371
Published (Last):17.09.2016
ISBN:886-3-62732-843-8
Distribution:Free* [*Sign up for free]
Uploaded by: MARANDA

54942 downloads 142065 Views 22.38MB PDF Size Report


Java Language Interview Questions And Answers Pdf

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?. Dear readers, these Java Interview Questions have been designed especially to the subject and later they continue based on further discussion and what you answer − What are the supported platforms by Java Programming Language?. Contains Important Java Interview Questions with Answers and Java FAQs helpful for clearing any Java Job Java Language Interview Question and Answers.

Question 3- Why Java is a strongly typed language? Answer- It is a strongly typed language because :- 1. Every variable and expression has a strongly defined type. All assignments are checked for type compatibility. Question 4- Draw a diagrammatic representation of Java? Answer- An applet is a special kind of Java program that is designed to be transmitted over the internet and automatically executed by a Java compatible web browser. They are downloaded on demand without interacting with user. The following figure explains loading and start-up of an applet. Java Applet Question 6- How will you define packages in java? Answer- A package is a mechanism for organising the classes. They can be stored in compressed files called JAR files. The Packages in this general purpose language have following features :- 1. Package provides a unique namespace for the types it contains.

Ans: String is not a primitive data type in java. When a string is created in java, it's actually an object of Java. String class that gets created.

After creation of this string object, all built-in methods of String class can be used on the string object. In the below example, how many String Objects are created?

String class are created. Why Strings in Java are called as Immutable? Ans: In java, string objects are called immutable as once value has been assigned to a string, it can't be changed and if changed, a new object is created.

In below example, reference str refers to a string object having value "Value one". What's the difference between an array and Vector? Ans: 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? Ans: Multi threading is a programming concept to run multiple tasks in a concurrent manner within a single program.

2018 Latest 60 Java Interview Questions And Answers Pdf

Threads share same process stack and running in parallel. It helps in performance improvement of any program. Why Runnable Interface is used in Java? Ans: 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? Ans: Multi threaded applications can be developed in Java by using any of the following two methodologies: 1. 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? Ans: 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? Ans: 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? Ans: 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? Ans: 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.

Can a class be a super class and a sub-class at the same time? Ans: 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?

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

Top Java Interview Questions with Answers

Ans: 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? Ans: 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? Ans: 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.

How can we make copy of a java object? Ans: 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 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? Answer: It contains the executable body that can be applied to the specific object of the class.

300 Core Java Interview Questions | Set 1

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? Answer: Finally block will not be executed whenever jvm shutdowns. If we use system. Explain about main method in java? Answer: Main method is starting point of execution for all java applications. Every Java application must have atleast one main method. What is constructor in java?

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

Answer: A constructor is a special method used to initialize objects in java. As and when an object is created it is initialized automatically with the help of constructor in java. We have two types of constructors Default Constructor How can we find the actual size of an object on the heap?

Answer: In Java, there is no way to find out the actual size of an object on the heap. In how many ways we can do synchronization in java? Portable and Robust. Machine Independent.

Distributed and Dynamic. Question 3- Why Java is a strongly typed language?

Answer- It is a strongly typed language because: Every variable and expression has a strongly defined type. All assignments are checked for type compatibility. Question 4- Draw a diagrammatic representation of Java? Answer- Architecture can be represented as: Question 5- What do you mean by Java Applet? Answer- An applet is a special kind of Java program that is designed to be transmitted over the internet and automatically executed by a Java compatible web browser. They are downloaded on demand without interacting with user.

The following figure explains loading and start-up of an applet. Question 6- How will you define packages in java?

Answer- A package is a mechanism for organising the classes. They can be stored in compressed files called JAR files.

The Packages in this general purpose language have following features: Package provides a unique namespace for the types it contains.

Related articles:


Copyright © 2019 wm-greece.info. All rights reserved.
DMCA |Contact Us