Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8679831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:05:03+00:00 2026-06-12T21:05:03+00:00

Write the declaration for class B. The class’s members should be as follows: m,

  • 0

Write the declaration for class B. The class’s members should be as follows:

m, an integer. This variable should not be accessible to code outside the class or to any class that extends class B.

n, an integer. This variable should be accessible only to classes that extend class B or in the same package as class B.

setM, getM, setN, and getN. These are the mutator and accessor methods for the member variables m and n. These methods should be accessible to code outside the class.
calc. This is a public abstract method.

Next, write the declaration for class D, which extends class B. The class’s members should be as follows:
q, a double. This variable should not be accessible to code outside the class.
r, a double. This variable should be accessible to any class that extends class D or in the same package.
setQ, getQ, setR, and getR. These are the mutator and accessor methods for the member variables q and r. These methods should be accessible to code outside the class.
calc, a public method that overrides the superclass’s abstract calc method. This method should return the value of q times r.

Here is my code the stared ones is the part I got wrong –

import java.io.*;
public class ClassB{

   ***private int m;
   public int n;***
  public setM(int minteger){
      m=minteger;
   }
   public void getM(){
      return minteger;
   }
   public setN(int ninteger){
      n=ninteger;
   }
   ***public void getN(){
      return ninteger
   }***
}

public class ClassD extends ClassB
{
   private double q;
   ***public double r;***

  public setQ(double qdouble){
      q=qdouble;
   }
   public void getQ(){
      return qdouble;
   }
   public setR(double rdouble){
      r=rdouble;
   }
   public void getR(){
      return rdouble
   }
}
   ***public abstract class calc{
   return r*q
   }***
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:05:05+00:00Added an answer on June 12, 2026 at 9:05 pm

    make int n and double r as protected
    .
    In getN() you should write return n;Similarly in getM() write return m;, getQ() write return q; and in getR() write return r;

    You abstract class should look like:

     public abstract Calculator{
          public abstract calc();
     }
    

    You didn’t clearly mention where to use/override calc method

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a class that has a generic member variable but is
I am working my way through some Objective-C code that I did not write
Below is a very simple bit of code that mimics a class structure in
I see in a header that I didn't write myself the following: class MonitorObjectString:
I tend to write a class declaration in a source file and then decide
My Professor gave us this class and told us that it won't compile. He
suppose I write a template class with a template constructor, like that. template<typename T>
write a script that takes two optional boolean arguments,--verbose‚ and ‚--live, and two required
i write this in .emacs (require 'dired-x) (global-set-key (kbd C-x C-j) 'dired-jump) but when
if a have a declaration like def inside_classroom(request,classname): theclass = Classroom.objects.get(classname = classname) members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.