Error Rectification in Java Code
Error Rectification in Java Code
Q.1 Find the Error
public class1 {
public static void main(String[] args) {
System.out.println(“Hello, Java!”;
}
}
Q.2 Find the Error
public class2 {
public static void main(String[] args) {
int x;
System.out.println(“The value of x is: ” + x);
}
}
Q.3 Find the Error
public class 3{
public static void main(String[] args) {
int x = y + 5;
System.out.println(“Value of x: ” + x);
}
}
Q.4 Find the Error
public class4 {
public static void main(String[] args) {
int x ;
System.out.println(“Value of x: ” + x);
}
}
.
Q.5 Find the Error
public class5 {
public static void main(String[] args) {
for (int i = 0; i > 5; i++) {
System.out.println(“Value: ” + i);
}
}
}
Q.6 Find the Error
public class6 {
public static void main(String[] args) {
int result = divide(10, 0);
System.out.println(“Result: ” + result);
}
static int divide(int a, int b) {
return a / b;
}
}
Q.7 Find the Error
public class7 {
public static void main(String[] args) {
int x = 5;
if (x > 3)
System.out.println(“x is greater than 3”);
else
System.out.println(“x is less than or equal to 3”);
}
Q.8 Find the Error
public class8 {
public static void main(String[] args) {
int x = 5;
if (x > 3 && x < 10) {
System.out.println(“x is between 3 and 10”);
} else {
System.out.println(“x is outside the range”);
}
}
}
Q.9 Find the Error
public class9 {
public static void main(String[] args) {
int day = 2;
switch (day) {
case 1:
System.out.println(“Sunday”);
case 2:
System.out.println(“Monday”);
case 3:
System.out.println(“Tuesday”);
}
}
}
Q.10 Find the Error
public class10 {
public static void main(String[] args) {
char grade = ‘B’;
switch (grade) {
case ‘A’:
System.out.println(“Excellent”);
case ‘B’:
System.out.println(“Good”);
case ‘C’:
System.out.println(“Average”);
}
}
}
Q.11 Find the Error
public class11{
public static void main(String[] args) {
char grade = ‘B’;
switch (grade) {
case ‘A’:
System.out.println(“Excellent”);
case ‘B’:
System.out.println(“Good”);
}
}
}
Q.12 Find the Error
public class12 {
public static void main(String[] args) {
for (int i = 0; i < 5; i++)
System.out.println(i);
}
}
Q.13 Find the Error
public class13 {
public static void main(String[] args) {
for (int i = 0; i < x; i++) {
System.out.println(i);
}
}
}
Fun & Easy to follow
Works on all devices
Your own Pace
Super Affordable
Popular Videos
Play Video
UX for Teams
Learn the basics and a bit beyond to improve your backend dev skills.
Chris Matthews
Designer
Play Video
SEO & Instagram
Learn the basics and a bit beyond to improve your backend dev skills.
Chris Matthews
Designer