Java Chapter 1 Test Questions and Answers
100% Verified
Name the two block styles when programming in Java ✔️✔️End of line style
Next-line Style
Name and Define 3 errors that are common in Java programming. ✔️✔️Syntax Errors-which is
detected by the compiler
Runtime errors - which causes the program to abort
Logic Errors - which produces the incorrect result
What type of error is in this code?
Where is the error?
public class ShowSyntaxErrors {
public static main(String[ ] args) {
System.out.println("Welcome to Java);
}
} ✔️✔️Syntax error:
1. missing void in method:
public static void main
2. missing quotations in string:
System.out.println("Welcome to Java");
, What type of error is in this code?
Where is the error?
public class ShowSyntaxErrors {
public static main(String[ ] args) {
System.out.println(1/0);
}
} ✔️✔️Runtime error and Syntax error:
1 can not be divided by 0.
void is missing from the main method
What type of error is in this code?
Where is the error?
public class ShowSyntaxErrors {
public static main(String[ ] args) {
System.out.println(" 5+3=6");
}
} ✔️✔️Syntax and logic error
void is missing from the main method
The string 5+3=6 is logically incorrect, the answer is 8.
100% Verified
Name the two block styles when programming in Java ✔️✔️End of line style
Next-line Style
Name and Define 3 errors that are common in Java programming. ✔️✔️Syntax Errors-which is
detected by the compiler
Runtime errors - which causes the program to abort
Logic Errors - which produces the incorrect result
What type of error is in this code?
Where is the error?
public class ShowSyntaxErrors {
public static main(String[ ] args) {
System.out.println("Welcome to Java);
}
} ✔️✔️Syntax error:
1. missing void in method:
public static void main
2. missing quotations in string:
System.out.println("Welcome to Java");
, What type of error is in this code?
Where is the error?
public class ShowSyntaxErrors {
public static main(String[ ] args) {
System.out.println(1/0);
}
} ✔️✔️Runtime error and Syntax error:
1 can not be divided by 0.
void is missing from the main method
What type of error is in this code?
Where is the error?
public class ShowSyntaxErrors {
public static main(String[ ] args) {
System.out.println(" 5+3=6");
}
} ✔️✔️Syntax and logic error
void is missing from the main method
The string 5+3=6 is logically incorrect, the answer is 8.