Ask Question

You coded the following class: public class N extends String, Integer { }When you compile, you get the following message:N. java:1: '{' expected public class N extends String, Integer^ 1 errorExplain what the problem is and how to fix it.

+5
Answers (1)
  1. 18 December, 04:16
    0
    Hi DancingGrace! The issue with the code is that it is trying to extend multiple classes which is not a feature in Java programming.

    Explanation:

    The extends keyword allows a class to use the attributes and properties of the base class it is extending and add more features and properties into it's own class. This is useful in programming where different models share similar properties but are slightly different. An example would be designing a class for Car and Bike. Both have some similar properties like wheels, engine, etc, however they are different forms of transport. A useful implementation would be to define a class called Vehicle with similar attributes, and have the Car and Bike extend it.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “You coded the following class: public class N extends String, Integer { }When you compile, you get the following message:N. java:1: '{' ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers