Interview Questions

Java Interview Questions

Java Interview Questions and Answers

Interview Questions April 28, 2017

Java Interview Questions and Answers

Are Looking for Java Training? Learn Advanced Java training in Besant Technologies – Only Institute with Oracle Authorized Java Training Center. For More Details Call Now!

Java Interview Questions and Answers for beginners and experts. List of frequently asked Java Interview Questions with answers by Besant Technologies. We hope these Java interview questions and answers are useful and will help you to get the best job in the networking industry. These Java interview questions and answers are prepared by Java Professionals based on MNC Companies’ expectations. Stay tuned we will update New Java Interview questions with Answers Frequently. If you want to learn Practical Java Training then please go through this Java Training in Chennai and Java Training in Bangalore

Best Java Interview Questions and Answers

Besant Technologies supports the students by providing Java interview questions and answers for job placements and job purposes. Java is the leading important course in the present situation because more job openings and the high salary pay for this Java and more related jobs. We provide Java online training also for all students around the world through the Gangboard medium. These are top Java interview questions and answers, prepared by our institute experienced trainers.

Java interview questions and answers for the job placements

Here is the list of most frequently asked Java Interview Questions and Answers in technical interviews. These questions and answers are suitable for both freshers and experienced professionals at any level. The questions are for intermediate to somewhat advanced Java professionals, but even if you are just a beginner or fresher you should be able to understand the answers and explanations here we give.

Java interview questions and answers for Freshers and Experienced

Here I am providing some of the important core java interview questions with answers that you should know. You can bookmark this post to brush up your knowledge before heading for an interview. Whether you are a fresher or highly experienced professional, java plays a vital role in any Java/JEE interview. Java is the favorite area in most of the interviews and plays a crucial role in deciding the outcome of your interview. This post is about java interview questions that come directly from 10+ years of experienced Professionals of Java programming and lots of interviewing experience.

As a Java professional, it is essential to know the right buzzwords, learn the right technologies and prepare the right answers to commonly asked Java Interview Questions. Here’s a definitive list of top Java Interview Questions that will guarantee a breeze-through to the next level.

Q1) Why is Java known as the Platform Independent Programming Language?

The ease of executing the code on any platform makes this language a Platform Independent Programming Language. Just by installing JDK software on a system, JVM also gets installed automatically. This JVM (Java virtual machine) is the one that can execute Java bytecode. Each Java source file is compiled into a bytecode file, which is later executed by the JVM. Java was designed with a motto to allow the programs to be run on any platform, without the need of rewriting or compiling them each time recompile for different platforms.

Q2) Name the Data Types that are supported by Java?

There are 8 primitive data types that are supported by Java:

  • byte
  • int
  • short
  • long
  • float
  • double
  • char
  • boolean
Q3) Throw some light on the main features of Java.
  • Object-Oriented language– First and foremost feature of Java. By object-oriented means here the state and behavior of an object is described by the class and the methods.
  • Platform independent language – Java runs on the WORA principle. WORA means “Write Once Run Anywhere”. Java was mainly designed to support platform independency. Thereby Java supports multiple platforms like Windows, Mac, Linux, Sun Solaris, etc.
  • Portable – It means Java byte code can be run on any hardware that is JVM compliant.
  • Robust – It is a highly supported language. It has a strong memory management and the reason is that there are no pointer allocations.
  • Prohibits Memory Leaks – Java is having automatic garbage collection feature that stops the memory leakage.
Q4) Define Autoboxing and Unboxing?

Autoboxing is an automatic conversion which is made by the Java compiler. The conversion of a primitive type to the equivalent reference type is termed as Autoboxing. Conversion of a double to a Double, an int to an Integer, etc are examples of Autoboxing. We can simply call it boxing too. Unboxing is the opposite of Boxing, i.e., conversion of the reference type to the corresponding primitive type such as Byte to byte.

Q5) What is Overloading and Overriding in Java?

Overloading: When two or more methods in the same class having exactly the same name, but parameters are different then it is called Method overloading. It is a compile-time concept. Overriding: When a child class redefines the same method as that of in a parent class, then it is called Method overriding. Polymorphism is applicable for overriding, and not for overloading. It is a run-time concept.

Q6) How do you differentiate a HashSet class and a TreeSet class?

HashSet Class – It implements java.util.Set interface.

  • It eliminates the duplicate entries and it makes use of hashing for storage.
  • Hashing is the mapping between a key value and a data item. This way it provides the efficient searching of data.
  • TreeSet Class – It implements java.util.Set interface.
  • It provides an ordered set and this class uses tree for storage purpose.
  • Like Hashset class, this also eliminates the duplicate entries.
Q7) What is a List? What is the difference between an ArrayList and a LinkedList?

List is a collection of non-duplicate objects which are in an order. One can access the elements of a list in a specific order.

  • An ArrayList Class implements java.util.List interface and for storage it uses arrays, while a LinkedList class also implements java.util.List interface but uses linked list for storage.
  • Storage in arrays is faster than List.
  • The insertion and deletion of elements can’t be done in the middle of an ArrayList. To achieve this, a new array needs to be constructed. But in case of LinkedList, elements can be added and deleted from anywhere in the list.
Q8) Define JVM, JDK and JRE?
  • JVM stands for Java Virtual Machine. JVM is a process execution machine that provides the runtime environment in which the java byte code can be executed.
  • It is platform dependent because JVMs are available for almost all hardware and software platforms.
  • JDK stands for Java Development Kit. It so physically exists. It is for writing Java applets and applications The runtime environment of JDK sits on the top of the operating system.
  • JRE is an acronym for Java Runtime Environment. It is also known as Java Runtime. It is a part of JDK. It is a set of programming tools used for developing the Java applications.
Q9) Define the Java’s WORA nature?

WORA means Write Once Run Anywhere. Java is compiled to a bytecode which does not platform specific. This bytecode is the intermediate language between the source code and the machine code. As the bytecode is not platforming specific, so it can be used to any platform. Sometimes, it is also called WORE – Write Once Run Everywhere.

Q10) How do you differentiate between StringBuffer & StringBuilder?
  • StringBuffer is thread safe, which means it is synchronized. Two methods at the same time can’t call the methods of StringBuffer. On the other hand, StringBuilder is non-synchronized. So two methods can simultaneously call the methods of StringBuilder.
  • StringBuffer is less efficient when compared to StringBuilder.
Q11) What is the case when you override hashcode() and equals() ? What problem can occur if we don’t override hashcode() method?

We can override hashcode and equals whenever necessary. Especially the case when one wants to do equality check or to use one’s object as a key in HashMap. If we don’t override hashcode() method, we’ll not be able to recover our object from hashMap (if that is used as a key in HashMap).

Q12) What are immutable classes?

An Immutable class is a Java class whose objects cannot be modified once created. Any alteration in the Immutable object results into a new object. All the java.lang package wrapper classes are immutable. Examples are: Short, Long, Boolean, String, etc.

Q13) Mention the access specifiers used in Java?

Access specifiers are defined as the keywords that are used before a class name which defines the scope of accessing. The types of access specifiers are:

  • Public – Class, Methods and Fields are accessible from anywhere.
  • Private – Methods and Fields can be accessed only from the same class to which they actually belong.
  • Protected – Methods and Fields can be accessed from the same class to which they belong, from the sub-classes and also from the classes of same package. But they are not accessible from outside.
  • Default – Methods, Fields, classes can only be accessible from the same package, not from outside.
Q14) What is Singleton in Java?

Singleton is a class with only one instance in the whole Java application. For an example java.lang.Runtime is a Singleton class. The prime objective of Singleton is to control the object creation by keeping the private constructor.

Q15) Will all the Try blocks in Java end with Catch Blocks?

Yes, Try block either needs to be followed by Catch block or by Finally block or sometimes by both. The reason is that any exception that will be thrown from a try block needs to be caught in a catch block, and even if no exception is there then also use of Finally block should be there so as to specify any specific tasks that need to be performed before code ends.

