Please, i need Unique answer, Use your own words (don't copy and paste). *Please, don't use handwriting. Please,...

Free

90.2K

Verified Solution

Question

Programming

Please, i need Unique answer, Use your ownwords (don't copy and paste).

*Please, don't use handwriting.

Please, i need Unique answer, Use your ownwords (don't copy and paste).

*Please, don't use handwriting.

Q1: Assume that there is a class namedTestInterface that implements two interfacesA and B. Both the interfaces havea common method with the same signature (example intsampleMethod()). Explain how will the classdefine this method and how will the compiler identify, to whichinterface does this method belong to? Will the compiler give anerror or will the program execute successfully. Give your codesnippet to support your answer.

Please, i need Unique answer, Use your ownwords (don't copy and paste).

*Please, don't use handwriting.

Please, i need Unique answer, Use your ownwords (don't copy and paste).

*Please, don't use handwriting.

_______________________________________________

Q4:

  1. Mention the appropriate relationship between following classes:[0.5 Marks]
  1. HOD–StaffMember
  2. Car–Ferrari
  3. Student-Address
  4. BankAccount–FixedAccount
  5. House-Building
  6. Department-Teacher
  7. Traffic–TrafficSign

b.

  1. Provide the UML diagram for the following program.
 
        class Parent 
        {
               public void getBike()
                {
                       System.out.println(\"Suzuki Bike\");
                }
        }
        class Child extends Parent 
        {
               public void getCar()
                {
                       System.out.println(\"Swift car\");
                }
        }
        class inheritance 
        {
                public static void main(String args[])
                {
                  Parent p = new Parent();
                  p.getBike();
                  Child c = new Child();
                  c.getBike();
                  c.getCar();
                }

           }

Please, i need Unique answer, Use your ownwords (don't copy and paste).

*Please, don't use handwriting.

Please, i need Unique answer, Use your ownwords (don't copy and paste).

*Please, don't use handwriting.

Answer & Explanation Solved by verified expert
3.9 Ratings (742 Votes)

Q.1

Solution for the above:

public class HelloWorld {

public static void main(String[]args){

TestClass test=new TestClass();

test.diplay();

}

}

interface TestInterface{

void display();

}

interface|1 extends TestInterface{

@Override

void display();

}

interface|2 extends TestInterface{

}

class TestClass implements|1,|2{

@Override

pulic void display(){

sytem.out.printIn('Yes\");

}

}

so this is the code given according to the problem.

-first interface i have overrriden the class but in other i have not done.

-make sure that if an interface extends another interface it is not required to override the methods.

-the methods are overrriden in all the interface. complier will not give error.

now, lets see the code for the requirement:

public class HellowWorld{

public static void main(string[]args){

TestClass test=new TestClass();

test.display();

}

}

interface TestInterface{

void display();

}

interface|1extends TestInterface{

@overrride

void display();

}

interface|2 extends TestInterface{

@override

void display();

}

class TestClass implements |1,|2{

@overrride

public void display(){system.out.printIn(\"Yes\");

}

}


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students