1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
PilotLPTM [1.2K]
3 years ago
14

Create a class 'ProblemSolution' with following characteristics A public method 'solution' without parameters and return type is

int. Create object of class 'Student' inside 'solution' method and return the value of ""rollNumber"" from the class 'Student'.
Computers and Technology
1 answer:
Rus_ich [418]3 years ago
8 0

Answer:

The program to this question as follows:

Program:

class Student //defining class student

{

int rollNumber=1001; //defining integer variable rollnumber and assign value

int value() //defining method value

{

return rollNumber; //return value

}

}

public class ProblemSolution extends Student //defining class problemSolution that inherits Student

{

int solution() //defining method solution

{

Student stu=new Student(); //creating student class object

return stu.value(); //call function using return keyword  

}

public static void main(String ax[]) //defining main method

{

int result; //defining integer variable result

ProblemSolution ps=new ProblemSolution(); //creating class object

result=ps.solution(); //holding value of solution function

System.out.println("rollNumber value is: "+result); //print value

}

}

Output:

rollNumber value is: 1001

Explanation:

In the above java code two-class "Student and ProblemSolution" is defined, in which student class an integer variable rollNumber is defined, that holds a value "1001", and inside this class, a method "value" is defined, that return above variable value.

  • In the next step, class "ProblemSolution" is defined, that inherits the student class, inside this class two method "solution and the main method" is defined.
  • Inside the solution method, the student class object is created and this method uses the return keyword to call the student class method "value".
  • In the main method, an integer variable "result" is defined, which holds its method "solution" value and uses print function to print its value.
You might be interested in
I need help with the code practice 9.2 Edhesive.<br><br> Thank you
antiseptic1488 [7]

Answer:

you talking about anaconda navigation? i would love to help!

Explanation:

3 0
3 years ago
Read 2 more answers
DO, of X isvvvvvvvvvvvvvvv
dem82 [27]
Huh ? I don’t understand the question
8 0
3 years ago
shana is keeping track of the expenses as deductions for her business when she files paperwork at the end of the year. What is s
Monica [59]

Shana I think is working on taxes

6 0
4 years ago
Read 2 more answers
Can someone tell me what this means it’s on my phone and it’s not been working for days ASAP REPLYS THANK YOU
bixtya [17]
Plug it into your computer I think
7 0
4 years ago
Read 2 more answers
What is an idea for novel food production technologies or systems that require minimal resources and produce minimal waste, whil
Luden [163]

Answer:

Dehydrated food that is vacuumed sealed.

Explanation:

Dehydrated food is not hard to make and holds the nutritious values needed for a human to survive. Dehydrated food can last up to 1-2 years if vacuumed sealed.

7 0
3 years ago
Read 2 more answers
Other questions:
  • The version of Windows that first provided networking capabilities was _____.
    12·2 answers
  • "You are on a service call to fix a customer’s printer when she asks you to install a software package. The software is on a per
    13·1 answer
  • Why is it important to brain storm and develop concepts prior to selecting an idea that you wish to move forward with as a solut
    7·1 answer
  • Which of the following is not something that consumers need to pay attention to order to make rational choices
    6·2 answers
  • What is a table in excel
    10·2 answers
  • What does f.i.r.s.t stand for in robotics
    15·1 answer
  • Describe the process of normalization and why it is needed.
    12·1 answer
  • Which online article citation is correctly formatted according to MLA standards?
    15·2 answers
  • JAVA<br>plzz help...............​
    7·1 answer
  • In a computer-controlled greenhouse, a temperature sensor and a window motor are connected to the computer.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!