Array Programs in Java

Array Programs in Java: An array is a data structure that stores similar elements in a contiguous memory location. In Java, an array is an object that stores the same kind of elements. Arrays in Java are index-based, i.e., the first element is stored in the 0th index,...

Constructor Program in Java

Constructor Program in Java In Java, a constructor is a piece of code that is used to create an object. A constructor is called implicitly when an object is created in Java using the new keyword. A constructor looks like an instance method. However, a constructor and...

Recursion Program in Java

The recursion program in Java demonstrates the usage of recursion. The process by which a function/ method calls itself, again and again, is called recursion. Each recursive call is pushed to the stack. The function/ method upon which recursion calls are made is...

Matrix Multiplication Program in Java

Matrix Multiplication Program in Java The matrix multiplication program in Java is the continuation of the matrix program in Java that we have already discussed earlier. In this section, we will learn how to multiply matrices. To find the multiplication of two...

String Programs in Java

String Programs in Java: In Java, a String is an immutable object that represents a sequence of characters. For example, “Tutorial” is a string that consists of 8 characters: ‘T’, ‘u’, ‘t’, ‘o’, ‘r’, ‘i’, ‘a’, ‘l’. Immutable object means once a string is created, it...

Classes and Objects in Java Example Programs

Classes and Objects in Java Example Programs Java is an Object-Oriented programming language, i.e., everything in Java is associated with objects and objects are associated with classes. The classes and objects in Java examples programs teach us about classes and...

Perfect Number Program in Java

Perfect Number Program in Java A perfect number is a number whose sum of all the factors, excluding the number itself, is equal to the number. For example, 28 is a perfect number. This is because all the factors of the number 28, excluding the number itself are: 1, 2,...

Java MCQ (Multiple Choice Questions)

Java Multiple Choice Questions 1) Observe the following code snippet and choose the correct option. byte b = 10; // line 1 b = b * 10; // line 2 1234  byte b = 10; // line 1b = b * 10; // line 2  Lines 1 and 2 both execute without any error. Because of line...

Client Server Program in Java

Client Server Program in Java The client and server are the two main components of socket programming. The client is a computer/node that request for the service and the server is a computer/ node that response to the client. In Java, using socket programming, we can...

Tower of Hanoi Program in Java

Tower of Hanoi Program in Java The Tower of Hanoi program in Java is written to solve a mathematical puzzle, called Tower of Hanoi, where we have three poles and n number of disks of different sizes. The task is to move all the n disks placed at one pole to another...

Pin It on Pinterest