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
_______________ is the term for the convergence of real-time and non-real-time communications services such as telephony, instan
Anna007 [38]

Answer:

Unified communications

Explanation:

Unified communications is the term for the convergence of real-time and non-real-time communications services such as telephony, instant messaging, video conferencing, speech recognition, voice mail, and email into a single interface.

8 0
3 years ago
Create a class, using separate files, named DynamicGrades. (2 points) This class has three data members: an int that represents
Alex

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

//DynamicGrades.h

class DynamicGrades

{

public:

DynamicGrades(int size);

~DynamicGrades();

void mutate(int studentId, int index, int grade);

int getGrade(int studentId, int index);

private:

int m_studentId;

int m_noofGrades;

int* m_dynamicArr;

};

//DynamicGrades.cpp

#include "DynamicGrades.h"

DynamicGrades::DynamicGrades(int size)

{

m_noofGrades = size;

m_dynamicArr = new int[m_noofGrades] {0};

}

DynamicGrades::~DynamicGrades()

{

if(nullptr != m_dynamicArr)

delete[] m_dynamicArr;

}

void DynamicGrades::mutate(int studentId, int index, int grade)

{

m_studentId = studentId;

if (index < m_noofGrades)

m_dynamicArr[index] = grade;

}

int DynamicGrades::getGrade(int studentId, int index)

{

if (index >= m_noofGrades)

return -1;

return m_dynamicArr[index];

}

//Main.cpp

#include "DynamicGrades.h"

int main()

{

DynamicGrades* grade = new DynamicGrades(5);

DynamicGrades grade2(10);

for (int i = 0;i < 5;++i)

{

grade->mutate(2, i, i + 1);

}

for (int i = 0; i < 10; i++)

{

grade2.mutate(3, i, i + 1);

}

cout << "Grades are " << endl;

for (int i = 0;i < 5;++i)

{

cout << grade->getGrade(2, i) <<" ";

}

cout << endl;

for (int i = 0; i < 10; i++)

{

cout << grade2.getGrade(3, i) << " ";

}

}

3 0
3 years ago
5. Are you more honest in your online communication? Explain your response.
Sati [7]
Multiple research has been conducted with regards to this point of view, but the common conclusion is that it depends more on the platform. People tend to be more dishonest when not comfortable and when given the chance live off their fantasy even for short while online. We all do agree that an example is the social media where in order to get attention we only share positive things. You might want to check speaker Simon Sinek and see rich views and in depth understanding of how technology has changed us.
5 0
3 years ago
Click to review the online content. Then answer the question(s) below, using complete sentences. Scroll down to view additional
kumpel [21]

Explanation:

hope this help here is the answer

3 0
3 years ago
as measuring the current, the shunt resistance of a galvanometer is needed to be zero. so why don't we put a wire parallel to th
Mariulka [41]

Galvanometer is a device used to detect an electric current.

<u>Explanation:</u>

A galvanometer is an electro mechanical instrument utilized for distinguishing and demonstrating an electric flow. A galvanometer fills in as an actuator, by creating a revolving redirection, in light of electric flow moving through a loop in a consistent attractive field.

Galvanometer is a gadget which is utilized to quantify electric flows. Note that the shunt obstruction must be low with the goal that greatest current goes through the shunt. Thus galvanometer can be utilized to gauge high flows.

7 0
3 years ago
Other questions:
  • Consider a method defined with the header:
    13·1 answer
  • Name that red flag asigment
    15·2 answers
  • What is ucspi-tcp pakage in qmail??
    5·1 answer
  • In an AND truth table.
    7·1 answer
  • The simplest method to copy information is to first select the information you want to copy, and then use the Copy button and th
    11·1 answer
  • A technician removes the cap from the brake fluid reservoir and finds that the rubber boot in the cap is swollen. technician a s
    8·1 answer
  • Your computer is taking longer than usual to open files and you notice that your hard drive light stays on longer than usual whi
    9·1 answer
  • Help plz, u just gotta select all that apply :)
    15·1 answer
  • in python Write a program that prompts the user to enter a hex character and displays its corresponding decimal integer python
    14·1 answer
  • Name any three areas of of application of excel.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!