Q16) What is the Final Keyword in Java?

In Java, Final the keyword is used to declare a constant. A value can be assigned only once to a constant. Later, the value can’t be changed. Example: Private Final int const_val=50 Here constant is assigned the value 50. The method here is resolved at complied time, thus are faster than any other code.

Q17) Is it possible to declare a class as Abstract without using any abstract method?

Yes, this case is possible. We can create an abstract class by using the abstract keyword before the class name. Also, even if a class has one or more abstract methods, then also, it must be declared as abstract, else it will throw error

Q18) Any five differences between an Abstract Class and Interface in Java?
  • Where an abstract class have a limit to extent only one class or abstract class at a time, Interface has no such limits. It can extend n numbers of interfaces at the same time.
  • Abstract classes can have both abstract as well concrete methods. On the other hand, interface can only have abstract methods.
  • Abstract class can provide complete code, but interface can only provide signature, not the code.
  • Speed wise Abstract classes are faster than interfaces.
  • An abstract class can have public and protected abstract methods while Interface, by default, can have only public abstract methods.
Q19) Define Serialization? When should we make use of serialization?

Serialization – It is a way of writing an object’s state into a byte stream. This converted byte stream is transferred on the network and the object is then re-created at the destination. Implementation of java.io.Serializable the interface is must if you want to serialize a class’ object. Serialization is basically used when data needs to be transmitted over the network. This traveling of state of an object on the network is known as marshaling.

Q20) Explain multi-threading and the ways of implementing multi-threading in Java?

Multithreading is a concept of running multiple tasks in a concurrent manner in a single program. The threads

shares the same process stack and thus runs in parallel. This process helps in improving the performance of a program. Multi-threading can be implemented in two ways:

  • First is by the use of Java.Lang.Runnable Interface.
  • Another ways is to write a class that extends the Java.Lang.Thread class.
Q21) What is Collection and a Collections Framework?

Collection: A collection is an object for grouping multiple elements into a single unit. It can hold other objects’ references. Collections are also termed as the container

Collections Framework: It provides an architecture that stores, manipulates and represents collections. It is a collection of classes and interfaces. Advantages of Collections Framework:

  • Improves program speed and quality
  • helps in storing & processing the data efficiently
  • Decreases the programming effort and increases the reusability chances of a software.
Q22) What do you mean by BlockingQueue in Java Collections Framework?

It implements the java.util.Queue interface and supports the operations that wait for space availability in the queue while storing an element. Blocking queues are mainly designed keeping the consumer-producer problems in mind. BlockingQueue does not accept the null elements. Also they are used in inter-thread communications.

Q23) What is the difference between ArrayList and Vector?
  • ArrayList is faster than Vector.
  • ArrayList is introduced in JDK 1.2. It is therefore not a legacy class, but Vector is.
  • To traverse the elements, an ArrayList uses Iterator interface while Vector can use Iterator as well as Enumeration interface.
  • Unlike ArrayList, Vector is synchronized.
Q24) Define Constructor and Constructor Overloading in Java.

Constructor – It gets invoked automatically when a new object is created. Every class has a constructor, so even if one forgot to mention it, the Java compiler itself creates a default constructor for that class. Constructor is like a method that doesn’t return the type. Constructor overloading – It is same as method overloading. Same constructor with different parameters can be declared in the same class. Then it’s the role of compiler to differentiate which constructor needs to be called depending upon the parameters and the sequence of data types.

Q25) What are the differences between Enumeration and Iterator?
  • When it comes to traversing the elements, Enumeration can do only legacy elements unlike Iterator that can traverse both legacy as well as non-legacy elements.
  • Enumeration interface don’t have remove() method which is there in Iterator.
  • Enumeration is less safer than Iterator.
  • Enumeration is fail-safe while Iterator is fail-fast.
Q26) Why break is used in Switch Statement’s each case?

Break is used in a switch so that code breaks after the valid case and thus prevents the flowing of code in the cases too. If break isn’t used after each case (except the last one), a wrong result will generate as it will execute all the proceeding cases after the valid case.

Q27) Name the different states of a thread.

An independent path of execution in a program is called as Thread. There are several states of a thread:

  • Ready: When a thread is created, it is said to be in the Ready state.
  • Running: The thread that is currently being executed is said to be in running state.
  • Waiting: Awaiting state is a state when a thread that is waiting for another thread to free certain resources so that it can acquire those resources.
  • Dead: A thread whose run() method exits is in dead or terminated state.
Q28) Is it true that a java program never goes out of memory because of garbage collection feature?

No this is not a true case. Automatic garbage collection can help in reducing the chances but can’t eradicates the possibility fully. It doesn’t ensure that a Java program will never go out of memory. There is a possibility that objects are created at a faster pace than that of garbage collection. This results into the filling of all the available memory resources, thus memory goes out of leak.

Q29) How can you define Object Cloning in Java?

Creating an exact copy of an object is known as the object cloning. clone() method of object class and java.lang.Cloneable interface are used for this purpose. If we don’t use mentioned interface(Cloneable interface), the clone() method will generate the CloneNotSupportedException. Cloning is a fastest way to copy the arrays. Also cloning takes less lines of code.

Q30) Is throw and throws keyword can be used interchangeably? If no, what is the difference between the two?

No, these two are different keywords, thus can’t be used interchangeably. Following are the differences between the two!:

  • The throw is used for throwing an exception while Throws used for declaring an exception.
  • Throw followed by an instance, whereas throws followed by a class.
  • With throw, one cannot throw multiple exceptions, but with Throws, multiple exceptions can be declared.
  • Throw is used in method body, but Throws is used in the method declaration which is signature.
Q31.What is the difference between JDK, JRE, and JVM?

JVM is an acronym for Java Virtual Machine, it is an abstract machine which provides the runtime environment in which Java bytecode can be executed. It is a specification.

  • JVMs are available for many hardware and software platforms (so JVM is platform dependent).
  • JRE stands for Java Runtime Environment. It is the implementation of JVM.
  • JDK is an acronym for Java Development Kit. It physically exists. It contains JRE + development tools.
Q32) What is the difference between an Inner Class and a Sub-Class?

An Inner class is a class which is nested within another class. An Inner class has access rights for the class which is nesting it and it can access all variables and methods defined in the outer class.

A sub-class is a class which inherits from another class called superclass. Sub-class can access all public and protected methods and fields of its superclass.

Q33) What is Final Keyword in Java? Give an example.

In Java, a constant is declared using the keyword Final. Value can be assigned only once and after assignment, a value of a constant can’t be changed.

  • In below example, a constant with the name const_val is declared and assigned a value
  • Private Final int const_val=100
  • When a method is declared as final, it can NOT  be overridden by the subclasses.This method is faster than any other method because they are resolved at the compiled time.
  • When a class is declared as final, it cannot be subclassed. Example String, Integer, and other wrapper classes.
Q34) What’s the base class in Java from which all classes are derived?
  • lang.object
Q35) What’s the difference between an Abstract Class and Interface in Java?

The primary difference between an abstract class and interface is that an interface can only possess declaration of public static methods with no concrete implementation while an abstract class can have members with any access specifiers (public, private etc) with or without concrete implementation.

Another key difference in the use of abstract classes and interfaces is that a class which implements an interface [su_spoiler title=”must implement all the methods of the interface while a class which inherits from an abstract class doesn’t require implementation of all the methods of its superclass.

A class can implement multiple interfaces but it can extend only one abstract class.

Q36) What is a platform?

A platform is basically the hardware or software environment in which a program runs. There are two types of platforms software-based and hardware-based. Java provides the software-based platform.

Q37) What is classloader?

The classloader is a subsystem of JVM that is used to load classes and interfaces.There are many types of classloaders e.g. Bootstrap classloader, Extension classloader, System classloader, Plugin classloader etc.

