0% found this document useful (0 votes)
2 views3 pages

Java Interview Questions

The document contains a list of interview questions and answers related to Java and software development, including topics like SNMP, garbage collection, design patterns, and differences between JDK, JRE, and JVM. Key concepts such as collections, thread deadlock, and memory management are also discussed. It serves as a guide for candidates preparing for Wipro interviews, focusing on technical knowledge and problem-solving skills.

Uploaded by

iamafreenfiza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Java Interview Questions

The document contains a list of interview questions and answers related to Java and software development, including topics like SNMP, garbage collection, design patterns, and differences between JDK, JRE, and JVM. Key concepts such as collections, thread deadlock, and memory management are also discussed. It serves as a guide for candidates preparing for Wipro interviews, focusing on technical knowledge and problem-solving skills.

Uploaded by

iamafreenfiza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Wipro interview qns?

Wednesday, September 16, 2020 2:57 PM

1. Current organisation
2. Roles and responsibility
3. Where and how SNMP is used in ur project
4. When and where to use which collection
5. How garbage collection works
6. Difference in Jdk and jre
7. What’s the role of jvm
8. How jre and jvm is related
9. What of design patterns used and worked
10. String with 1 & 0 values in it, how to take out 0 or count 0 without loop
11. While loop with condition always true , inside loop you are creating the object of a class and Syso it. What will happen.
12. What is out of memory exception and how will you manage it
13. What are the key areas you would keep in mind when creating the HLD
14. What is thread deadlock
15. What is thread pool
Answers :
Q4. When and where to use which collection?
The key interfaces used by the collection framework are List, Set and Map. The List and Set extends the
Collection interface. Should not confuse the Collection interface with the Collections class which is a utility class.
A Set is a collection with unique elements and prevents duplication within the collection. HashSet and TreeSet
are implementations of a Set interface. A List is a collection with an ordered sequence of elements and may
contain duplicates. ArrayList, LinkedList and Vector are implementations of a List interface.
The Collection API also supports maps, but within a hierarchy distinct from the Collection interface. A Map is an
object that maps keys to values, where the list of keys is itself a collection object. A map can contain duplicate
values, but the keys in a map must be distinct. HashMap, TreeMap and Hashtable are implementations of a Map
interface.
How to implement collection ordering? SortedSet and SortedMap interfaces maintain sorted order. The
classes, which implement the Comparable interface, impose natural order. For classes that don’t implement
comparable interface, or when one needs even more control over ordering based on multiple attributes, a
Comparator interface should be used.
Design pattern: What is an Iterator? An Iterator is a use once object to access the objects stored in a collection.
Iterator design pattern (aka Cursor) is used, which is a behavioural design pattern that provides a way to access
elements of a collection sequentially without exposing its internal representation.

Q5. How garbage collection works.


Each time an object is created in Java, it goes into the area of memory known as heap. The Java heap is called
the garbage collectable heap. The garbage collection cannot be forced. The garbage collector runs in low
memory situations. When it runs, it releases the memory allocated by an unreachable object. The garbage
collector runs on a low priority daemon (background) thread. You can nicely ask the garbage collector to collect
garbage by calling System.gc() but you can’t force it.
What is an unreachable object? An object’s life has no meaning unless something has reference to it. If you
can’t reach it then you can’t ask it to do anything. Then the object becomes unreachable and the garbage collector
will figure it out. Java automatically collects all the unreachable objects periodically and releases the memory
consumed by those unreachable objects to be used by the future reachable objects.

We can use the following options with the Java command to enable tracing for garbage collection events.
-verbose:gc reports on each garbage collection event.
Explain types of references in Java? java.lang.ref package can be used to declare soft, weak and phantom
references.
ô Garbage Collector won’t remove a strong reference.
ô A soft reference will only get removed if memory is low. So it is useful for implementing caches while
avoiding memory leaks.
ô A weak reference will get removed on the next garbage collection cycle. Can be used for implementing
canonical maps. The java.util.WeakHashMap implements a HashMap with keys held by weak references.
ô A phantom reference will be finalized but the memory will not be reclaimed. Can be useful when you want to
be notified that an object is about to be collected.

Q6. Difference in Jdk and jre


Sr. No. Key JDK JRE JVM
1 Definitio JDK (Java Development Kit) JRE (Java Runtime Environment) JVM (Java Virtual Machine) is an abstract
n is a software development is the implementation of JVM and machine that is platform-dependent and has
kit to develop applications in is defined as a software package three notions as a specification, a document that
Java. In addition to JRE, JDK that provides Java class libraries, describes requirement of JVM implementation,
also contains number of along with Java Virtual Machine implementation, a computer program that
development tools (JVM), and other components to meets JVM requirements, and instance, an
(compilers, JavaDoc, Java run applications written in Java implementation that executes Java byte code
Debugger etc.). programming. provides a runtime environment for executing
Java byte code.
2 Prime JDK is primarily used for On other hand JRE is majorly JVM on other hand specifies all the
functiona code execution and has responsible for creating implementations and responsible to provide
lity prime functionality of environment for code execution. these implementations to JRE.
development.
3 Platform JDK is platform dependent Like of JDK JRE is also platform JVM is platform independent.
Independ i.e for different platforms dependent.
ence different JDK required.
4 Tools As JDK is responsible for On other hand JRE does not JVM does not include software development
prime development so it contain tools such as compiler or tools.
contains tools for debugger etc. Rather it contains
developing, debugging and class libraries and other
monitoring java application. supporting files that JVM requires
to run the program.
5 Impleme JDK = Java Runtime JRE = Java Virtual Machine (JVM) JVM = Only Runtime environment for executing
ntation Environment (JRE) + + Libraries to run the application the Java byte code.
Development tools

You might also like