Question

Write some java code that has a syntax error. Provide your explanation of the error, the...

Write some java code that has a syntax error. Provide your explanation of the error, the consequence of such error

0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class JavaError {
   public static void main(String[] args) {
       String s="Welcome!";
       // here we will get the error as the print() method is not a static method so we can't call directly it from main
       // we need to create object for class JavaError and call the print
       print(s);
   }
   public void print(String name) {
       System.out.println(name);
   }
}

Add a comment
Know the answer?
Add Answer to:
Write some java code that has a syntax error. Provide your explanation of the error, the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write some java code to show that it has a runtime error. Provide your explanation of...

    Write some java code to show that it has a runtime error. Provide your explanation of the error. What is the consequence of such error?

  • What is the output of the following code snippet? (If there is some kind of syntax...

    What is the output of the following code snippet? (If there is some kind of syntax error indicate this by marking "error" in your answer choice) 1.        int laps = 8;        if (laps++ > --laps)               laps += 2;        else if (--laps > (laps - 1))               laps += 4;        else if (++laps)               laps -= 3;        cout << laps << endl; 2. What is the output of the following code snippet?     int j = 47;     int i = 8;     j =...

  • What kind of error is it when your program has a syntax error? Exception Logic error...

    What kind of error is it when your program has a syntax error? Exception Logic error Run-time error Compile-time error ----------------------- Consider the following code snippet: public class Employee { private String empID; private boolean hourly; public Employee(String employeeID, boolean isHourly) { . . . } } Which of the following statements can be used to create an object of type Employee? Employee anAuto = new Employee("10548", true); Employee anAuto = new Employee("10548", "true"); Employee anAuto = new Employee(10548, true);

  • Write a program that will check a Java file for syntax errors. The program will ask...

    Write a program that will check a Java file for syntax errors. The program will ask for an input-file name and output-file name and will then copy all the code from the Java input file to the Java output file, but with the following changes: 1. Any syntax error found in the Java input file will be corrected: a. Missing semicolon b. Missing compound statements (curly braces) c. All comments have to start with // and end with a period....

  • 1. Questions Python Code: For each line of code, write the type of error (syntax, semantics,...

    1. Questions Python Code: For each line of code, write the type of error (syntax, semantics, runt-time), cause of the error, and your fix. (1) def fun(num letter) (2) num == 7 + num (3) return 'num' - letter (4) result = fun(5, x) 2. Question Python Code: Run the code below to check the outputs of the print() call on lines 12. And : A) Analyze the application of the accumulation pattern and answer the following questions: #1. a....

  • Explain why the following if statement results in syntax error in C, Java, and C#? if...

    Explain why the following if statement results in syntax error in C, Java, and C#? if (x==1) y = 2 else y = 3;

  • JAVA CODE Provide Java code for a simple class of your choice. Be sure to include...

    JAVA CODE Provide Java code for a simple class of your choice. Be sure to include at least one constructor, two methods and two fields. The fields should be private. Create a test class to constuct and call the methods of your class. Describe your class and demonstrate your code functions properly.

  • Java Programming: Task: - Write some Java code that creates a collection (an ArrayList, a TreeSet...

    Java Programming: Task: - Write some Java code that creates a collection (an ArrayList, a TreeSet or a LinkedList), puts some elements into it, creates an iterator, uses it a bit and then (1) changes the collection using one of the four techniques listed (not using the first iterator) and then (2) calls one of the three iterator methods listed. (See instructions below for details) - After writing the code answer the following questions: 1.) What is the result? 2.)...

  • When running this SQL code in Access I get an error saying "Syntax Error in FROM...

    When running this SQL code in Access I get an error saying "Syntax Error in FROM Clause" SELECT SUM(HoursWorked) AS TotalHoursWorked FROM Property_Service INNER JOIN Property_Service.EmployeeID = Employee.EmployeeID WHERE ExperienceLevel <> 'Junior'; I was wondering if someone could help me fox it.

  • CGALLENE 4.2: More syntax errors. ACTIVITY Each cout statement has a syntax error. Type the first...

    CGALLENE 4.2: More syntax errors. ACTIVITY Each cout statement has a syntax error. Type the first cout statement, and press Run to observe the error message. Fix the error, and run again. Repeat for the second, then third, cout statement cout << "Num: "<< songnum << endl; cout << int songNum << endl; cout << songNum " songs" << endl; Note: These activities may test code with different test values. This activity will perform two tests: the first with songNum-5,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT