[Go to site: main page, start]

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

Core Java Interview Questions Guide

This document contains questions about core Java concepts and programming techniques. It covers topics like Java fundamentals, OOP concepts, memory areas, exceptions, collections, strings and more. Multiple choice, coding and output based questions are included to test Java skills.

Uploaded by

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

Core Java Interview Questions Guide

This document contains questions about core Java concepts and programming techniques. It covers topics like Java fundamentals, OOP concepts, memory areas, exceptions, collections, strings and more. Multiple choice, coding and output based questions are included to test Java skills.

Uploaded by

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

Core Java Interview Questions

What is Java? Explain its meaning and definition.


The syntax of Java is based on which programming language?
How is Java platform independent?
When was Java developed?
What does `write once run anywhere' mean in Java?
What is Java Virtual Machine (JVM)?
What is Java Runtime Environment (JRE)?
What is Java SE (Standard Edition)?
What are operators in Java?
What are the different types of Java operators?
What is JIT compiler in Java?
What is a package in Java?
What are Tokens in Java?
What is difference between Java and JavaScript?
Which Java class is considered a superclass of all other classes?
Is it possible for a class to extend itself?
Is it possible to assign a superclass to a subclass in Java?
How to print text in Java?
What is multithreading in Java?
Which class is used for multithreading in Java?
What is Java applet?
What is garbage collection in Java?
What if you use Java keywords as a variable or identifier?
What is inheritance in Java?
What is polymorphism in Java?
What is encapsulation in Java?
What is serialization in Java?
What is Java JDBC?
What is constructor overloading in Java?
What is copy constructor in Java?
Which keyword in Java is used to inherit a class?
What are the top benefits of inheritance in Java?
What are the different memory areas assigned by JVM?
What are access modifiers in Java?
How many types of inheritance are there in Java?
Can you restrict an object from inheriting its subclass? If yes, how?
How can we remove the duplicate elements from a list of numbers if Java 8 is being
used?
What is the difference between heap memory and stack memory in Java?
What is the difference between equals() method and equality (==) operator in Java?
Can you inherit static members to a subclass?
Can you override the final method in Java?
How to declare an infinite loop in Java?
What are the roles of final, finally, and finalize keywords in Java?
When to use the super keyword in Java?
What is a ClassLoader in Java?
What are the different types of ClassLoaders in Java?
Is it possible to access the members of a subclass if you create a superclass'
object?
How to define a functional interface in Java?
Difference between Error and Exception in Java?
Difference between checked and unchecked Exception in Java?
Why Java doesn't support multiple inheritances?
Why wait and notify method are declared in **Object** class in Java?
Difference between this and super in Java?
What is the **String** pool in Java?
Can we access the private method in Java?
Can we override static method in Java?
Difference between **StringBuilder** and **StringBuffer** in Java?
How do you restrict your class from being used by your client?
Difference between method overloading and overriding in Java?
When do you use **Runnable** vs **Thread** in Java?
a=new b(); explain this statement?
what is wait() and sleep() methods?
What is inner process of array list?
Programming based questions
How do you reverse a string in Java?
How do you swap two numbers without using a third variable in Java?
Write a Java program to check if a vowel is present in a string
How do you swap two numbers without using a third variable in Java?
Write a Java program to print a Fibonacci sequence using recursion.
How do you check whether a string is a palindrome in Java?
How do you remove spaces from a string in Java?
How do you sort an array in Java
How do you create a deadlock scenario programmatically in Java?
How can you find the factorial of an integer in Java?
How do you reverse a linked list in Java?
Can you create a pyramid of characters in Java?
Write Java program that checks if two arrays contain the same elements
How do you get the sum of all elements in an integer array in Java?
How do you find the second largest number in an array in Java?
How do you print a date in specific format in Java?
Can you prove that a String object in Java is immutable programmatically?
Can you write some code to showcase inheritance in Java?
How do you use the forEach() method in Java?
Show examples of overloading and overriding in Java
Guess the Output:
String s1 = "abc";
String s2 = "abc";

[Link]("s1 == s2 is:" + s1 == s2);


output.....?
String s3 = "JournalDev";
int start = 1;
char end = 5;

[Link]([Link](start, end));
output......?

try {
if (flag) {
while (true) {
}
} else {
[Link](1);
}
} finally {
[Link]("In Finally");
}
output.....?

String str = null;


String str1="abc";

[Link]([Link]("abc") | [Link](null));
output.....?

Common questions

Powered by AI

Method overloading occurs when multiple methods have the same name but different parameters within the same class, allowing different ways to handle similar operations. In contrast, method overriding involves a subclass redefining a method with the same name and parameters as a method in its superclass to provide specific functionality. Overloading is used for offering multiple ways to perform similar operations, while overriding is used for implementing specific behavior in subclasses .

Java does not support multiple inheritance to avoid complexity and ambiguity caused by the 'diamond problem'. Instead, it uses interfaces to achieve code reusability. By defining shared methods in interfaces, Java allows varying implementation in multiple classes, providing flexibility without inheritance-related ambiguities .

Java's access modifiers control encapsulation by restricting access to classes, methods, and variables. 'Public' allows complete access, 'protected' offers access within the same package and subclasses, 'package-private' (default) restricts access to only the package, and 'private' restricts access to the defining class. This ensures a controlled environment for data exposure, promoting encapsulation by providing varying degrees of access depending on the need .

A deadlock can be created in Java by having two or more threads holding locks while waiting indefinitely for another lock held by another thread. This can occur when threads acquire locks in different orders. To prevent deadlocks, it is essential to establish a consistent lock acquisition order and use timed locks or tryLock() methods that allow the thread to back off after a time-out .

Java achieves platform independence through the use of the Java Virtual Machine (JVM). The source code is compiled into bytecode, which can be executed on any device that has a compatible JVM, allowing Java programs to run on any platform without recompilation. This is known as 'write once, run anywhere' .

The synchronized keyword in Java ensures that only one thread can access a block or method at a time, providing thread safety. However, it can lead to reduced performance due to excessive locking and a potential for deadlocks. Synchronized code blocks can be less responsive because they increase the waiting time for threads .

Garbage collection in Java is an automatic process of reclaiming memory by deleting objects no longer reachable in the application. It prevents memory leaks by freeing up memory resources for new objects. This impacts memory management by optimizing available memory and improving program efficiency but may introduce occasional pauses during its execution .

The 'throws' keyword is used in a method signature to declare that a method can throw exceptions, allowing the caller to handle them. In contrast, 'throw' is used within a method to explicitly throw an exception. While 'throws' signals possible exception handling, 'throw' actively triggers an exception to signal a problem .

The 'final' keyword is used to declare constants or prevent inheritance or overriding. 'finally' is a block used to execute important code such as closing connections, which runs regardless of an exception. 'finalize' is a method called by the garbage collector when an object is about to be garbage collected, allowing resource cleanup. Each serves a unique purpose in ensuring program stability and resource management .

Heap memory is used for dynamic memory allocation where objects are stored, and it is shared among all threads. Stack memory is used for static memory allocation and stores local variables and method calls, which are thread-specific. Heap memory impacts performance due to slower access time, but provides more flexibility with memory allocation than stack memory, which has faster access time but limited space .

You might also like