Startertutorials Blog
Tutorials and articles related to programming, computer science, technology and others.
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.

Java program to display the number of characters lines and words in a text file

Categories: Files. 5 Comments on Java program to display the number of characters lines and words in a text file

In this article we will learn to implement a Java program to display the number of characters lines and words in a text file. A Java program is provided below that displays the number of characters, lines and words in a text file.   import java.io.*; class FileDemo { public static void main(String args[]) { […]

Read the rest of this entry »

Java program to display integers and sum using StringTokenizer

Categories: Strings. No Comments on Java program to display integers and sum using StringTokenizer

In this article we will learn to implement a Java program to display integers and their sum using StringTokenizer. A Java program is provided below which uses StringTokenizer class, reads a line of integers and then displays each integer and the sum of all integers.   Program is as follows: import java.util.*; class StringTokenDemo { […]

Read the rest of this entry »

Java program to demonstrate life cycle of a thread

Categories: Threads. No Comments on Java program to demonstrate life cycle of a thread

In this article we will learn to implement a Java program to demonstrate life cycle of a thread. A Java program is provided below to illustrate life cycle of a thread.   Program is as follows: import java.util.*; class ChildThread implements Runnable { Thread t; ChildThread() { t = new Thread(this); System.out.println("Thread is in new […]

Read the rest of this entry »

Java program that creates three threads

Categories: Threads. No Comments on Java program that creates three threads

In this article we will learn to implement a Java program that creates three threads. A java program is provided below to create three threads.   First thread displays “Good Morning” every one second, the second thread displays “Hello” every two seconds and the third thread displays “Welcome” every three seconds.   Program is as […]

Read the rest of this entry »

Java program on rodent hierarchy

Categories: Inheritance. No Comments on Java program on rodent hierarchy

In this article we will learn to implement a Java program on rodent hierarchy. A Java program is provided below which uses the rodent hierarchy to demonstrate inheritance in Java.   Java program to create an inheritance hierarchy of Rodent, Mouse, Gerbil, Hamster etc. In the base class provide methods that are common to all Rodents […]

Read the rest of this entry »

Java program on shape hierarchy

Categories: Inheritance. No Comments on Java program on shape hierarchy

In this article we will learn to implement a Java program on shape hierarchy. The requirements for writing the program is specified below.   Java program to create an abstract class named Shape that contains an empty method named numberOfSides( ).Provide three classes named Trapezoid, Triangle and Hexagon such that each one of the classes […]

Read the rest of this entry »

Java program that illustrates how runtime polymorphism is achieved

Categories: Inheritance. No Comments on Java program that illustrates how runtime polymorphism is achieved

In this article we will learn to implement a Java program that illustrates how runtime polymorphism is achieved. A Java program is provided below that demonstrates how runtime polymorphism is achieved. abstract class Figure { int dim1, dim2; Figure(int x, int y) { dim1 = x; dim2 = y; } abstract void area(); } class […]

Read the rest of this entry »

Java program for sorting a given list of names in ascending order

Categories: Strings. No Comments on Java program for sorting a given list of names in ascending order

In this article we will learn to implement a Java program for sorting a given list of names in ascending order. A Java program is provided for sorting a given list of names or strings in ascending order.   Program is as follows: import java.util.*; class Sorting { void sortStrings() { Scanner s = new […]

Read the rest of this entry »