TUTORIAL VIDEO


INTERVIEW QUESTIONS

Java is a high-level, object-oriented programming language developed by Sun Microsystems (now owned by Oracle). Its key features include platform independence (Write Once, Run Anywhere), automatic garbage collection, and support for multithreading and distributed computing.

JDK (Java Development Kit) is a complete environment for Java development, including tools like the compiler and debugger. JRE (Java Runtime Environment) provides libraries and JVM for running Java programs. JVM (Java Virtual Machine) executes Java bytecode and enables platform independence.

The == operator checks for reference equality, meaning whether two object references point to the same memory location. The equals() method checks for logical equality and can be overridden in a class to define equality based on the object's properties.

The main principles of OOP are:
  • Encapsulation: Binding data and methods together.
  • Inheritance: Deriving new classes from existing ones.
  • Polymorphism: Using methods in different ways.
  • Abstraction: Hiding implementation details from the user.

Access modifiers define the scope of accessibility for classes, methods, and variables. The four types are:
  • Public: Accessible from anywhere.
  • Protected: Accessible within the same package and subclasses.
  • Default: Accessible within the same package.
  • Private: Accessible only within the same class.

The static keyword in Java indicates that a member (variable or method) belongs to the class rather than any specific instance of the class. Static members can be accessed without creating an object of the class.

A constructor is a special method in Java used to initialize objects. It has the same name as the class and does not have a return type. Constructors can be default (no arguments) or parameterized.

Exceptions in Java are unexpected events that disrupt the normal flow of a program. They are handled using try-catch blocks. The try block contains code that might throw an exception, while the catch block handles it. The finally block, if present, executes regardless of exceptions.

Arrays are fixed in size and can store only elements of a specific data type. ArrayLists, part of the Java Collections Framework, are dynamic in size and can grow or shrink as needed. ArrayLists provide more functionality but are slower due to overhead.

An abstract class can have both abstract and concrete methods and is used for classes with a common base. An interface only contains abstract methods (until Java 8 introduced default methods) and is used to define a contract that classes must implement.

QUIZ

1. What is Java?

A programming language
A database
An operating system

2. Which of the following is not a Java feature?

Object-oriented
Platform-independent
Hardware-dependent

3. Which keyword is used to create a class in Java?

function
class
method

4. What is the extension of Java compiled files?

.java
.class
.exe

5. Which method is used to start a Java program?

main
start
run