0% found this document useful (0 votes)
2 views

Java qns

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java qns

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Java

1. Explain OOPS concepts.


2. What is transient keyword.
The transient keyword in Java is used to avoid serialization. If any object of a data
structure is defined as a transient , then it will not be serialized.
Serialization is the ​process of converting an object into a byte stream.

3. What is serialization and deserialization in java.


Serialization is a mechanism of converting the state of an object into a byte stream.
Deserialization is the reverse process where the byte stream is used to recreate the actual
Java object in memory. ... So, the object serialized on one platform can be deserialized on a
different platform.

4. What is static keyword and how is it used in java


the keyword static indicates that the particular member belongs to a type itself, rather than
to an instance of that type.
This means that only one instance of that static member is created which is shared across
all instances of the class.
uses:-
static keyword is mainly used for memory management. It can be used with variables,
methods, blocks and nested classes.
It is a keyword which is used to share the same variable or method of a given class.
Basically, static is used for a constant variable or a method that is same for every instance
of a class.

5. What is exception handling in java?


The Exception Handling in Java is one of the powerful mechanism to handle the runtime
errors so that the normal flow of the application can be maintained.
In this tutorial, we will learn about Java exceptions, it's types, and the difference between
checked and unchecked exceptions
1) Checked Exception
The classes that directly inherit the Throwable class except RuntimeException and Error
are known as checked exceptions.
For example, IOException, SQLException, etc. Checked exceptions are checked at
compile-time.

2) Unchecked Exception
The classes that inherit the RuntimeException are known as unchecked exceptions.
For example, ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException,
etc. Unchecked exceptions are not checked at compile-time, but they are checked at runtime.
3) Error
Error is irrecoverable. Some example of errors are OutOfMemoryError, VirtualMachineError,
AssertionError etc.
6. What are runtime and compile time exceptions
7. What is difference between checked and unchecked exceptions in java.

8. Explain Try Catch and Finally blocks.


Try We specify the block of code that might give rise to the exception in a special
block with a “Try” keyword.
Catch When the exception is raised it needs to be caught by the program. This is done
using a “catch” keyword.
So a catch block follows the try block that raises an exception. The keyword catch
should always be used with a try.
Finally Sometimes we have an important code in our program that needs to be executed
irrespective of whether or not the exception is thrown.
s This code is placed in a special block starting with the “Finally” keyword. The Finally
block follows the Try-catch block.
Throw The keyword “throw” is used to throw the exception explicitly.
Throws The keyword “Throws” does not throw an exception but is used to declare
exceptions. This keyword is used to indicate that an exception might occur in the program or
method.

9. What is Method overloading and overriding


10. What is super class/interface for exception
11. What is super class/interface for collection
12. Difference between list and set
13. Difference between HashMap and Hashtable
14. How HashMap works internally
15. What is hash code in java?
16. Explain override equals method
17. What is the difference between comparable and comparator?
18. Mention methods provided by list and map interfaces.
19. Is collections thread safe? If not, how can we make them thread safe?
20. What is java 8 features
21. What is latest version in java and what is its new features.
22. What are streams and what is its advantages.
23. What are some java pre-defined functional interfaces?
24. What are various categories of predefined functional interfaces.
25. What is an optional class.
26. What is a functional Interface and how it is used?
27. Explain about string constant pool in java.
28. What is heap dump in java refer to?
29. What are the methods present in Object class.
30. What are marker interfaces
31. What is multithreading in java
32. What is thread in java and what are two ways we can implement thread in java.
33. What is the difference between class lock and object lock?
34. What is wait() sleep() notify() notifyAll() in multithreading.
35. What is difference start and run methods.

Java Programming Questions


String manipulation questions :
Write a program for string palindrome
Write a program to reverse a string
Write a program to eliminate duplicate characters in a string
Write a program to find highest occurred character
Write a program where input is a string – Testing output T2e1s1i1n1g1
Rest API
1. What are Rest API’s?
2. What are the advantages of microservices architecture over a monolithic application?
3. What different http methods supported by rest api.
4. How do we implement security for rest API’s?
5. What are various design principles we need to follow while developing a rest API?
6. What is the difference between put and Post?
7. What is service discovery and how can we achieve it?

You might also like