Experience Top-Rated Tutoring – 4.3/5 ★★★★★ by Parents & Students
Course Details
JOIN OUR

Java Language

Book a free trial session and start your personalized learning journey with our expert tutors.

Send Us Your Enquiry To Get Started

Fill out the form below and one of our experts will contact you shortly

TutorX Smart Learning Dashboard

Everything You Need, All in One Place

TutorX Learning Platform

At The TutorX, we believe learning should be clear, focused, and at your fingertips. That’s why we’ve built a smart and user-friendly dashboard to empower every student on their academic journey. From live sessions and homework to performance tracking and resources—everything is seamlessly integrated to help you stay ahead with confidence.

  • View upcoming sessions and join with a single click.
  • Track your progress through weekly reports.
  • Access study materials tailored to your goals.
  • Get reminders so you never miss a session.
  • Connect with tutors and ask questions anytime.
Tutela Dashboard

Java Tutorial | Learn Java Programming Language

What is Java?

Java is a high-level, class-based, object-oriented programming language developed by James Gosling at Sun Microsystems and released in 1995. Java follows the principle of "Write Once, Run Anywhere" (WORA) — compiled Java code can run on all platforms that support the Java Virtual Machine (JVM) without recompilation. Java is one of the most popular and widely used programming languages in the world, used in web development, mobile apps (Android), enterprise applications, big data, cloud computing, and embedded systems.

Java is strongly typed, statically typed, and platform-independent. It automatically manages memory through garbage collection, eliminating manual memory management. Java's syntax is heavily influenced by C and C++, making it familiar to many developers. The current long-term support version is Java 21 (released 2023), with major improvements in records, sealed classes, pattern matching, and virtual threads.

How Java Works — JDK, JRE and JVM

JDK — Java Development Kit Development tools: javac (compiler), jar, javadoc, jdb (debugger) JRE — Java Runtime Environment Standard Libraries: java.lang, java.util, java.io, java.net, javax... JVM — Java Virtual Machine Class Loader Loads .class files into RAM Bytecode Verifier Security check JIT Compiler Bytecode → Machine code Memory (Heap + Stack) Objects, method frames Garbage Collector Auto memory cleanup Compilation Flow Hello.java Source code (.java) javac Hello.class Bytecode (.class) JVM Machine Code Platform-specific Output Program runs! Run: java Hello No recompile needed!

JVM (Java Virtual Machine): An abstract computing machine that enables Java portability. It interprets compiled bytecode and provides runtime services like memory management and garbage collection. Each operating system has its own JVM implementation — this is what makes Java platform-independent.

JRE (Java Runtime Environment): Provides the minimum requirements to run a Java program — JVM + Java class libraries. End users who only need to run Java apps need the JRE. It does not include development tools like the compiler.

JDK (Java Development Kit): Complete development environment — JRE + development tools (javac compiler, debugger, profiler, jar tool, javadoc). Developers need JDK to write and compile Java programs.

Java Data Types and Variables

Primitive and Reference Data Types in Java

Java is a statically typed language — every variable must be declared with a type before use. Java has two categories of data types: Primitive types (8 built-in types that store simple values directly in memory) and Reference types (objects, arrays, and strings that store a reference/address to the data).

Primitive Data Types (8) byte 1 byte | -128 to 127 byte b = 100; short 2 bytes | -32,768 to 32,767 short s = 1000; int 4 bytes | ~±2.1 billion int x = 42; long 8 bytes | very large integers long l = 99L; float 4 bytes | decimal (~6-7 digits) float f = 3.14f; double 8 bytes | decimal (~15 digits) double d = 3.14; char 2 bytes | single Unicode char char c = 'A'; boolean 1 bit | true or false only boolean ok = true; Reference Types String String name = "Alice"; // immutable! Array int[] arr = {1, 2, 3, 4, 5}; Class / Object Student s = new Student(); Interface / Abstract class Widening: auto | Narrowing: (type)cast int → long (auto) | long → int (cast)

Variable types in Java: Local variables (declared inside methods — must be initialized before use), Instance variables (declared inside class but outside methods — belong to object), Class/Static variables (declared with static keyword — shared by all instances).

Type casting: Widening conversion (smaller to larger — automatic): byte → short → int → long → float → double. Narrowing conversion (larger to smaller — explicit cast required): double d = 9.99; int x = (int) d; // x = 9, decimal truncated.

Wrapper Classes: Every primitive has an object equivalent — int → Integer, double → Double, char → Character, boolean → Boolean, etc. Used with collections (ArrayList<Integer>). Autoboxing (int → Integer) and unboxing (Integer → int) happen automatically in Java 5+.

String in Java: String is immutable — once created, its value cannot be changed. String operations create new objects. Use StringBuilder for mutable string operations (more efficient). String pool: Java reuses string literals from a pool to save memory.

Java OOPs Concepts

Object-Oriented Programming in Java

Java is a purely object-oriented language — everything (except primitives) is an object. Java OOP is built on four fundamental pillars: Encapsulation, Abstraction, Inheritance, and Polymorphism. These principles make Java code modular, reusable, maintainable, and scalable.

public class Employee { private String name; private int age; private double salary; // instance vars public Employee(String n, int a, double s){ this.name = n; this.age = a; this.salary = s; } public String getName() { return name; } public void setSalary(double s) { salary = s; } @Override public String toString() { return name+":"+salary; } } Class Components Fields (Instance Variables): Data stored by each object. private = encapsulated. Constructor: Called with new. Same name as class. No return type. this refers to current object. Getter / Setter Methods: Access private fields safely. Core of encapsulation. @Override toString(): Custom string output when object is printed. Employee e = new Employee( "Alice", 28, 75000.0);

Encapsulation: Binding data (fields) and methods together inside a class. Making fields private and providing public getters/setters. Protects data from direct unauthorized access. JavaBeans pattern follows encapsulation strictly.

Abstraction: Hiding implementation details and showing only necessary features. Achieved using abstract classes (abstract keyword) and interfaces. An abstract class can have both abstract methods (no body) and concrete methods (with body). You cannot instantiate an abstract class.

this keyword: Refers to the current object instance. Used to: differentiate between instance variables and parameters (this.name = name), call another constructor (this()), pass current object as argument.

static keyword: Belongs to the class rather than any instance. Static variables (shared by all objects), static methods (called on class, not object — Math.sqrt()), static blocks (run once when class loads). Cannot access instance variables inside static context.

final keyword: final variable — value cannot be changed (constant). final method — cannot be overridden. final class — cannot be subclassed (e.g., String is final). Used with static for constants: static final double PI = 3.14159;

Java Inheritance

What is Inheritance in Java?

Inheritance allows a class (child/subclass) to acquire the properties and behaviors of another class (parent/superclass). Java uses the extends keyword for class inheritance. Java supports single inheritance for classes (a class can extend only one class) but multiple inheritance through interfaces. Inheritance promotes code reusability and establishes an IS-A relationship.

java.lang.Object Root of all Java classes class Animal String name; void eat(){} class Dog extends Animal void bark(){} void eat(){} // override class Cat extends Animal void meow(){} @Override eat(){} class Bird extends Animal void fly(){} @Override eat(){} class Poodle extends Dog super keyword super.eat(); / super(name);

super keyword: Refers to the parent class. super.method() calls the parent's version of the method. super() calls the parent constructor — must be the first statement in a constructor. Java automatically calls super() if you don't.

Method Overriding: A subclass provides a specific implementation of a method already defined in the parent class. Rules: same name, same parameters, same or covariant return type. @Override annotation is recommended (catches errors at compile time). Cannot override static, final, or private methods.

Method Overloading: Multiple methods with the same name but different parameters (different number, type, or order). Resolved at compile time (static polymorphism). Return type alone is not enough to overload — parameters must differ.

instanceof operator: Checks if an object is an instance of a specific class. if (animal instanceof Dog) { Dog d = (Dog) animal; d.bark(); }. Java 16+ pattern matching: if (animal instanceof Dog d) { d.bark(); } — combines check and cast.

Java Interfaces and Abstract Classes

Interface vs Abstract Class in Java

Both interfaces and abstract classes are used to achieve abstraction in Java. An abstract class is a class that cannot be instantiated and may contain a mix of abstract and concrete methods. An interface defines a contract — a set of method signatures that implementing classes must fulfill. A class can implement multiple interfaces but extend only one class.

Interface public interface Flyable { void fly(); // abstract default void land() { System.out.println("land"); } static void info() { System.out.println("fly!"); } } ✦ All methods abstract by default ✦ default methods (Java 8+) ✦ static methods (Java 8+) ✦ implements (multiple allowed) ✦ Fields are public static final Abstract Class public abstract class Shape { String color; // field allowed abstract double area(); // no body void display() { // concrete System.out.println(area()); } } class Circle extends Shape { double r; double area(){return 3.14*r*r;} } ✦ Can have constructor, fields ✦ extends (only one)

When to use Interface vs Abstract Class: Use Interface when unrelated classes should share a behavior contract (Comparable, Runnable, Serializable). Use Abstract Class when classes are closely related and share state (fields) and some common implementation. Java 8+ interfaces with default methods blur this distinction somewhat.

Functional Interface (Java 8+): An interface with exactly one abstract method. Annotated with @FunctionalInterface. Examples: Runnable, Callable, Comparator, Predicate, Function, Consumer, Supplier. Used with lambda expressions and method references.

Multiple interface implementation: class Robot implements Flyable, Drivable, Chargeable { ... } — a class can implement as many interfaces as needed. If two interfaces have the same default method, the class must override it to resolve the conflict.

Java Polymorphism

Compile-time and Runtime Polymorphism

Polymorphism means "many forms." In Java, it allows one interface to be used for different underlying data types. Java supports two types: Compile-time polymorphism (method overloading — resolved at compile time) and Runtime polymorphism (method overriding + dynamic dispatch — resolved at runtime through the JVM's virtual method table).

Runtime polymorphism example:
Animal a = new Dog(); // reference type: Animal, object type: Dog
a.eat(); // calls Dog's eat() at runtime — dynamic dispatch
The reference type determines which methods you can call. The object type determines which implementation runs. This is the power of polymorphism — the same code works for all subtypes.

Dynamic method dispatch: When an overridden method is called through a parent reference, Java determines at runtime which class's version to call based on the actual object type (not the reference type). This is also called late binding or dynamic binding.

Covariant return type: An overriding method in a subclass can return a subtype of the return type declared in the parent class. class Animal { Animal create() { return new Animal(); } } class Dog extends Animal { @Override Dog create() { return new Dog(); } } — Dog is a covariant return type of Animal.

Java Exception Handling

What is Exception Handling in Java?

Exception handling in Java manages runtime errors gracefully. Java uses try, catch, finally, throw, and throws keywords. Java exceptions are objects — they inherit from java.lang.Throwable. The hierarchy splits into Error (serious JVM errors — OutOfMemoryError, StackOverflowError — not meant to be caught) and Exception (recoverable problems — checked and unchecked).

Throwable Error (unchecked) OutOfMemory StackOverflow Exception Checked Exception Must handle or declare IOException SQLException ClassNotFoundException RuntimeException Unchecked — optional NullPointer ArrayIndex ClassCast try { int[] a = new int[5]; a[10] = 1; // throws ArrayIndexOutOfBoundsException } catch (ArrayIndexOutOfBoundsException e) { System.out.println(e.getMessage()); } finally { System.out.println("Always runs"); }

Checked vs Unchecked exceptions: Checked exceptions (IOException, SQLException) must be handled with try-catch or declared with throws in the method signature — compiler enforces this. Unchecked exceptions (RuntimeException subclasses — NullPointerException, ArrayIndexOutOfBoundsException) are optional to handle.

Multi-catch (Java 7+): catch (IOException | SQLException e) { ... } — handles multiple exception types in one block. The exception variable is implicitly final.

try-with-resources (Java 7+): try (FileReader fr = new FileReader("file.txt")) { ... } — automatically calls fr.close() when try block exits. The resource must implement AutoCloseable. Cleaner than finally for closing resources.

Custom exceptions: class InsufficientFundsException extends Exception { public InsufficientFundsException(String msg) { super(msg); } }. Throw it: throw new InsufficientFundsException("Balance too low!"); Declare it: void withdraw(double amt) throws InsufficientFundsException { ... }

Java Collections Framework

What is the Java Collections Framework?

The Java Collections Framework (JCF) provides a unified architecture for storing and manipulating groups of objects. It includes interfaces (List, Set, Queue, Map), implementations (ArrayList, LinkedList, HashSet, TreeMap, etc.), and algorithms (sort, search, shuffle). Collections work with generics to provide type safety.

Iterable<E> Collection<E> List<E> ArrayList LinkedList Vector Set<E> HashSet TreeSet LinkedHashSet Queue<E> PriorityQueue ArrayDeque Map<K,V> — (NOT part of Collection hierarchy) HashMap TreeMap LinkedHashMap ConcurrentHashMap Hashtable EnumMap

ArrayList: Dynamic array, O(1) get by index, O(n) insert/delete in middle. Best when frequent reads. List<String> list = new ArrayList<>(); list.add("A"); list.get(0); list.remove(0); list.size(); Collections.sort(list);

HashMap: Key-value pairs, O(1) average get/put. Keys must be unique. Map<String,Integer> map = new HashMap<>(); map.put("Alice", 25); map.get("Alice"); map.containsKey("Alice"); map.entrySet(); map.keySet(); map.values(); map.getOrDefault("Bob", 0);

HashSet: Unique elements, O(1) add/contains. No guaranteed order. Set<Integer> set = new HashSet<>(); set.add(1); set.contains(1); set.remove(1); — use TreeSet for sorted order, LinkedHashSet for insertion order.

Generics: List<String> only holds Strings — compile-time type safety. <T> in class/method definitions. Wildcards: List<?> (any type), List<? extends Number> (Number or subtypes), List<? super Integer> (Integer or supertypes).

Iterating collections: Enhanced for loop: for (String s : list). Iterator: while (it.hasNext()) { it.next(); }. Java 8 forEach: list.forEach(s -> System.out.println(s)); or list.forEach(System.out::println);

Java Multithreading

What is Multithreading in Java?

Multithreading in Java allows concurrent execution of two or more threads. A thread is the smallest unit of execution within a process. Java has built-in support for multithreading through the java.lang.Thread class and java.lang.Runnable interface. Multithreading improves performance by utilizing multiple CPU cores and keeping programs responsive.

Creating threads — Method 1 (extending Thread):
class MyThread extends Thread {
    public void run() { System.out.println("Thread: " + Thread.currentThread().getName()); }
}
MyThread t = new MyThread(); t.start(); // start() creates new thread and calls run()

Creating threads — Method 2 (implementing Runnable — preferred):
class MyTask implements Runnable {
    public void run() { System.out.println("Running!"); }
}
Thread t = new Thread(new MyTask()); t.start();
// Lambda version (Java 8+): Thread t = new Thread(() -> System.out.println("Running!")); t.start();

Thread lifecycle: New (created) → Runnable (start() called) → Running (CPU executing) → Waiting/Blocked (sleep, wait, I/O) → Terminated (run() completes). Key methods: start(), run(), sleep(ms), join() (wait for thread to finish), interrupt(), isAlive(), setPriority().

synchronized keyword: Prevents race conditions by ensuring only one thread executes a synchronized block/method at a time. synchronized void deposit(int amt) { balance += amt; } — thread-safe method. synchronized(this) { ... } — synchronized block for finer control.

ExecutorService (Java 5+): Better than raw threads. ExecutorService exec = Executors.newFixedThreadPool(4); exec.submit(() -> doTask()); exec.shutdown(); Provides thread pools — reuses threads to reduce creation overhead. Future<T> for getting results from tasks.

volatile keyword: Ensures a variable's value is always read from and written to main memory (not CPU cache). Prevents thread-local caching issues. volatile boolean running = true; — threads will always see the latest value.

Java Lambda Expressions and Streams

Java 8+ Modern Features

Java 8 introduced lambda expressions and the Stream API — the most significant additions to Java since generics. Lambda expressions provide a clear, concise way to represent a function (an instance of a functional interface). The Stream API enables functional-style operations on collections — filter, map, reduce, collect.

Lambda expression syntax: (parameters) -> expression or (parameters) -> { statements; }. Examples: () -> System.out.println("Hello") — no params. x -> x * 2 — one param (parens optional). (a, b) -> a + b — two params. (int a, int b) -> { int sum = a+b; return sum; } — block body.

Method references: Shorthand for lambda calling a method. ClassName::staticMethod (Math::sqrt), instance::method (System.out::println), ClassName::instanceMethod (String::toUpperCase), ClassName::new (ArrayList::new — constructor reference).

Stream API pipeline: Source → Intermediate operations → Terminal operation.
List<String> names = Arrays.asList("Alice","Bob","Charlie","Dave","Alice");
long count = names.stream()
    .filter(n -> n.length() > 3) // intermediate
    .map(String::toUpperCase) // intermediate
    .distinct() // intermediate
    .sorted() // intermediate
    .count(); // terminal

Common terminal operations: collect(Collectors.toList()), count(), findFirst(), findAny(), anyMatch(), allMatch(), noneMatch(), reduce(), forEach(), min(), max(), toArray().

Optional (Java 8+): A container for a value that might be null. Avoids NullPointerException. Optional<String> opt = Optional.of("hello"); opt.isPresent(); opt.get(); opt.orElse("default"); opt.orElseGet(() -> compute()); opt.map(String::toUpperCase);

Collectors: Collectors.toList(), Collectors.toSet(), Collectors.joining(", "), Collectors.groupingBy(Employee::getDept), Collectors.counting(), Collectors.summingInt(Employee::getSalary), Collectors.toMap(k, v).

Java Programs

Important Java Programs for Practice

1. Hello World:
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

2. Fibonacci Series:
int a = 0, b = 1;
for (int i = 0; i < 10; i++) {
    System.out.print(a + " ");
    int temp = a + b; a = b; b = temp;
} // Output: 0 1 1 2 3 5 8 13 21 34

3. Factorial (recursion):
static long factorial(int n) {
    return (n == 0) ? 1 : n * factorial(n - 1);
}
System.out.println(factorial(10)); // 3628800

4. Reverse a String:
String str = "Java Programming";
String reversed = new StringBuilder(str).reverse().toString();
System.out.println(reversed); // gnimmargorP avaJ

5. Check Prime:
boolean isPrime(int n) {
    if (n <= 1) return false;
    for (int i = 2; i <= Math.sqrt(n); i++)
        if (n % i == 0) return false;
    return true;
}

6. Sort ArrayList with Lambda:
List<String> names = new ArrayList<>(Arrays.asList("Charlie","Alice","Bob"));
names.sort((a, b) -> a.compareTo(b)); // or: Collections.sort(names);
// [Alice, Bob, Charlie]

7. Find duplicates using HashMap:
int[] arr = {1, 2, 3, 2, 4, 1, 5};
Map<Integer, Integer> freq = new HashMap<>();
for (int n : arr) freq.put(n, freq.getOrDefault(n, 0) + 1);
freq.entrySet().stream().filter(e -> e.getValue() > 1).forEach(System.out::println);

8. Generic Stack implementation:
class Stack<T> {
    private List<T> list = new ArrayList<>();
    void push(T item) { list.add(item); }
    T pop() { return list.remove(list.size()-1); }
    T peek() { return list.get(list.size()-1); }
    boolean isEmpty() { return list.isEmpty(); }
}

Java Interview Questions and Answers

Top Java Programming Interview Questions

Q1. What is the difference between JDK, JRE, and JVM?
Ans: JVM (Java Virtual Machine) executes bytecode and provides runtime services. JRE (Java Runtime Environment) = JVM + standard class libraries — used to run Java programs. JDK (Java Development Kit) = JRE + development tools (javac, jar, jdb) — used to develop Java programs. Users need JRE; developers need JDK.

Q2. What is the difference between == and .equals() in Java?
Ans: == compares references (memory addresses) for objects, and values for primitives. .equals() compares the actual content/value of objects. String s1 = new String("hello"); String s2 = new String("hello"); s1 == s2 is false (different objects), s1.equals(s2) is true (same content). For string literals, == may return true due to string pooling.

Q3. What is the difference between ArrayList and LinkedList?
Ans: ArrayList uses a dynamic array internally — fast random access O(1), slow insertion/deletion in middle O(n). LinkedList uses doubly linked list — slow random access O(n), fast insertion/deletion at known position O(1). Use ArrayList for frequent reads; LinkedList for frequent insertions/deletions at both ends. LinkedList also implements Deque.

Q4. What is the difference between interface and abstract class?
Ans: Abstract class can have constructor, instance fields, and both abstract and concrete methods. A class can extend only one abstract class. Interface can only have abstract methods (Java 7), default/static methods (Java 8+), private methods (Java 9+), and constants. A class can implement multiple interfaces. Use abstract class for IS-A with shared state; interface for CAN-DO behavior contracts.

Q5. What is String immutability in Java? Why is String immutable?
Ans: Once a String object is created, its value cannot be changed. Any modification creates a new String object. Reasons: Security (class names, network addresses shouldn't change), Thread safety (immutable objects are inherently thread-safe), String pool efficiency (shared across JVM). Use StringBuilder for mutable strings — it's not thread-safe but faster. Use StringBuffer for thread-safe mutable strings.

Q6. What is garbage collection in Java?
Ans: Java's automatic memory management system that identifies and removes objects that are no longer reachable (no references pointing to them). The JVM's Garbage Collector periodically reclaims heap memory. Developers cannot force GC (System.gc() is a suggestion). Modern GC algorithms: G1GC (Java 9+ default), ZGC (Java 15+, low latency), Shenandoah. Objects become eligible for GC when all references are set to null or go out of scope.

Q7. What is the difference between HashMap and Hashtable?
Ans: HashMap is non-synchronized (not thread-safe), allows one null key and multiple null values, faster. Hashtable is synchronized (thread-safe), does not allow null keys or values, slower. HashMap is preferred in single-threaded environments. For thread-safe map, use ConcurrentHashMap (better than Hashtable) — it uses segment-level locking instead of method-level locking.

Q8. What are checked and unchecked exceptions in Java?
Ans: Checked exceptions are verified at compile time — must be handled with try-catch or declared with throws (IOException, SQLException, ClassNotFoundException). Unchecked exceptions extend RuntimeException — optional to handle, represent programming errors (NullPointerException, ArrayIndexOutOfBoundsException, ClassCastException, IllegalArgumentException). Errors (OutOfMemoryError, StackOverflowError) are serious JVM problems — not meant to be caught.

Q9. What is the difference between method overloading and method overriding?
Ans: Overloading — same method name, different parameters, in the same class. Compile-time polymorphism (static binding). Return type can differ. Overriding — same name, same parameters, in subclass. Runtime polymorphism (dynamic binding). Return type must be same or covariant. @Override annotation recommended. Cannot override static, final, or private methods.

Q10. What is a lambda expression in Java?
Ans: A lambda expression is an anonymous function — a concise way to implement a functional interface (interface with one abstract method). Syntax: (params) -> expression. Enables functional programming style. Used heavily with Stream API, event handlers, and Comparators. Lambdas can capture effectively final local variables from the enclosing scope (closure). Under the hood, lambdas are converted to invokedynamic bytecode instructions.

Java MCQ (Multiple Choice Questions)

Java MCQs with Answers

Q1. Which component converts Java source code to bytecode?
a) JVM b) JRE c) javac d) java
Answer: c) javac — the Java compiler (part of JDK) converts .java to .class bytecode.

Q2. What is the default value of an int variable in Java?
a) null b) 0 c) undefined d) -1
Answer: b) 0 — instance int fields default to 0; local variables must be initialized.

Q3. Which keyword is used to prevent method overriding in Java?
a) static b) private c) final d) abstract
Answer: c) final — a final method cannot be overridden by subclasses.

Q4. Which collection allows duplicate elements and maintains insertion order?
a) HashSet b) TreeSet c) ArrayList d) HashMap
Answer: c) ArrayList

Q5. What is the size of a char in Java?
a) 1 byte b) 2 bytes c) 4 bytes d) depends on OS
Answer: b) 2 bytes — Java uses Unicode (UTF-16), so char is 2 bytes (16 bits).

Q6. Which method must be implemented when implementing the Runnable interface?
a) start() b) execute() c) run() d) thread()
Answer: c) run() — Runnable has one abstract method: public void run().

Q7. What is the output of: System.out.println(10 / 3)?
a) 3.33 b) 3 c) 3.0 d) 4
Answer: b) 3 — integer division truncates the decimal. Use 10.0/3 or 10/(double)3 for 3.33.

Q8. Which of the following is NOT a feature of Java?
a) Platform independent b) Pointers c) Object-oriented d) Multithreaded
Answer: b) Pointers — Java does not support explicit pointers for security and simplicity.

