Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
Java Interview Question And Answers

Free Java Interview Question And Answers Pdf [Quiz -7]

Posted on February 8, 2024March 14, 2025 By Updategadh No Comments on Free Java Interview Question And Answers Pdf [Quiz -7]

Java Interview Question And Answers Pdf ( Quiz -7 )

https://youtu.be/YqSrznLSrz0?si=Cxtcd8Wx-fzRsFEW

  1. Matrix Transpose:
    Write a program or function that takes a square matrix as input and returns its transpose. The transpose of a matrix is obtained by swapping the rows and columns.

public class MatrixTranspose {
    public static int[][] transposeMatrix(int[][] matrix) {
        int rows = matrix.length;
        int columns = matrix[0].length;
        int[][] transpose = new int[columns][rows];

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < columns; j++) {
                transpose[j][i] = matrix[i][j];
            }
        }

        return transpose;
    }

    public static void main(String[] args) {
        int[][] matrix = {
            {1, 2, 3},
            {4, 5, 6},
            {7, 8, 9}
        };
        int[][] transposedMatrix = transposeMatrix(matrix);
        for (int[] row : transposedMatrix) {
            for (int element : row) {
                System.out.print(element + " ");
            }
            System.out.println();
        }
    }
}

Check 50+ JAVA Projects with Source Code

  1. Remove Duplicates from an Array:
    Create a program or function that removes duplicate elements from an array and returns the array with only unique elements.

import java.util.Arrays;
import java.util.LinkedHashSet;

public class RemoveDuplicatesFromArray {
    public static int[] removeDuplicates(int[] array) {
        return Arrays.stream(array).distinct().toArray();
    }

    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 3, 2, 5};
        int[] uniqueArray = removeDuplicates(array);
        System.out.println("Unique Array: " + Arrays.toString(uniqueArray));
    }
}

Check 100+ JAVA Spring Boot Projects with Source Code

Check for Perfect Number: Write a function to check if a given positive integer is a perfect number. A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself).

public class PerfectNumber {
    public static boolean isPerfectNumber(int number) {
        if (number <= 1) {
            return false;
        }
        int sum = 1;
        for (int i = 2; i * i <= number; i++) {
            if (number % i == 0) {
                sum += i;
                if (i * i != number) {
                    sum += number / i;
                }
            }
        }
        return sum == number;
    }

    public static void main(String[] args) {
        int number = 28; // Example number
        System.out.println("Is Perfect Number: " + isPerfectNumber(number));
    }
}

Find Missing Number:
Write a program or function that finds the missing number in a given array of integers containing numbers from 1 to n, where n is the length of the array

public class FindMissingNumber {
    public static int findMissingNumber(int[] nums) {
        int expectedSum = nums.length * (nums.length + 1) / 2;
        int actualSum = 0;
        for (int num : nums) {
            actualSum += num;
        }
        return expectedSum - actualSum;
    }

    public static void main(String[] args) {
        int[] array = {1, 2, 4, 5, 6}; // Example array with one missing number
        System.out.println("Missing Number: " + findMissingNumber(array));
    }
}

Reverse a Linked List: Implement a function to reverse a singly linked list

class ListNode {
    int val;
    ListNode next;

    ListNode(int val) {
        this.val = val;
    }
}

public class ReverseLinkedList {
    public static ListNode reverseLinkedList(ListNode head) {
        ListNode prev = null;
        ListNode current = head;
        while (current != null) {
            ListNode nextNode = current.next;
            current.next = prev;
            prev = current;
            current = nextNode;
        }
        return prev;
    }

    public static void main(String[] args) {
        ListNode head = new ListNode(1);
        head.next = new ListNode(2);
        head.next.next = new ListNode(3);
        head.next.next.next = new ListNode(4);
        head.next.next.next.next = new ListNode(5);

        ListNode reversedList = reverseLinkedList(head);

        while (reversedList != null) {
            System.out.print(reversedList.val + " ");
            reversedList = reversedList.next;
        }
    }
}

Keyword
java interview question and answers pdf
java interview question and answer pdf
java interview question
java interview question book
java interview question pdf download
java interview question pdf free download
java interview question and answer for experienced
java interview question and answer for 3 years experience

Post Views: 700
Interview Question Tags:Interview Question

Post navigation

Previous Post: Free Project : Building an E-Learning Portal using Java, Spring MVC, Hibernate, Spring Security, and JSP
Next Post: E-commerce Web Application on Java, JSP, MySQL, and Servlet: A Comprehensive Guide

More Related Articles

Most Popular Java Program Questions for 2025 - Most Popular Java Program Questions Most Popular Java Program Questions for 2025 Interview Question
Top 10 Machine Learning Interview Questions 2024 With Answer - Top 10 Machine Learning Interview Questions Top 10 Machine Learning Interview Questions 2024 With Answer Interview Question
Java Interview Questions Java Interview Questions -Set 8 Interview Question

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. How to build an AI System Step-By-Step Guide [ Create an Ai ]
  2. Top 30 Coding Interview Questions You Should Know !
  3. Mastering SQL for Data Analytics and Interview Success
  4. Top 20 Web Application Interview Questions
  5. Swift Interview Questions and Answers: A Comprehensive Guide
  6. Popular Java Coding Questions & Answer for 2025

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Blog Site In PHP And MYSQL With Source Code || Best Project
  9. Online Bike Rental Management System Using PHP and MySQL
  10. E learning Website in php with Free source code
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Agentic RAG AI System Using Python – Complete Final Year Project Guide
  • AI-Powered Online Examination System with Face Detection Using PHP & MySQL
  • Real-Time Medical Queue & Appointment System with Django
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital

Most Viewed Posts

  • Top Large Language Models in 2025 (8,628)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,248)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,908)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme