Question

When I wrote this code in the Eclipse program, I did not see a output .....

When I wrote this code in the Eclipse program, I did not see a output .. Why?
___________________
public class YClass
{
private int a;
private int b;
public void one(){
}
public void two ( int x , int y ) ;
a=x;
b=y;
}
public YClass()
{
a=0;
b=0;
}
}

class XClass extends YClass{
private int z;
public void one()
{
}
public XClass
{
z=0;
}
}

YClass Object;
XClass Object;

Homework Answers

Answer #1

Your program is 100% correct,

  • You have initialized all variables and classes
  • You have used the inheritance between the classes.
  • Methods has been declared and everthing is fine.
  • Your program works 100% for sure.
  • Why it is not showing any output means,
    • You have just initialized the objects for XClass and YClass but no passing any arguments.
    • Moreover, in the whole program you haven't written any print statement to output something.
  • Corrections to be made
    • Try to pass the arguments in the form of values to the objects.
    • Include print statements to display the output.

I hope the above information and explanation will help you out to understand!

Please comment if you have any queries/errors!

Thank you!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Hello, I need a output for the following code as well as screenshots from the eclipse...
Hello, I need a output for the following code as well as screenshots from the eclipse page showing the output. Thank you public class COMP1050 { public static void main(String[] args) { System.out.printf("before"); new CS(); System.out.printf(".after"); } } public class CS extends WIT { public CS() { System.out.printf(".cs"); } } public class WIT { public WIT() { System.out.printf(".wit"); } }
I wrote the following java code with the eclipse ide, which is supposed to report the...
I wrote the following java code with the eclipse ide, which is supposed to report the number of guesses it took to guess the right number between one and five. Can some repost the corrected code where the variable "guess" is incremented such that the correct number of guesses is displayed? please test run the code, not just look at it in case there are other bugs that exist. import java.util.*; public class GuessingGame {    public static final int...
I have wrote this code for arduino to turn the LED light off when an object...
I have wrote this code for arduino to turn the LED light off when an object is not detected and the LED light on when an object is detected, although the code is not working. How can I improve this? #define trigPin 12 #define echoPin 11 int ledPin= 1; //Connect LEd pin to 6 int duration, distance; //to measure the distance and time taken void setup() { Serial.begin (9600); //Define the output and input objects(devices) pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(ledPin,...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { flavor = s; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         System.out.println(pepper.getFlavor());     } } a. a class variable b. a constructor c. a local object variable d....
Hello. I have an assignment that is completed minus one thing, I can't get the resize...
Hello. I have an assignment that is completed minus one thing, I can't get the resize method in Circle class to actually resize the circle in my TestCircle claass. Can someone look and fix it? I would appreciate it! If you dont mind leaving acomment either in the answer or just // in the code on what I'm doing wrong to cause it to not work. That's all I've got. Just a simple revision and edit to make the resize...
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*;...
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*; import javax.swing.*; public class Clicker extends JFrame implements ActionListener {     int count;     JButton button;     Clicker() {         super("Click Me");         button = new JButton(String.valueOf(count));         add(button);         button.addActionListener(this);         setSize(200,100);         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         setVisible(true);     }     public void actionPerformed(ActionEvent e) {         count++;         button.setText(String.valueOf(count));     }     public static void main(String[] args) { new Clicker(); } } a. add(button);...
I am writing code in java to make the design below. :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) I already have...
I am writing code in java to make the design below. :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) I already have this much public class Main { int WIDTH = 0; double HEIGHT = 0; public static void drawSmileyFaces() { System.out.println(" :-):-):-):-):-):-)"); } public static void main (String[] args) { for (int WIDTH = 0; WIDTH < 3; WIDTH++ ) { for(double HEIGHT = 0; HEIGHT < 2; HEIGHT++) { drawSmileyFaces(); } } } } I am pretty sure that alot of this is wrong...
In Java Let’s say we’re designing a Student class that has two data fields. One data...
In Java Let’s say we’re designing a Student class that has two data fields. One data field, called id, is for storing each student’s ID number. Another data field, called numStudents, keeps track of how many Student objects have been created. For each of the blanks, indicate the appropriate choice. id should be   public/private   and   static/not static . numStudents should be   public/private   and   static/not static . The next three questions use the following class: class Counter {     private int...
Here is my java code, I keep getting this error and I do not know how...
Here is my java code, I keep getting this error and I do not know how to fix it: PigLatin.java:3: error: class Main is public, should be declared in a file named Main.java public class Main { ^ import java.io.*; public class Main { private static BufferedReader buf = new BufferedReader( new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { String english = getString(); String translated = translate(english); System.out.println(translated); } private static String translate(String s) { String latin =...
Give the output of the program using Call-By-Reference: int i, a[3]; void f (int x, int...
Give the output of the program using Call-By-Reference: int i, a[3]; void f (int x, int y){ x = (x*y) mod 3; y = y – x; } main(){ i = 0; a[0] = 1; a[1] = 2; a[2] = 0; f(i, a[i]); print(“%d %d %d %d\n”, i, a[0], a[1], a[2]); f(a[i], a[i]); print(“%d %d %d\n”, a[0], a[1], a[2]); }
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT