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 | Lessions | click to Practice |
---|---|---|---|
1 | class 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 |
2 | import java.lang.reflect.Constructor;
public class NewInstanceExample1 {
String str="hello";
public static void main(String args[]) {
try {
Constructor | 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 |
4 | import 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 |
5 | import 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 |