Q38) What is the static method?
  • A static method belongs to the class rather than an object of a class.
  • A static method can be invoked without the need for creating an instance of a class.
  • A static method can access static data member and can change the value of it.
Q39) Can a class have multiple constructors?

Yes, a class can have multiple constructors with different parameters. Which constructor gets used for object creation depends on the arguments passed while creating the objects.

Q40) 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.

Q41) 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

  1. By using Java.Lang.Runnable Interface. Classes implement this interface to enable multithreading. There is a Run() method in this interface which is implemented.
  1. By writing a class that extends Java.Lang.Thread class.
Q42) How can we execute any code even before the main method?

If we want to execute any statements before the 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 the creation of objects in the main method.

Q43) What’s the benefit of using inheritance a key?

Key the 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.

Q44) What’s the difference between Stack and Queue?

Stack and Queue both are used as placeholder for a collection of data. The primary difference between a stack and a queue is that stack is based on Last in First out (LIFO) principle while a queue is based on FIFO (First In First Out) principle.

Q45) 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.

Q46) Is String a data type in java?

String is not a primitive data type in java. When a string is created in java, it’s actually an object of Java.Lang.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.

Q47) List any five features of Java?

Some features include Object Oriented, Platform Independent, Robust, Interpreted, Multi-threaded

Q48) Why are Strings in Java called as Immutable?

In Java, string objects are called immutable as once the 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”.

Q49) 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.

Q50) Why Java is considered dynamic?

It is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.

Q51) Define class?

A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object.

Q52) How would you call wait() method? Would you use if block or loop, and why?

wait() method should always be called in loop. It is likely that, until thread gets CPU to start running again, the condition may not hold. Therefore, it is always advised to check condition in loop before continuing.

Q53) How do you take thread dump in Java?

By using kill -3 PID in Linux, where PID is the process id of Java process, you are able to take a thread dump of Java application. In Windows, you can press Ctrl + Break.

Q54) What is the difference between sleep and wait in Java?

Both are used to pause thread that is currently running, however, sleep() is meant for short pause because it does not release lock, while wait() is meant for conditional wait.This is why it releasesm lock, which can then be developed by a different thread to alter the condition of which it is waiting.

Q55) Is ++ operator thread-safe in Java?

++ is not thread-safe in Java because it involves multiple commands such as reading a value, implicating it, and then storing it back into memory.

Q56) What is constructor chaining in Java?

Constructor chaining in Java is when you call one constructor from another. This generally occurs when you have multiple, overloaded constructor in the class.

Q57) Explain Java Heap Space and Garbage collection.

When a Java process has started using Java command, memory is distributed to it. Part of this memory is used to build heap space, which is used to assign memory to objects every time they are formed in the program.

Part of this memory is used to build heap space, which is used to assign memory to objects every time they are formed in the program.

Garbage collection is the procedure inside JVM which reclaims memory from dead objects for future distribution.

Q58) What is the difference between final, finalize and finally?
  • Final is a modifier which you can apply to variable, methods, and classes. If you create a variable final, this me its value cannot be changed once initialized.
  • Finalize is a method, which is called just before an object is a garbage collected, allowing it a final chance to save itself, but the call to finalize is not definite.
  • Finally is a keyword which is used in exception handling, along with try and catch. The finally block is always implemented regardless of whether an exception is thrown from try block or not.
Q59) What is the difference between poll() and remove() method?

Both poll() and remove() take out the object from the Queue but if poll() fails, then it returns null. However, if remove() fails, it throws exception.

Q60) What kind of variables can a class consist of?

A class consists of the Local variable, instance variables, and class variables.

Q61) What is Singleton class?

ingleton class control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes.

Q62) List the three steps for creating an Object for a class?

An Object is first declared, then instantiated and then it is initialized.

Q63) When a byte datatype is used?

This data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int.

Q64) What do you mean by Access Modifier?

Java provides access modifiers to set access levels for classes, variables, methods and constructors. A member has

package or default accessibility when no accessibility modifier is specified.

Q65) When parseInt() method can be used?

This method is used to get the primitive data type of a certain String.

Q66) Why is StringBuffer called mutable?

The String class is considered as immutable, so that once it is created a String object cannot be changed. If there is a necessity to make alot of modifications to Strings of characters then StringBuffer should be used.

Q67) What is an Exception?

An exception is a problem that arises during the execution of a program. Exceptions are caught by handlers positioned along the thread’s method invocation stack.

Q68) When throw keyword is used?

An exception can be thrown, either a newly instantiated one or an exception that you just caught, by using throw keyword.

Q69) When a super keyword is used?

If the method overrides one of its superclass’s methods, overridden the method can be invoked through the use of the keyword super. It can be also used to refer to a hidden field.

Q70) Why Runnable Interface is used in Java?

Runnable interface is used in java for implementing multi-threaded applications. Java.Lang. Runnable the interface is implemented by a class to support multi-threading.

Q71) 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.

Q72) 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.

Q73) Can we have two methods in a class with the same name?

We can define two methods in a class with the same name but with different number/type of parameters. Which method is to get invoked will depend upon the parameters passed.

Q74) How can we make the 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. lone() is a method of Cloneable interface and hence, Cloneable interface needs to be implemented for making object copies. 45. 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 trient while declaring them.

Q75) 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.

Q76) 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 the developer can use only those constructors which are defined in the class.

Q77) 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 are turn type must be exactly same as is that of the method being overridden.  Hence using a different return type doesn’t override a method.

Q78) What is an applet?

An applet is a Java program that runs in a Web browser. An applet can be a fully functional Java application because it has the entire Java zPI at its disposal.

Q79) What is Comparable Interface?

It is used to sort collections and arrays of objects using the Collections.sort() and java.utils. The objects of the class implementing the Comparable interface can be ordered.

Q80) Why IS Java application platform independent?

In Java application first, java compiler convert our java source code to bytecode. This bytecode sends or through any OS or hard disk or something, it’s accepted directly in using of JVM.Each JVM worked based on own platform, but all JVM accept machine language(of byte stream) easily.so only java application called platform independent.

Q81) What are the actions present in the JVM?

1.Loader-it performed to collect the codes anywhere(hard disk or software or ide)to given JVM.

2.Compiler-to converts source code to bytecode.

3.Jit-to covert bytecode to a high-level language.

4.Execution-finally program starts to run and execute the output.

Q82) What is the current version of JDK?

JDK-java development kit current version is 1.8.

Q83) Java is fully OOPS language or not?

No, its present primitive(old datatypes).so java not fully based on OOPS.

Q84) What is Wrapper class?

Wrapper class means typecasting (to convert one data type to another data type).this class used to data objects(Integer, Float, Char, Byte, Short, Long, Double, Boolean).

Q85) What is an Immutable class?

Once create the value of class cannot be modified, that class called immutable class.immutable class present 9 classes and there are 8 wrapper class and string class, totally present 9 immutable class.

Q86) What is Array?

Array means collection of similar data types.its present two types.

1.single dimension-stored multiple value in single variable.

ex: int a[]={1,2,3,4};

2.multi dimension-values stored based on rows and columns.

ex: int a[][]={{1,2,3},{1,2,3},{1,2,3}};

Q87) What is String?Difference between StringBuilder and StrinngBuffer?

String means a collection of characters.It’s used to get any data type values(Like int, char, float,etc..).so string act as strong media.

String value once creates cannot be modified so only we prepared next level of StringBuilder and StrinngBuffer.

StringBuilder-it’s a non-synchronized method so it’s acting very fast and no thread safe.

StrinngBuffer-it’s a synchronized method so it’s acting slow and thread safe.

Q88) What is Function?

Function means member function and smallest multiple blocks of class.the function only can be access to provide calling function, otherwise cannot be accessed.

Q89) What is Class?

It’s a templet or blueprint or collection of objects .its describe state and behaviors .state means-data, behavior means-method.

Q90) What is Object?

It’s a runtime or real-time entities.each object gets own properties and response.objects are used to access the class properties.

Q91) What is Polymorphism?

One object or message functioned different actions called polymorphism.

Q92) What is Function Overloading?

Using a number of same method name and different parameters in a single class to achieve this process polymorphism its known as function overloading.

Q93) What is Function Overriding?

Using same method name and same parameters in inheritance method to override parent on child class details, it is called function overriding.

Q94) Why used super and this keyword in java?

this keyword means-current or represent a class.its used to read current class properties.

super keyword means-super or parent class.its used to read immediate parent class properties.

Q95) What is inheritance?

One class of data or properties collected or send in another class is called inheritance.

Q96) Describe the types of Inheritance?

1.single-one parent to one child class.

2.multilevel-one parent to child, after that child act as a parent, to send another child.

3.hierarchical-one parent to any child.

4.multiple-two parent send at a time one child.

5.hybrid-combination of hierarchical and multiple.

Q97) What is scope?Describe the types of scope?

scope means storage capacity or level of variable and methods.

1.package scope-this variable or method storage present within a package otherwise its destroyed.

2.class scope-its present within the class otherwise, it’s destroyed.

3.method scope-its present the method otherwise, it’s destroyed.

4.block scope-its present within the block otherwise, it’s destroyed.

Q98) Types of Access Specifiers?

1.public-its global value, accessed package to package.

2.private-its private value, accessed only within the class.

3.protected- its used inheritance class, its possible only hierarchical inheritance.

4.default- its normal type, its used within the package.

Q99) What is Encapsulation?

Binding or warping to the data and method within a class is called encapsulation.

Q100) What is Abstraction?

Hiding the background details and show only essential features or functions.this is advance of an interface.

Q101) What is Multitasking? How to achieve multitasking?

Different network performed a different task called multitasking.to achieve this process using two concepts

1.multi threading

2.multi processing

Q102) What is Thread?

A single core of sequential process called thread.

ex: single desktop application.

Q103) what is Multithreading?

Multiple actions performed sequentially at a time is called multithreading.

ex: atm process

Q104) Difference between Multithreading and Multiprocessing?

Multi processing-no allocation of the common memory in a set of process, so speed low, high cost.

Multi threading-multi threading allocates common memory in a set of threading, so high speed, low cost.

Q105) What is Interface?

The interface in java is a mechanism to achieve abstraction.There can be only abstract methods in the Java interface, not method body.

It is used to achieve abstraction and multiple inheritances in Java. and also a blueprint of class.

Q106) Difference between Interface and Abstraction?

Abstraction-using abstract keyword must.itsused to not achieve multiple and hybrid inheritance.

Interface-abstract keyword not must.its used to achieve multiple and hybrid inheritance.

* The abstract class cannot implement one interface, but one interface implements to one abstract class.

Q107) What is Serialization?

In our source code converted into a byte stream(machine understanding language) this process called Serialization.it’s means to write the objects (of data) in the needed destination.so we are using output streams of write objects.

Q108) What is DeSerialization?

In our byte stream convert into a high-level language(human being understanding language) this process called deSerialization.its mean read the objects (of data) in a needed platform.so we are using input streams of reading objects.

Q109) What is Exception?types of Exception?

The exception is an abnormal condition.In Java, an exception is an event that disrupts the normal flow of the program.

It is an object which is thrown at runtime.

types

1.error-its irrecoverable.

2.checked exception-compile time error.

3.un checked exception-run time error.

Q110) Explain Exception Handling methods?

Any exception occurred in our source code the compiler terminated or skip the process, so that place we are using Exception Handling.

it means to catch and handle the exception, to maintain the flow of process normally.some methods

1.Try-it used to catch the exception.

2.Catch-it used to handle the exception.

3.Finally-finally block executes always.

4.throw-it used to create exception explicitly.

5.throws-its indicate signature of methods for handling the exception.

Q111) What is Java ?

Java is a programming language used to create programs that is used to perform the tasks.

Q112) Which thread will execute first?

Main() thread will start first

Q113) How to achieve lock?

By using synchronized keyword you can achieve lock.

Q114) How to get the current thread?

By using Thread.currentThread() method

Q115) Difference between Array and Arraylist?
  1. Array
  2. It is fixed size
  3. Arraylist
  4. Its not fixed size, dynamically grows and shrinks.
  5. Array
  6. Does not provide built in methods
  7. Arraylist

Provides built in methods to add,delete

Q116) How to sort the collections?

Collections.sort() method we can use to sort

Q117) Which data structure set uses?

Set internally uses map data structure.

Q118) Is wrapper classes overrides hashcode and equals method.

Yes

Q119) What is Treeset?

Set with sorted elements.

Q120) In which scenarios Arraylist and LinkedList will be used?

For searching Arraylist is will be used and for modification linkedlist will be used.

Q121) What happens if you add same key in the hashmap?

Key will remain same, It will override the value.

Q122) Can we add null key to the hashmap?

Yes hashmap allows only one null key

Q123) Hashmap put() operations uses which datastrcture when the hashcode is same ?

It uses Linkedlist data structure.

Q124) Does java 8 supports functional programming?

Yes. By using lambda expressions.

Q125. What is default method in java 8 interface?

Java 8 interface allows one method implementation as default by using default keyword.

Q126) Difference between stringbuffer and stringbuilder?

Stringbuffer is a synchronized

Stringbuilder is not synchronized.

Q127) What is token in c

Small individual units of program call token.

Q128) What is keywords, data type, constant and variable

Keywords: Its reserved which have special meaning provided by compiler.

Data type: Its define the type of variable. There are four fundamental data type in c

Int->integer value

Float-> Float value

Char->character value

Double->for double value

Constant: its means fixed. Once a variable has declared as a constant,the value of variable can not change through out the program. const keywords use to declare variable as contant.

Variable: it’s a identifier which use to hold the value in program.

Q129) What are the fundamental data type in c

there are seven fundamental data type in c

  • Arithmetic Operator
  • Logical Operator
  • Relational Operator
  • Assignment Operator
  • Increment or decrement Operator
  • bitwise Operator
  • ternary or conditional operator
Q130) What are the conditional statement

conditional statement are:

  • if
  • if-else
  • nested if-else
  • else-if ladder
  • switch-case
Q131) What are the un-conditional statement

un conditional statement are:

  • break
  • continue
  • goto
  • exit()
Q132) What is if—else statement

in if—else statement either if block will work or else block will wor, both cant work together. If condition is true if block will work other wise else block will work.

Syntax:

if(condition)

{

//statement;

}

else

{

//statement;

}

Q133) What is switch case statements

its is use for multiple value checking.

Syntax:

Switch(expression)

{

Case 1: //statement

break;

Case 2: //statement

break;

Case 3: //statement

break;

.

.

default:

}

Q134) What is conditional operator

its shortest form of if-else.its  is called as ternary operator.

Syntax:

Expression?value1: value2;

If expression is true it return value1 otherwise vlaue2.

Q135) What are the iterative statement

Iterative statement are:

  • while
  • do-while
  • for
Q136) What is an array

Array is the collection of homogenous data elements.

Syntax:

int Array_name(size);

Q137) What is sorting

sorting is technique in which we arrange dtata in either ascending or descending order.

Some techniques are:

  • bubble sort
  • selcstion sort
  • insertion sort
  • quick sort
  • merge sort
Q138) What is searching

searching is a technique through which  we can search a particular elements.

Some searching techniques are:

  • linear search
  • binary serch
Q139) What is function

it’s a set of statement to perform specific task.

Syntax of user define function:

Returntype function_name(datatype1 param1,datetype2  param2,….)

{

//set of statements

return(value);

}

Q140) Explain the type of user define function

there are four type of user define function

  • function without parameter without return type.
  • function without parameter with return type.
  • function with parameter without return type.
  • function with parameter with return type.
Q141) What is recursive function

function call itself again and again is called recursive function

Syntax:

Function_name

{

//statements

Function_name();

}

Q142) What is structure

it is the collection of non-homogenous data element.

Syntax:

stuct structure_name

{

Datatype1  varaiable1;

Datatype2  varaiable2;

.

.

};

struct structure_name Variable_name;

Q143. What is difference
between structure and union” open=”no” style=”default” icon=”plus” anchor=”” class=””]

the major difference between structure and union is

In structure each member variables have individual memory allocation where as in union  member variable share memory allocation.

Q144. What is pre-processor directive

pre-processor directive start with # and it work before compilation

Example:#include,#define,#if,#prgma,#error etc

Q145. What is micro in c

micro can be define before main() function

Syntax:

#define x 6

Q146. What is file

it is collection of data or information, store permanently in our system.

Q147. What is file pointer

if we want to write or retrieve data from the file that is possible only with help of file pointer.file pointer can be declared as

File *File_pointer_name;

Q148. What is data structure

it’s a sequence of data through which we can easily perform operation like insert, search and delete

Q149. What is stack

its is non-primitive linear data structure work on LIFO(last in first out) technology.it is use in conversion of expression, scientific calculation etc.

Q150. What is queue

its is non-primitive linear data structure work on FIFO(First in first out) technology.it is use in Railway reservation system, online ordersystem  etc.

Q151. What is link list

It is collection of node and each node divided in two part, first part called as info part and second part called as address part which hold the address of next node.

Syntax,

Struct Node

{

Int info;

Struct Node Add;

}

Q152. What is binary tree

Its is collection of node and each node can have maximum two child node.

Q153. What is spanning tree

spanning tree are that type of tree in which we cover all nodes using minimum number of edges.

Q154. What is oops

oops stand for object oriented programming language.if any language following oops concept that means they have following property

  • class
  • object
  • inheritence
  • polymorphism
  • Abstraction
  • Encpasulation
  • databinding
Q155. What is polymorphism

Ability to perform different different  task is called as polymorphism. Example –function overloading, Operator overloading in C++.

Q156. What is abstraction

if we use feature of system without knowing background detail is called abstraction.

Q157. What is inheritance

It’s a process through which we can access the property of one class into another class

Q158. What are type of inheritance in c++
  • single inheritance
  • multiple inheritanc
  • multilevel inheritance
  • hybrid inheritance
  • hierarchal inheritance
Q159. What is constructor and destructor in c++

constructor: it is special type of function which have the same name as a class name. constructor does not return any value even void.

Destructor:-it’s a same like constructer presided with ~.it is use to de allocate memory which has allocated by constructor .

Q160. What is static keyword

we can declared variable and function as a static.

Static function can have only static variable.

Static function and variable can call directly without help of object.

Q161. What is friend function

Friend functions are that type of function which are not member of class.

Since they are not member of class, we can call directly.

Friends function is use to access private member of classes.

Q162. What is pure virtual function

Function does not have function body is call virtual function

Syntax,

Returntypre function_name(agruments)=0;

Q163. What is copy contractor in c++

if we  declared a object,and at the same time we initialised is called as   copy constructor

Ex. Class o1;

Class o2=o1;//copy constructor

Q164. What is Java

it is pure object oriented and platform independent language.

Q165. What final in java

final is keyword in java

If we declared any variable as a final, the value of variable cant be change.

If we declared any method as a final, That method can not override.

If we declared any class as a final, That class cant be inherit.

Q166. What is super keyword in java

super keyword is use to call Super class variable, super class constructor and super  class method.

Q167. What the difference between abstract and interface

abstract-it is the collection of abstract method and concrete method. we cant perform multiple inheritance using abstract class.

Interface-it is the collection of abstract method and final variable. we can perform multiple inheritance using interface.

Q168. What is an applet program

applet program can run on web browser as well as on console window.

Its have life cyle-

Init()->start()->paint()->stop()->destroy()

Q169. What is swing

it’s a advance version of awt. All component of swing are pure java component. we use package

Import javax.swing.*;

Q170. What is thread

A thread is small part of program, which work independently.

Q171. What is synchronisation

if multiple thread seeking a chance of same resource. once a tread has achieved resource other thread do not interrupt,is called as synchronisation

Q172. What exceptional handling

the way of handing exception is called exception handling.

Exceptional handling uses

  • try
  • catch
  • finally
  • throw
  • throws
Q173. What is JDBC

JDBC stands for java data base connectivity which is use to establish connection between Java Application and database.

Q174. What are jdbc driver

there are for types of driver

  • JDBC-ODBC bridge driver
  • Native API driver
  • Network driver->handle multiple data base
  • pure java driver or protocol driver
Q175. What are steps involved in data base connectivity

Step1: import package

Import java.sql.*;

Step2:load the driver

Class.forName(sun.jdbc.odbc);

Step3:establish connection

Connection corn=DriverMangaer.getConnection(“sun:jdbc:odbc:”,”usr”,”pass”);

Step4: create statement object

Statement st=cor.CreateStatement();

Step5: proses the query

St.executequery(“sql statement”);

Step6: close connection

Corn.close();

Q176. What is servlet

Servlet is java program store on server. its store web container. Once a request has sent by user to server ,the appropriate response send  back by server to user.

Q177. What is life cycle of servlet

life cycle of servlet are

Init()àservice()àdestroy()

Q178. Write a servlet program

Import javax.servlet.*;

Public class Hello extend HttpServlet