Q9. What does the super() call do in a constructor?
a) Calls the current class constructor b) Calls the parent class constructor c) Creates a new object d) Calls a static method
Answer: b) Calls the parent class constructor — must be the first statement.

Q10. Which Java 8 feature allows writing anonymous functions concisely?
a) Generics b) Annotations c) Lambda expressions d) Enums
Answer: c) Lambda expressions

Q11. What is the correct way to create an object in Java?
a) Employee e = Employee(); b) Employee e = new Employee(); c) new Employee e; d) Employee e;
Answer: b) Employee e = new Employee();

Q12. Which exception is thrown when you try to access a null reference?
a) NullReferenceException b) NullPointerException c) IllegalArgumentException d) ArrayIndexOutOfBoundsException
Answer: b) NullPointerException — thrown when you call a method or access a field on a null object.

Instructor

Administrator

TUTORX ADMIN

Administrator

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

0 Rating
0 Reviews
93 Students
67 Courses

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Contact TutorX – We're Here to Help You Succeed

Reach out to us for inquiries, support, or more information about our personalized tutoring services

Get in touch

We are happy to hear from you. You can either fill out the form or send us an email.

Address

A1 220, 4th floor ,shushant lok phase 2 sector 55 gurgaon

Email

info@thetutorx.com

Phone

(+91)9013504886

Follow Us

Send Us Message

Shopping Cart

Loading...