0% found this document useful (0 votes)
5 views2 pages

Common Java Programming Errors

The document outlines common programming errors, including syntax errors like missing keywords and quotation marks, runtime errors such as division by zero, and logic errors that occur when a program does not function as intended. It also discusses valid and invalid identifier naming conventions in Java, as well as the formatting of the main method. Additionally, it provides examples of class definitions and prompts for understanding output from a specific program.

Uploaded by

saradha.r
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Common Java Programming Errors

The document outlines common programming errors, including syntax errors like missing keywords and quotation marks, runtime errors such as division by zero, and logic errors that occur when a program does not function as intended. It also discusses valid and invalid identifier naming conventions in Java, as well as the formatting of the main method. Additionally, it provides examples of class definitions and prompts for understanding output from a specific program.

Uploaded by

saradha.r
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

 The keyword void is missing before main in line 2.


 The string Hello World Example should be closed with a closing
quotation mark in line 3.

Since a single error will often display many lines of compile errors, it is a
good practice to fix errors from the top line and work downward. Fixing
errors that occur earlier in the program may also fix additional errors that
occur later.
2. runtime errors is division by zero
3. Logic errors occur when a program does not perform the way it was
intended to. Errors of this kind occur for many different reasons. For
example, suppose you wrote the program to convert Celsius 35 degrees to
a Fahrenheit degree:

OUTPUT: Celsius 35 is Fahrenheit degree

67

4. [Link], [Link]
5.

ExcitingGame OK: mixed upper and lower case is allowed

Lady Luck BAD: no spaces allowed inside an identifier

x32 OK: identifiers must start with an alphabetical character, but the rest can be digits.

lastChance OK: class names usually start with a capital, but identifiers don't have to.

x/y BAD: the slash is not allowed inside an identifier

1stPrize BAD: starts with a digit

6. public static void main(String[] args )


The Java compiler would accept the line. But it looks sloppy to human eyes.

7. Yes, yes, no, it has a bug.


8. Any three statements within quotes.
9. Consider the following class definitions.
public class Ex12_3
{ public int x; public int y; }

public class Ex12_3sub extends Ex12_3


{
public int y = 1; public int z = 1;
}
What is the output of the following program?
10.

You might also like