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;

  • Please help me answer these questions in java programming language. Please answer it line after line...

    Please help me answer these questions in java programming language. Please answer it line after line so that I can understand please. Does it compile or not? No programming is done in this exercise, simply answer the questions asked in the code given below. class Exemple { /*Explain why this code does not compile */ public void m1() { foo(); } public int foo() throws Exception { throw new Exception(); } /*Explain why this code is not considered as good...

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

  • ******Java Programming Hi guys, I really need you help. I created a code for my java...

    ******Java Programming Hi guys, I really need you help. I created a code for my java course, but it keep giving me error messages. Majority of my code is fine but some keep display error on my console. I was hoping someone could pin points the problem. .There are three classes with the testCenter class being the main class. In the following is the assignment, and the bottom is my code. Please help! Assignment: Concepts: GUI User Design Graphics Deployment...

  • Java programming double d = Math.PI( ); // line 10 System.out.println ( "d = " +...

    Java programming double d = Math.PI( ); // line 10 System.out.println ( "d = " + d ); // line 11 When I compile, Test.java:10: error : cannot find symbol double d = Math.PI( ); // line 10 symbol: method PI( ) location: Class Math 1 error Explain what the problem is and how to fix  

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

  • 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

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

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

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