Name Lau Name CSE 110 Lab 2 Introduction to variables Lab Ex

Name Lau Name: CSE 110 Lab 2: Introduction to variables Lab Exercise: Complete this portion of the lab during your lab session, 1. Recognizing syntax Errors When you make syntax errors in your program the compiler gives error messages and does not create the bytecode file(.class file). It saves time and frustration to learn what some of these messages are and what they mean. Unfortunately, at this stage in the game many of the messages will not be meaningful except to let you know where the first error occurred. Your only choice is to carefully study your program to find the error. In the following you will introduce a few typical errors into a simple program and examine the error messages. Type the following program into a file called Hello,java. (This is the traditional first program a computer scientist writes in a new language.) Hello Java Print a Hello, World message public class Hello main method prints the greeting public static void main (string t) args) system. out. print (\"Bello, World!\") Compile and run the program to see what it does. Then make the changes as stated below, answering the accompanying questions as you go.

Solution

Answer - 1
  
   1.
       Whenever a java file contains a public class then it is necessary that the java file and
       public class should have same name, otherwise compiler will reports an error.
      
       For your example error massage should as follows -
      
           java: class Helo is public, should be declared in a file named Helo.java
          
   2.
       It will not generate any error as Java compiler does not report any spelling mistake.
      
   3.
       Compiler will generate three errors specifying -
       i> unclosed string literal
       ii> expected \';\'
       iii> reached en of file while parsing
      
   4.
       Compiler will generate following errors -
       i> expected \')\'
       ii> unclosed string literal
       iii> not a statement
      
   5.  
       Compiler will generate an error - \';\' expected

 Name Lau Name: CSE 110 Lab 2: Introduction to variables Lab Exercise: Complete this portion of the lab during your lab session, 1. Recognizing syntax Errors Wh

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site