Ask Experts Questions for FREE Help !
Ask
    nomasana's Avatar
    nomasana Posts: 2, Reputation: 1
    New Member
     
    #1

    Oct 23, 2013, 05:57 PM
    Java question
    Consider the following two class code:
    Public class MyClass {
    Protected int data1 = 0;
    Private char data2 = 0;

    Public MyClass(int x) {
    Data1= x;
    Data2 = data1 + 1;
    }

    Public getData2() {
    Return data2;
    }

    Public void doWork() {
    System.out.println(“In doWork of MyClass”);
    }
    }

    Public class YourClass extends MyClass {
    Private int data3 = 0;

    Public YourClass(int x) {
    Super(x);
    Data3 = x + 2;
    }

    Public void doWork() {
    System.out.println(“In doWork of YourClass”);
    }
    }

    Suppose we have the following code:
    MyClass m;
    YourClass y;
    M = MyClass(1);
    Y = YourClass(2);
    M.doWork();
    Y.doWork();
    M = y;
    M.doWork();

    I) (5 points) Show the all the class attribute values of the two objects (m and y), after the objects get instantiated (be careful).


    ii) (5 points) What gets printed when the code snippet is executed.
    ma0641's Avatar
    ma0641 Posts: 15,675, Reputation: 1012
    Uber Member
     
    #2

    Oct 23, 2013, 08:48 PM
    This is the second JAVA homework or test question. Why are you taking the class without trying to learn? We do not answer these types of questions.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Please fix this java question with code [ 2 Answers ]

Please fix this coding with Java Programming. Vehicle Make.. Model.. Noise Factor... InterstatePermitscurrent... Parking Fines Holden... Colorado... 2.. . 0 Chrysler... Aspen... 3.. . 0 Toyota... Lite Ace... 4.. . 0 Ford... F350... 5... ….. . 0 Dodge... Sprinter... 6.. . 2 Hino......

Ask a java question [ 1 Answers ]

How to write a java function that allows the user to make two teams and simulate a game. The program should employ polymorphism and allow subclasses. As scores against teams should be simulated by randomization- use random method to decide who scores against the other and by how many goals. this...

Forum to ask java question [ 1 Answers ]

hi guys me working on swing in a project and I'm not understanding how me can get value from jList from one page to another page in jtextfield me using netbean /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /*


View more questions Search