Question

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);
0 0
Add a comment Improve this question Transcribed image text
Answer #1

What kind of error is it when your program has a syntax error?

Ans - Compilation Error

When you don't code according to the given language standard, syntax error arises.

syntax errors reported by the compiler at the compile time. that's why it is called as Compilation Error

2.

public class Employee
{
    private String empID;
    private boolean hourly;
    public Employee(String employeeID, boolean isHourly)
    { . . . }
}

below statement is correct to initialize the object.

in Employee class constructor is defined as Employee(String employeeID, boolean isHourly)

which takes a string and boolean data type

Employee anAuto = new Employee("10548", true);

Add a comment
Know the answer?
Add Answer to:
What kind of error is it when your program has a syntax error? Exception Logic error...
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
  • The files provided contain syntax and/or logic errors. In each case, determine and fix the problem,...

    The files provided contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. import java.util.*; public class DebugEight1 { public static void main(String args[]) { Scanner input = new Scanner(System.in); char userCode; String entry, message; boolean found = false; char[] okayCodes = {'A''C''T''H'}; StringBuffer prompt = new StringBuffer("Enter shipping code for this delivery\nValid codes are: "); for(int x = 0; x <...

  • I was wondering if I could get some help with a Java Program that I am...

    I was wondering if I could get some help with a Java Program that I am currently working on for homework. When I run the program in Eclipse nothing shows up in the console can you help me out and tell me if I am missing something in my code or what's going on? My Code: public class Payroll { public static void main(String[] args) { } // TODO Auto-generated method stub private int[] employeeId = { 5658845, 4520125, 7895122,...

  • Exception handling is a powerful tool used to help programmers understand exception errors. This tool separates...

    Exception handling is a powerful tool used to help programmers understand exception errors. This tool separates the error handling routine from the rest of the code. In this application, you practice handling exception errors. You use sample code that was purposefully designed to generate an exception error, and then you modify the code so that it handles the errors more gracefully. For this Assignment, submit the following program: The following code causes an exception error: import java.io.BufferedReader; import java.io.IOException; import...

  • JAVA CODE This program causes an error and crashes. Compile and give it a test run,...

    JAVA CODE This program causes an error and crashes. Compile and give it a test run, note the exception that is thrown. Then do the following to fix the problem 1. Write code to handle this exception 2. Use try, catch and finally blocks. 3. Display, the name of the exception 4. Display a message from the user about what happened. Here is the starting file BadArray.java: public class BadArray { public static void main(String[] args) { // Create an...

  • 1. Which of the following statements is true? I. When an object is serialized, all of...

    1. Which of the following statements is true? I. When an object is serialized, all of its data attributes are always serialized. II. When an object is serialized, its methods are not serialized. III. The Serializable interface does not declare any abstract methods. Select one: A. I only B. II only C. III only D. I and II only E. II and III only 2. For the code below, and assuming widget.dat exists, which of the following statements are false?...

  • The files provided in the code editor to the right contain syntax and/or logic errors. In...

    The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. public class DebugTwo1 { public static void main(String[] args) { integer oneInt = 315; double oneDouble = 12.4; character oneChar = 'A'; System.out.print("The int is "); System.out.println(oneint); System.out.print("The double is "); System.out.println(onDouble); System.out.print("The char is "); System.out.println(oneChar); } }

  • The following code has a problem with polymorphism. I keep getting a runtime error. Error: "An...

    The following code has a problem with polymorphism. I keep getting a runtime error. Error: "An unhandled exception of type System.InvalidCastException occured in polymorphism.exe" Apparently, I need one line of code to fix it. C# Code: class Sensor     {         private string sensorName;         public Sensor(string _name)         {             sensorName = _name;         }         public virtual void ActionType()         {             Console.WriteLine("Sensor Detect Nothing.");         } } class SmokeSensor : Sensor     {         private string type;...

  • 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 =...

  • Analyze the following code in these 2 Java classes and choose the correct statement below: public...

    Analyze the following code in these 2 Java classes and choose the correct statement below: public class Test { public static void main(String[] args) { Time1 time = new Time1(); time.print(); } } public class Time1 {    private String showTime;    public Time1(String newTime) { showTime = newTime; }    public void print() { System.out.printf("%s", showTime); } } a. The program will compile and run if you change: Time1 time = new Time1();  → Time1 time = new Time1("5:15"); b....

  • 1. Analyze the following code: public class Test implements Runnable { public static void main(String[] args) { Thread t = new Thread(this); t.start(); } public void run() { System....

    1. Analyze the following code: public class Test implements Runnable { public static void main(String[] args) { Thread t = new Thread(this); t.start(); } public void run() { System.out.println("test"); } } 1. The code compiles but will not print anything since t does not invoke the run method. 2. The code will not compile since you cannot invoke "this" in a static method. 3. The program compiles, runs, and prints tests on the console. 2. What will the following example...

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