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
What is value parameter and reference parameter while things are passed by Also, do a c code to show it
azamat

Answer: While constructing a function the parameters can be passed by value or by reference.

In value parameter we actual make a copy of the values which has been passed to the function from the main method while we reference parameter we copy the address of the values in memory so that while our program references those values it it can refer them from their memory location.

Explanation:

Now we take can example to show parameter passing by value and reference with the help of an C program to add two numbers

int add_val(int x, int y) {

 return x + y;

}

void add_ref(int *x, int y) {

 *x += y;

}

int main () {

 int a, b, c, d;

 a = 2;

 b = 1;

 c = add_val(a,b); //value parameter

 d = add_ref(&a, c); // reference parameter

 return 0;

}

In the above code the value the value of c is 3 and the value of d is 5. In add_p we have passed the address of the a but in add_val we have passed the values of a and b.

3 0
4 years ago
Which two statements describe features of an ipv4 routing table on a router? (choose two.)
solong [7]

The statements that describe features of an ipv4 routing table on a router include:

  • Directly connected interfaces will have two route source codes in the routing table.
  • If a default static route is configured in the router, an entry will be included in the routing table with source code.

It should be noted that the IPv4 route table is important for listing entries that are in the routing table.

The routing table of every router is unique and can be stored in the read access memory (RAM) of the device.

Read related link on:

brainly.com/question/24958077

7 0
3 years ago
Please give all the answer​
il63 [147K]

Answer:

am/is=was

are=were

do=did

go=went

eat=ate

have=had

make=made

take=took

see=saw

fly=flew

sell=sold

tell=told

find=found

sent=sent

Explanation:

These are all present/ past tense

I hope this helps.

5 0
3 years ago
Read 2 more answers
Do you hate Final Fantasy VII Remake and why
pashok25 [27]

Answer: I never watched it...looking forward to watch it.

4 0
3 years ago
Read 2 more answers
Why is it important to protect people's intellectual property online?
grigory [225]
I believe that the answer is D hope this helped
6 0
3 years ago
Other questions:
  • What are some common characteristics of jobs in this career cluster? check all that apply
    10·2 answers
  • What are some ways social media networks make money from users
    10·1 answer
  • Which one of the following analog VOM ranges would be selected to measure a DC current of 90 milliamps? A. 10mA B. 1.0A C. 10A D
    14·2 answers
  • (tco 3) what vbscript boolean operator could be used to replace the nested selection structure in this pseudocode? if empmedical
    13·1 answer
  • The smallest unit of storage is​
    15·1 answer
  • In your own words describe the benefits of creating functions in your code
    12·1 answer
  • Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 5
    15·1 answer
  • The Danger zone around a robot is?
    13·2 answers
  • Your friends are having difficulties with their computer setups. Can you suggest a way to help each friend?
    5·1 answer
  • In a DTP project, Fiona is looking for a way to make a page layout attractive to readers. Help Fiona pick the correct word to co
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!