Java programs for Practice
Find the mistakes in the following java code
//Practice 1
public class Practice1
{
public static void main(string[] args)
{
System.out.println("Welcome");
}
}
//Practice 2
public class Practice2
{
public static void main(String[] args)
{
int num;
num=10;
System.out.println("num =",num);
}
}
//Practice 3
public class Practice3
{
public static void Main(String []args)
{
int first, second;
first=23;
second=56;
System.out.println(first+"+"+second+"="+(first+second));
}
}
Fill the code in the Blanks
//Practice 1
public class Add2Nos {
public static void main(____________) {
int _____________________;
_______ = num1 + num2;
System.out.println("Sum of these numbers: "+sum);
}
}
//Practice 2
import ________________;
public class Add2Nos {
_____________main(String[] args) {
int _________________;
Scanner sc = new Scanner(__________);
System.out.println(___________________);
n1 = sc.nextInt();
System.out.println(_______________________);
n2 = sc.nextInt();
sc.close();
res = n1 + n2;
System.out.println("Sum of these numbers: "_________);
}
}