Table of Contents
Frequently Asked Questions
This page aims to address many Frequently Asked Questions (FAQs) by CSE 1020 students. If, after reading this, you still have questions, meet with your instructor or TA, or post a message on the online forum.
eCheck hints and tips
Before starting to code a solution to an eCheck task, you might want to follow these guidelines:
- Read and re-read the task description. If you require clarification, ask your instructor, TA, classmate, or in the online forum.
- Identify the result that you must produce. Note any particular spacing or formatting that is required.
- List the resources that will help you produce the result. This can include user input, contents of an input file, techniques discussed in that eCheck’s chapter, and/or helper classes in the API.
- Outline how you can compute the desired result given the available resources. This outline could also serve as documentation/comments within your code.
Template for Java program
See page 70 in the textbook.
TS count too high
To ensure that your program is efficient, eCheck will not accept programs with too many terminated statements (TS). If your program is correct but too long, here are some tips:
- Delete any comments that contain a semicolon “;”.
- Combine print statements. E.g.: print(someStringA); print(someStringB); can be combined into print(someStringA + someStringB);
- Read the chapter for hints on solving the problem efficiently.
Output formatting
See page 108 in the textbook.
eCheck does not like the spacing of your output
Sometimes, eCheck expects a space when you have a tab (or visa versa). But eCheck communicates this using ASCII codes rather than “space” or “tab”. See page 455 in the textbook for an ASCII code chart.
Reading input from a file
See pages 168 and 201-202 in the textbook.
Object serialization (input files with .dat extension)
Input files ending with .txt are text files. But (in the textbook) files ending with .dat contain a serialized object. A serialized object is an object whose state (i.e., attributes) has been written to a file. To read-in such objects, see pages 351-352 for details.
Interpreting compilation errors
Here are some common exceptions and their meanings:
Cannot find symbol …
If the symbol is a class name, then you forgot to import it. If the symbol is a variable name, then you forgot to define it (or mistyped its name). If the symbol is a method name, then the name is incorrect, or the type or number of parameters is wrong.
Illegal Start of Expression … or ; ( or ) Expected
You forgot a semicolon or parenthesis.
Class ... is public, should be declared in ...
Your file name (excluding the .java extension) should be the same as your class name. Remember that Java is case sensitive (e.g., myClass is different from MyClass) and that class names should start with an uppercase letter.
... cannot be applied to ...
You are calling a valid method, but are trying to pass incorrect parameters to it.
Reached end of file while parsing
You forgot a bracket at the end of your code.
Interpreting runtime exceptions
Every exception has an entry in the API. Reading the description will often explain why the exception was thrown.
Incorrect output
Use print statements to output the value of variables during the execution of your program. This can help determine if intermediate calculations (e.g., inside loops) are correct.
To determine whether or not an if-branch is taken, insert a print statement as the first line in the code block.
Infinite loop or unresponsive program
You can force your program to terminate by pressing Ctrl+C. This ability is helpful when your program becomes unresponsive or has an infinite loop.