Question

Java Programming Language: Find the compiling error in the following code segment. Explain what the problem...

Java Programming Language:

Find the compiling error in the following code segment. Explain what the problem is and how to fix it.

public class Mark {

private float value;       

public float Mark(float startValue) {       

value = startValue; }

}

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

public class Mark {

private float value;       

public float Mark(float startValue) {       

value = startValue; }

}

As per this code compiling error is about variable value and error occures at value = startValue; . in class Mark it is declared as private. So that we can only access that varible with in the class and viewed by any method. We can not perform any operation out of the scope. So that it throus comilation error wile executing above code segement .

Add a comment
Know the answer?
Add Answer to:
Java Programming Language: Find the compiling error in the following code segment. Explain what the problem...
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
  • Can someone tell me why this isnt compiling. The language is java Ive attached my 2...

    Can someone tell me why this isnt compiling. The language is java Ive attached my 2 files im getting my one and only error on line 24 of my monster file. the error says: error cannot find symbol return weapon.getName ^ File 1. Monster.java import java.util.Random; class Monster{ private String name; private int health; private Weapon weapon;    public Monster(String monsterName, int monsterHealth, Weapon monsterWeapon){ name = monsterName; health = monsterHealth; weapon = monsterWeapon;    }    public String getName(){...

  • c++ What is wrong with the following code segment? Fix the error and explain why its...

    c++ What is wrong with the following code segment? Fix the error and explain why its wrong. int* m[3]; for(int i = 0; i < 3; i++) m[i] = new int[4]; delete [] m;

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

  • first we are requested to transfer the code to any OO programming language (Java, C#, C++...

    first we are requested to transfer the code to any OO programming language (Java, C#, C++ or VB) using the syntax of the selected language with the necessary modifications then we do the use case, domain model,class diagram, sequence diagram, - Develop (Analyze and Design) a GPA calculator using the same UML approach where the student enters his/her courses as objects with attributes: course Id, course credit hours and course grade. The system will calculate the Cumulative GPA for all...

  • Java is an object-oriented programming language that enables us to define classes and to instantiate them...

    Java is an object-oriented programming language that enables us to define classes and to instantiate them into objects. These objects then call each other’s methods to implement the behavior of the application. The Unified Modeling Language (UML) is an object-oriented visual notation to document the design of object-oriented classes. For this discussion, you will practice designing a Java class called Course, drawing a UML class diagram for the Course class, and then implementing the Course class in Java code. Review...

  • CDA-3101 – MIPS Assembly Programming 1. Write the following code segment in MIPS assembly language code:...

    CDA-3101 – MIPS Assembly Programming 1. Write the following code segment in MIPS assembly language code: 3. Write a MIPS program to find the sum of squares from 1 to n. Where n=10. For example, the sum of squares for 10 is as follows: 12+22+32+……+n2=385

  • O indexOf Language/Type: Related Links: Author: Java implementing Linked Lists LinkedIntList LinkedIntList.java Marty Stepp Write a...

    O indexOf Language/Type: Related Links: Author: Java implementing Linked Lists LinkedIntList LinkedIntList.java Marty Stepp Write a method indexOf that accepts a value as a parameter and returns the index in the list of the first occurrence of that value, or -1 if the value is not found in the list. Assume that you are adding this method to the LinkedIntList class as defined below: public class LinkedIntList { private ListNode front; // null for an empty list Type your solution...

  • FIX THE FOLLOWING JAVA CODE public class Errors public static main(String[] args) { float sum int...

    FIX THE FOLLOWING JAVA CODE public class Errors public static main(String[] args) { float sum int a = 27.5, b = 72.99; suma(a, b); System.out.println("Suma = %7:3b", sum); } //end main public static suma(float a, double b) { double suma suma = a + b; } }//end class

  • Write code in Java programming language. The ShoppingCart class will be composed with an array of...

    Write code in Java programming language. The ShoppingCart class will be composed with an array of Item objects. You do not need to implement the Item class for this question, only use it. Item has a getPrice() method that returns a float and a one-argument constructor that takes a float that specifies the price. The ShoppingCart class should have: Constructors: A no-argument and a single argument that takes an array of Items. Fields: • Items: an array of Item objects...

  • Find the error in the following java code and explain how to correct it (val is...

    Find the error in the following java code and explain how to correct it (val is a variable of type int): switch (val) { case 1: System.out.println ("The number is 1"); case 2: System.out.println ("The number is 2"); default: System.out.println ("The number is not 1 or 2"); break;

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
ADVERTISEMENT