WPM
100
CPM
100
Errors
0
Time
15Min
Accuracy
100%
Start Java code typing Practice. Java Main Methods Static Methos, Creating Objects in Java, Thread Using Runnable Interface, Reverse String Using Loop and Input From User in Java.Click on the area below to start typing.

S.No.Paragraph : Practice repeatedly whatever you would like most for full fifteen minutes Lessionsclick to Practice
1class Demo{ static{ //static block System.out.println("Static block"); } public static void main(String args[]){ //static method System.out.println("Static method"); } } //A program that does not have the main() method gives an error at run time. class DemoStaticBlock{ Static{ //static block System.out.println("Static block"); } }1.1 java main method and static method
2import java.lang.reflect.Constructor; public class NewInstanceExample1 { String str="hello"; public static void main(String args[]) { try { Constructor obj=NewInstanceExample1.class.getConstructor(); NewInstanceExample1 obj1 = obj.newInstance(); System.out.println(obj1.str); } catch(Exception e) { e.printStackTrace(); } } }1.2 creating objects in java
3//To create a thread using runnable, use the following code- public class ExampleClass implements Runnable { @Override public void run() { System.out.println("Thread has ended"); } public static void main(String[] args) { ExampleClass ex = new ExampleClass(); Thread t1= new Thread(ex); t1.start(); System.out.println("Hi"); } }1.3 a thread using Runnable interface in java
4import java.util.Scanner; class ReverseStringExample1 { public static void main(String args[]) { String s; Scanner sc=new Scanner(System.in); System.out.print("Enter a String: "); s=sc.nextLine(); //reading string from user System.out.print("After reverse string is: "); for(int i=s.length();i>0;--i){ //i is the length of the string System.out.print(s.charAt(i-1)); //printing the character at index i-1 } } }1.4 reverse string in Java by using for loop
5import java.util.*; class UserInputDemo { public static void main(String[] args) { Scanner sc= new Scanner(System.in); // standard input stream System.out.print("Enter first number- "); int a= sc.nextInt(); System.out.print("Enter second number- "); int b= sc.nextInt(); System.out.print("Enter third number- "); int c= sc.nextInt(); int d=a+b+c; System.out.println("Total= " +d); } }1.5 input from user from java program