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
In a three-tier architecture, the component that runs the program code and enforces the business processes is the:_______.
madam [21]

Answer:

Application Server

Explanation:

The Application Server is a component in computer engineering that presents the application logic layer in a three-tier architecture.

This functionality allows client components to connect with data resources and legacy applications.

In this process of interaction, the Application Server runs the program code from Tier 1 - Presentation, through Tier 2 - Business Logic to Tier 3 - Resources, by forcing through the business processes.

8 0
3 years ago
What was bill gates first operating system he created?
vagabundo [1.1K]
Microsoft windows was his first

3 0
3 years ago
A​ _______ helps us understand the nature of the distribution of a data set.
Sphinxa [80]

Frequency distribution
3 0
3 years ago
Demonstrate the register addressing mode for the following instructions. Also what addressing mode belongs to these instructions
kotykmax [81]

Answer:

Demonstrate the register addressing mode for the following instructions. Also what addressing mode belongs to these instructions?

1. MOV CX, [BX+DI]

2. MOV AX, ARRAY[CX]

3. MOV BX, [CX+DI+6]

4 0
3 years ago
What is the benefit of using a creative commons license?
alukav5142 [94]
It makes things easier for creative people 
3 0
3 years ago
Other questions:
  • Which information technology job has the lowest predicted 10-year growth? computer programmer software developer computer suppor
    13·1 answer
  • Data arranged and stored in a data set
    9·1 answer
  • To what extent can u justify that computer is not the only ICT tool?​
    9·1 answer
  • What are the TWO methods of copying and pasting on the AutoCAD Clipboard function?
    7·1 answer
  • Write c++ program bmi.cpp that asks the user bmi.cpp the weight (in kilograms) and height (in meters).
    12·1 answer
  • Which of these programmers creates the core game engine?
    5·2 answers
  • Explain why interrupt times and dispatch delays must be limited to a hard real-time system?
    8·1 answer
  • The information given to you by your teachers is always accurate and should never be questioned. Please select the best answer f
    8·1 answer
  • Select the correct answer from the drop-down menu.
    15·2 answers
  • How many pages is 1500 words double spaced 12 font?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!