{

Public void doGet(HttpServletRequest req, HttpServletResponse res)

{

PrintWriter pw=req.getWriter();

pw.print(“<body bgcolor=lightyellow><h1> welcome in servlet</body>”);

}

Q179. What is Jsp

Jsp stands for java server page. Its written in form of tag. starting tag <% and closing tag %>

Q180. What is difference between while and do-while
  • While loop is called as pre condition checking loop whereas do-while loop is called as post condition checking.
  • While loop works depend on condition where as do-while loop works at least one time.
Q180. From which method the execution of java programs begins?

All the java program execution begins with the main method () because the JVM is hard coded.

Q181. Which name will be checked by the compiler for the execution of program?

The filename of the snippet will be checked by the compiler to compile the code.

Q182. Which name will be checked by the JVM after the compiling the program?

The JVM will check for the Classname for interpreting the code to byte code.

Q183. Can we have filename and classname as same?

Yes, the programmer can save the filename and classname as different name because the compiler will check for the file name for compiling and the JVM will check for the class name for converting the code to machine code, but it is good naming convention to have file name and class name as same name.

Q184 Define Expressions?

Multiple operators and operands in the same line are called Expressions.

Q185. What will be the result of relational operators?

The relational operators in Java are 6 in number and they are (<, >, <=, >=, ==, ! =) . The result is always in Boolean (Yes/No).

Q186. Which operators are used for masking the data in encryption and decryption process?

Bitwise operators are used for masking the date in encryption and decryption process. They are encoded along with the data.

Q187. Which is maintained to manage the life cycle of local variables?

Memory management is spiltted- into 4 sections and the local variables are managed in stack.

Q188. By how many ways the object can be created?

Object can be created by 4 ways they are: by new, by cloning, by reflection, by de-serialization.

Q189. The object which has no reference is called?

When there is no reference or when the object is nowhere used then the object becomes unreachable and they are called unreachable objects, the JVM will call the garbage collector to destroy the same.

Q190. In Heap memory which variables are created?

Memory management in Java is spiltted- into 4 sections namely: Heap, stack, String pool, Miscellaneous and the Reference variables are managed in Heap.

Q191. In java, how arrays are created?

Arrays are created as Objects in java. Arrays can contain any type of elements value (primitive or objects) but the storage of both data is not possible in a single array.

Q192. Which operator is not used in java?

The size occupied by primitive datatype, object or array is managed and hence there is no need of sizeof operator in java.

Q193. Define Runtime Polymorphism?

The ability of JVM to pick one method from several methods that exist in a hierarchy is called Runtime Polymorphism.

Q194. When null pointer exception occurs?

When we try to access the Instance methods and variables, when there is a null reference to them.

Q195. When Out of memory error occurs?

When the heap memory if full and we try to over load the memory with the reference variables then the Out of memory error will be generated.

Q196. Can exceptions occur in catch block?

Yes, exceptions can occur in catch block. The exceptions in java are handled in try{} and catch{} block. The try{} contains the code which can r

aise an exception and the catch{}  block contains the code to catch and handle the exceptions.

Q197. What will happen if we use throws keyword in body?

Throws keyword should be used only in the header and if we use the keyword in body it will result in the compile time error.

Q198. Which exceptions are used to represent the business/environmental failure?

Checked Exceptions are used to represent the business/environmental failure

Ex: Business failure: ATM cash withdrawal, trying to withdraw money with low balance

Environmental failure: Network issue.

Q199. In Java, Why multiple inheritance is not supported?

When both the extended classes have the same method name, during the runtime ambiguity can occur and it can lead to compile time error.

Q200. Which feature allows the JVM to run more than one thread in java?

The multithreading is implemented as JVM feature, which allows to run more than one thread at a time. Here the threads uses a shared memory area so saves memory and context-switching between the threads takes less time than the process

Java multithreading is used in games and animation.

Q201. Which methods are there in the thread class?

Native methods in the thread class allows the execution of the thread by invoking the start() method. When a thread is created it is assigned with the priority.

Q202. Can we have two start() methods in thread execution?

No, because we can’t start a thread which is already started.

Q203. When Out of stack error occurs?

When the stack memory if full with the local variables and we try to over load the memory with the local variables then the Out of stack error will occur.

Q204. Where all string literals are managed?

Memory management in Java is spilted- into 4 sections namely: Heap, stack, String pool, Miscellaneous and the String literals are managed in String pool .

Q205. Which condition will result in Illegal state exception?

When we have 2 start() method in thread, it will result in Illegal state exception. We cannot have 2 start() method in a program because the JVM is hardcoded to start the execution of program from the start() method.

Q206. Which will manage the lifecycle of thread?

JVM Thread Scheduler will manages the lifecycle of thread based on state transition (NEW, RUNNABLE, BLOCKED, WAITING, TERMINATED).

Q207. What is the default priority of thread?

When the thread is created, every thread is assigned with the default priority 5.

Q208. What is default priority of gc()?

The garbage collector is assigned with the low priority as 1, because the gc() method should not run in-between the execution of main program. The JVM will invoke the gc() method once the memory is filled with unreachable objects.

Q209. Which interface will result in sorted order?

TreeSet will give the result in sorted order. It is the most important implementation of interface in java. Objects in Treeset are stored in a sorted and ascending order.

Q210. What is Comparator?

Comparator need to be explicitly linked to treeset via constructor. They are used to order the objects of user-defined classes and they are capable of comparing two objects of different classes.

Q211. What is workspace?

Workspace manages the jar files, Artifacts & runtime libraries.

Q212. Which will interact with hard disk?

Artifacts will interacts with hard disk and automates the interaction.

Q213. What are Access specifiers?

Access specifiers like Default, private, public and protected can be applied to class, methods, variables, Innerclass, constructor

Q214. Why we cannot be apply access specifiers to packages, initializers, local variables?

We cannot access the members inside the class if we specify the access specifiers, either we should leave without specifying or we should specify as public.

Q215. When we can use final class?

We will use final class only when we need Immutable classes.  Immutable – the user cannot create any objects.

Q216. Abstract class cannot be instantiated. Why?

If the author doesn’t want the user to create an object then the class id marked as abstract, it indirectly means that some implementation is missing in the code.

Q217. Abstract method cannot have body, why?

Abstract methods will provide only design not implementation and the class which extends the abstract will have the implementation part.

Q218) Define class in Java.

In Java, class can be used to create an object and define data types. It acts as a compilation of Java language based computers.

Q219) What is the difference between fixed and dynamic load?

Standard class loading is a class loading method that generates objects and events using new words, while class name is not known at the time of the compilation.

Q220) What is Multiple Mitigation?

Multi-threading is a programming concept that can be used to run multiple tasks simultaneously on a single program.

Q221) When was Java created?

Java was created by James Coscough in Sun Microsystem in 1995.

Q222) What stand is for JDK, JRR and JVM?
  • Java Virtual Machine has JVM
  • JRR
  • JDK has Java development kit
Q223) Need Java Use Pointers?

No java notes can be used. This is a serious security. Instead of markers, they are used in Java as safe and secure as compared to markers.

Q224) Are you connecting to a database in Java?

Action to connect to a database of Java:

  • Registration of driver class
  • Creating Link
  • Creating Report
  • Complete the questions
  • Close link
Q225) Functions of JVM and JRE?

JVM provides an operating environment to enable Java byte codes. The JRE contains JVM files that need JVM during the JRM movement.

Q226) What is the default size of the loaded factor in hacking on the basis of the collection?

The default size is 0.75, and the default capability is calculated:

Initial capacity * Attributes

Q227) What is a collection?

A package is a set of relevant classes and interfaces.

Q228) What Exception Classes are the Basic Class?

Java.lang.Throwable is a superclass of all exception classes, and all exception classes are derived from this basic class.

Q229) Two differences in the state between a class and one square

When internal classes are in the same file, subclasses may be in another file. In turn, when subclasses have their parent class methods, the inner classes get the methods they want.

Q230) How are they destroyed in Java?

Java has its own garbage collection, which should define any destructors. The destruction of the goods is automatically carried out by the garbage collection machine.

Q231) Define JSON.

JSON is an abbreviation for the JavaScript Object Code. It uses JavaScript syntax, and the design is only text.

Q232) Name the most important aspect of Java

Java is an independent language on a platform.

Q233) What is anonymous class?

A new class is defined as anonymous class without a name in a row of code.

Q234) What is a JVM?

JVM is a Java Virtual Machine, which is the operating system for compiled Java class files.

Q235) Can a Dead End Start Again?

No, a dead book can not start again.

Q236) Sort of ancient data types?

In Java, the rows are items.

Q237) What researchers are in Java?

In Java, the code set used to start a product.

Q238) Explain garbage in Java.

In Java, an object can no longer be used or specified, garbage collection is called and the material is automatically erased.

Q239) What’s the difference between the stack and the queue?

The difference between the stack and the line is that Stay is based on the Last In First Out (LIFO) policy and is based on the principle of FIFO (First, First Out).

Q240) What is a standard method?

Statistical methods can be called directly without creating an example (class) of the class. A stable method is directly accessible to all variables’ variables of a class, but it can not access standard variables without creating an example of class.

Q241) Explain the key word of Java

Super important tips for the parent class. There are many uses of the super key:

  • It is used to call the Super Class (Parent Class) Constructor.
  • It may be used to access the super class system hidden by the supplier (inviting parent class version, by applying the method).
  • Invite the parent class constructor.
Q242) The use of Java’s last words?

Final methods – These methods can not be violated any way.

Final variable – Constants, the value of this variable can not be altered.

Final Class – Such classes can not be obtained by other classes. The use of this type of classes can be used when security or someone does not want that particular class. Java’s final phase

Q243) What is the subject class?

This is a special class defined by Java; Other classes are subdivisions of the subject class. The subject class is superclass of other classes. The subject class consists of the following steps

  • Object-maternal () – means the object of creating a new object.
  • Objject Obj – determines whether an object is equal to another.
  • Final decision () – The garbage collector invites the garbage collection on a subject when it determines that the material does not exist. The subset system violates the final method for removing system resources or performing other cleansing actions.
  • toString () – The object returns a string representation.
Q244) What are the packages in Java?

A set of relevant categories (classes, interfaces, techniques, and references) are defined as a group. See: Package in Java.

Q245) What’s the difference between importing java.util.Date and java.util? *?

Star form (java.util. *) Includes all types of packages, and packages can increase the time – especially if you import multiple packages. However, this is not a run-time performance at any time.

Q246) What is the standard import?

See: Fixed import in Java.

Q247) Garbage collection in Java?

By using the new operator, Java automatically handles the de-reservation of memory, as things are allocated. This whole process is called garbage collection.

Q248) Decision Making in Java

The final method () method is used to release the reserved resources.

Q249) How many times do you call the trash cushion for the last time () method for an object?

The trash collector’s final object () method only calls once for an object.

Q250) How can garbage collection be enforced?

No, it’s not possible. You can not force garbage collection. You can call system.gc () method for garbage collection but there is no guarantee that garbage collection will be made.

Q251) What’s the exception?

Exceptions Unusual conditions during program program. This may be due to an incorrect logic written by an incorrect user input or programmer.

Q252) Are the exceptions defined in JavaScript packages? Or are there any definitions for all classes?

Java.lang.Exception

There are definitions for this set exceptions.

Q253) What are the types of exceptions?

There are two types of exceptions: the exceptions and the exceptions that are not deleted.

Verified Exceptions: These exceptions should be handled by the programmer, otherwise the program will reject the errata.

Unselected Exceptions: It is a programmer until you write the code to avoid unchecked exceptions. If you do not handle these exceptions, you can not get a compilation. These exceptions will occur in turn.

Q254) Difference between error and exception?

Error: Mostly complicated system. This occurs occasionally at run time and needs to be resolved to continue.

Exception: Most often an input data problem or wrong logic on the index. Compilation may occur in time or run times.

Q255) What is the key word in exceptional handling?

Throwing is used by throwing the main user defined or pre-defined exception.

Q256) What is the key word?

If once you have not checked a validated exception once, it should be reported using the throwskeyword. The key looks at the end of a hand signature.

Q257) Throwing in Java

Read the difference here: java – blowing blows.

Q258) Can the standard block be lifted?

Yes, a standard set of exceptions can be thrown out. It has its own limits: it runners exceptions (unselected exceptions).

Q259) What is banned?

Finally, the module always runs the code that is not an exception. The block to catch volume or effort to finally block the block follows.

Q260) NoClassDefFoundError versus ClassNotFoundException?

1) ClassNotFoundException Class can not load the required class on the track.

2) No error occured when loaded on NoClassDefFoundError class, but one or more of the class required by other classes can not be removed or packaged.

Q261) Can we try or do not try to stop it?

No, you can not try without it or finally stop it. One or both of them should be.

Q262) Is there a number of capture blocks after an endorsement line?

Yes, we can have multiple capture blocks to handle more than one exception.

Q263) Can finally ban without c block?

Yes, if we try to catch, we can use the black blade without catching the clasp.

If the last volume was not executed?

If called System.exit () or if JVM is disabled first, it will not be finalized at the same time.

Q264) Can you handle a catch in an exception to an exception?

Yes, we are using something else but it can not be considered a good practice. For an exception we must have a catch block.

Q265) What is Java Bean?

A Java Bean is the Java class, which follows some simple steps, in which the traditions are titled as the names and traditions of some of the methods. This is because the conventions are as follows, making it easy to process as a software tool that connects beans into the operating system. JavaBeans reusable software components.

Q266) Define JAVA

Sun Microsystems originally developed the high-level programming language “JAVA” and got released in the year 1995. Various platforms like Mac OS, Windows, and different UNIX versions are used to run Java.

Q267) Why do we say Java is dynamic?

Java is intended to acclimate to a developing environment. Java programs can carry a wide-ranging quantity of run-time data which can be utilized to validate and solve contacts to objects during run-time.

Q268) List out the different access specifiers available for Java classes

Below are the four (4) different types of access specifiers:

  • Protected
  • Public
  • Private
  • Default
Q269) Define Loops in Java

Loops in Java programming is to execute or block a statement frequently

Q270 ) Provide the different types of loops in Java

Three types of loops in Java

  • While Loops
  • Do While Loops
  • For Loops
Q271) List out the constructors in Java

Parameterized and Default are the two constructors in Java

Q272) List out the Oops concepts

Following are the Oops concepts:

  • Interface
  • Polymorphism
  • Abstraction
  • Encapsulation
  • Inheritance
Q273) Explain Method Overriding
le=”default” icon=”plus” anchor=”” class=””]

There are few conditions to be satisfied by subclass with super class to make Method overriding happen. The conditions are method name, argument and return type should be same.

Q274) Define Interface in Java

In Java, multiple inheritances is not possible. To solve these issues and get an option, Interface concept is presented in Java.

Q275) List out the advantages of Java packages

Packages in Java evade the name clashes, afford simpler access control, and make easy to locate the associated classes.

Q276) Do you know whether constructor returns any value in Java?

Yes, the constructor in Java returns the current instance of the class.

Q277) Is it possible to make a constructor final?

No, it is not possible to make a constructor final

Q278) Is it possible to overload the constructors?

Yes, it is possible to overload the constructors in Java by changing the arguments count which the constructor accepted.

Q279) Explain static block

You can use the static block to initialize the static data member. While classloading, the static block is executed before the main method.

Q280) Explain the keyword “this” in Java

The keyword “this” in Java is a variable which is referring to the current object. You can pass this keyword as an argument into constructors or methods.

Q281) Mention the class which is the superclass for the entire classes

In Java, object class is the superclass for the entire classes.

Q282) Define Aggregation

Aggregation – said to be a relationship between two (2) classes.

Q283) Explain the keyword “Super” in Java

The keyword “Super” is a reference variable which is for referring to the immediate parent class object.

Q284) List out the vital advantages of the keyword “Super”

The keyword “Super” is used to raise the immediate parent class method and immediate parent class constructor.

Q285) Is it possible to use both “this()” and “super()” in a constructor?

No, it is not possible to use both “this()” and “super()” in a constructor.

Q286) Will you be able to overload the main() method?

Yes, we can overload the main() method with the use of method overloading.

Q287) Explain final variable

Final variable in Java is for restricting the user from updating it. When initializing the final variable, it is not possible to change the value. To be very clear, when the final variable is allotted to value, they can never be modified. If you find a final variable not assigned to any value, they can be assigned via a class constructor.

Q288) Is possible for you to declare a constructor as final?

We cannot declare a constructor as final as it is never inborn. It is very clear that constructors are not normal approach, hence it is of no use in declaring the constructors as final. If trying to declare so, you will receive an error from the compiler.

Q289) Mention the difference between abstract and final method

It is necessary to override the abstract method in the subclass to provides its definition and hence the abstract method cannot be declared as final.

Q290) Explain the purpose of encapsulation

Encapsulation maintains and protects the code from others.

Q291) Explain Polymorphism

Any kind of forms is said to be polymorphism. Based on the reference type, a single object can refer to the sub-class or super class. This method is known as polymorphism.

Q292) Define Java Collections

Java Collection is a framework which is intended to store the objects and operate the pattern to stockpile the objects.

Q293) What are the operations of collections?

Following are the operations performed by collections in Jav

  • Insertion
  • Manipulation
  • Searching
  • Deletion
  • Sorting
Q294) List out the interfaces available in Java collections
” open=”no” style=”default” icon=”plus” anchor=”” class=””]

Interface available in Java collections are Sorted Set, Collection, Map, Set” open=”no” style=”default” icon=”plus” anchor=”” class=””], Sorted Map, List, and Queue.

Q295) List out the Classes available in Java collections

Classes available in Java collections are Array List, Linked List, Lists and Vector.

Q296) List out the maps available in Java collections

Treemap, Hash Table, Hash Map, and Linked Hashed Map are the four (4) maps available in Java collections

Q297) Can you give an example of pointers?

We cannot use pointers as there is no a concept called pointers in Java.

Q298) Provide the features of Hashtable method

Hashtable is synchronized and thread-safety. Hashtable enumerator is helpful to iterate the values and do not allow anything which is null. Performance of Hashtable is always slow.

Q299) Explain HashSet

Inserted elements of HashSet are listed in random order and it can easily store null objects. Performance of HashSet is always high.

Q300) Explain TreeSet Tree set upholds the elements in an organized order and it cannot store null objects.

TreeSet performance is always slow.

Q301) What are the types of exceptions in Java?

There are two (2) types of exceptions in Java

Unchecked Exception and Checked Exception are the two (2) type of exceptions in Java.

Q302) Mention the different methods to handle exceptions

Declaring throws keyword and Using try/catch are the two (2) methods available in Java to handle exceptions.

Q303) Provide the benefits of exception handling

When handling the exception, the standard execution flow will never be terminated. With the use of catch declaration, it is useful to recognize the issues.

Q304) Provide the exception handling keywords available in Java

There are three (3) exception handling keywords available in Java which are try, catch and finally.

Q305) Describe Thread in Java

The execution flow in Java is called ‘Thread’. Java will always have the main thread, which is created by JVM (Java Virtual Machine). By executing a runnable interface or spreading thread class, users can describe their individual threads.

Q306) Describe wait () method

To enable the thread to wait in the waiting pool, we can use the method wait (). Wait () method intimates the thread to pause for a provided quantity of time. When called using notify () or notify all () method, the thread wakes up.

Q307) Explain notify () and notify all () methods

notify (): To enable a single thread to wake up from the waiting pool, notify () method is used.

notify all (): To enable all the threads to wake up from the waiting pool, notify all () method is used.

Q308) Provide the list of thread methods to stop a thread in Java

Blocked, Sleeping and Waiting are the three (3) thread methods to stop a thread in Java

Q309) Describe the thread life cycle of Java

The thread life cycle of Java is given below:

New -> Runnable -> Running -> Non-runnable -> Terminated

Q310) Define Serialization

Users can convert a file into a byte stream and this process is known as Serialization. The conversion is performed for safety purpose. To achieve this process, java.io.Serializable interface must be implemented.

Q311) What is the benefit of Volatile Variable

The values which are constantly recited from the main memory, but not from thread’s cache memory are said to be the Volatile Variable. Volatile Variable is useful at the time of synchronization.

Q312) Provide byte datatype default value in Java

In Java, byte datatype default value is zero (0).

Q313) Explain applet

There are many Java programs and one among them is applet which runs in the Web browser. Applet has the whole Java API at its clearance.

Q314) Define Use Cases in Java

Use cases are the vital part of the program analysis, defining a state for us which a program might come across and the program behavior that needs to be revealed in that condition.

Java is being always the best and trending course for over 20 years. Our Java training in Chennai by Besant Technologies is ranked as best training institute by many people who got trained under this course. There are lots of job openings for Java developer and also there for many mobile applications development companies. In this blog, we are posting the best and top 100 Java interview questions and answers.

These Java interview questions and answers were prepared by the experienced and talented trainers and tutors from our institute and also by the Java developer those who are having 5+ years of experience.

Whether you are a fresher or highly experienced professional, java plays a vital role in any Java/JEE interview. Java is the favorite area in most of the interviews and plays a crucial role in deciding the outcome of your interview. This post is about java interview questions and answers.

As a Java professional, it is essential to know the right buzzwords, learn the right technologies and prepare the right answers to common Java Interview Questions and answers. Learn and study this Java interview questions and answers, move your carrier to the next level.

Besant Technologies – Chennai & Bangalore Branch Locations

Besant Technologies - Velachery Branch

Plot No. 119, No.8, 11th Main road, Vijaya nagar,

Velachery, Chennai - 600 042

Tamil Nadu, India

Landmark - Reliance Digital Opposite Street

Besant Technologies - Tambaram Branch

No.2A, 1st Floor, Duraisami Reddy Street,

West Tambaram, Chennai - 600 045

Tamil Nadu, India

Landmark - Near By Passport Seva

Besant Technologies - OMR Branch

No. 5/318, 2nd Floor, Sri Sowdeswari Nagar,

OMR, Okkiyam Thoraipakkam, Chennai - 600 097

Tamil Nadu, India

Landmark - Behind Okkiyampet Bus Stop,

Besant Technologies - Porur Branch

No. 180/84, 1st Floor, Karnataka Bank Building,

Trunk Road, Porur, Chennai - 600 116

Tamil Nadu, India

Landmark - Opposite to Gopalakrishna Theatre

Besant Technologies - Anna Nagar Branch

Plot No:1371, 28th street kambar colony,

I Block, Anna Nagar, Chennai - 600 040

Tamil Nadu, India

Landmark - Behind Reliance Fresh

Besant Technologies - T.Nagar Branch

Old No:146/2- New No: 48,

Habibullah Road,T.Nagar, Chennai - 600 017

Tamil Nadu, India

Landmark - Opposite to SGS Sabha

Besant Technologies - Thiruvanmiyur Branch

22/67, 1st Floor, North mada street, Kamaraj Nagar

Thiruvanmiyur, Chennai 600041

Tamil Nadu, India

Landmark - Above Thiruvanmiyur ICICI Bank

Besant Technologies - Siruseri Branch

No. 4/76, Ambedkar Street, OMR Road, Egatoor, Navallur,

Siruseri, Chennai 600130

Tamil Nadu, India

Landmark - Near Navallur Toll Gate, Next to Yamaha Showroom

Besant Technologies - Maraimalai Nagar Branch

No.37, Ground Floor, Thiruvalluvar Salai,

Maraimalai Nagar,Chennai 603209

Tamil Nadu, India

Landmark - Near to Maraimalai Nagar Arch

Besant Technologies - BTM Layout Branch

No 2, Ground floor, 29th Main Road,

Kuvempu Nagar,BTM Layout 2nd Coming from Silkboard,

AXA company signal, Stage, Bangalore - 560 076

Karnataka, India

Landmark - Next to OI Play School

Besant Technologies - Marathahalli Branch

No. 43/2, 2nd Floor, VMR Arcade,

Varthur Main Road, Silver Springs Layout,

Munnekollal, Marathahalli, Bengaluru - 560037

Karnataka, India

Landmark - Near Kundalahalli Gate Signal

Besant Technologies - Rajaji Nagar Branch

No. 309/43, JRS Ecstasy, First Floor,

59th Cross, 3rd Block, Bashyam Circle,

Rajaji Nagar, Bangalore - 560 010

Karnataka, India

Landmark - Near Bashyam Circle

Besant Technologies - Jaya Nagar Branch

No. 2nd Floor,1575,11th Main Road,

4th T-Block, Pattabhirama Nagar,

Jaya Nagar, Bangalore - 560 041

Karnataka, India

Landmark - Opposite to Shanthi Nursing Home

Besant Technologies - Kalyan Nagar Branch

No.513, 4th Cross Rd

2nd Block, HRBR Layout,

Kalyan Nagar, Bangalore - 560 043

Karnataka, India

Landmark - Opposite to kalayan nagar Axis Bank

Besant Technologies - Electronic City Branch

No. 7, 3rd Floor, Ganga Enclave,

Neeladri Road, Karuna Nagar, Doddathoguru Village,

Electronics City Phase 1, Electronic City,

Bangalore - 560100, karnataka, India

Landmark - Adjacent to HDFC Bank and State Bank Of India

Besant Technologies - Indira Nagar Branch

No.54, 1st Floor,

5th Main kodihalli,

Bengaluru, Karnataka 560008, India

Landmark - Behind Leela Palace Hotel,

Besant Technologies - HSR Layout Branch

Plot No. 2799 & 2800, 27th Main,

1st Sector, HSR Layout,

Bengaluru, Karnataka 560102, India

Besant Technologies - Hebbal Branch

No.29, 2nd Floor, SN Complex,

14th Main Road, E-Block Extention, Sahakara Nagar,

Bengaluru, Karnataka -560092, India

Scroll Up