Question & Answer: When one object is a specialized version of another object, there is this type of relationship between them. "contains a" "h…..

Question 1 When one object is a specialized version of another object, there is this type of relationship between them. contains a has a Direct is a Question 2 If addressList exists and has values stored in it and addrList is an array with values stored in it, what will be the results when the following code is executed? addressList.setListData (addrList) The values of addrList will be inserted at the beginning of the current addressList. The values in addressList will be replaced by the values in addrList. addressList will be unchanged The values of addrList will be attached at the end of the current address List. Question 3 What does the following statement do? double arrayl-new double[101: o declares arrayl to be a reference to an array of double values will allow valid subscripts in the range of 0-9 creates an instance of an array of 10 double values All of the above Question 4 What is an Interface? How are they used?

When one object is a specialized version of another object, there is this type of relationship between them. “contains a” “has a” Direct “is a” If addressList exists and has values stored in it and addrList is an array with values stored in it, what will be the results when the following code is executed? addressList.setListData (addrList): The values of addrList will be inserted at the beginning of the current addressList. The values in addressList will be replaced by the values in addrList. addressList will be unchanged. The values of addrList will be attached at the end of the current address List. What does the following statement do? double [] array1 = new double[10]: declares array1 to be a reference to an array of double values will allow valid subscripts in the range of 0-9 creates an instance of an array of 10 double values All of the above What is an Interface? How are they used?

Expert Answer

 

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: When one object is a specialized version of another object, there is this type of relationship between them. "contains a" "h…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

Question 1 Answer – It is “is a” relationship because when an object is a specialized version of another object it means that particular sub or child object inherits all the properties and methods of the base or parent object.

Example :-

class parent_class{

int a = 0, b = 8;

void set(int a, int b){

this.a = a;

this.b = b;

}

}

class child_class extends parent_class{

int c = 0, d = 0;

void setvariables(int c, int d){

this.c = c;

this.d = d;

}

}

In this example, we can say that there is a “is a” relationship between “parent_class” and “child_class” as it extends or inherits all the properties and methods(in this case variable a and b, method set) from parent class “parent_class” which is called inheritance.

Question 2 Answer – The following statement will do the following action – The values of addrList will be attached at the end of the current addressList because setListData method always attaches the current array list to the end of the existing array list.

Question 3 Answer – The following statement will declare “array1” to be a reference to an array of double values because when we declare an array, we are creating a reference variable to be an array of a specific data type.

Question 4 Answer – An interface is an abstract data type in a programming language. We cannot declare an object of an abstract data type as it can be implemented by another class or interface. Any class implementing an interface remains abstract until it implements all the methods and properties of the interface.

An interface may contain constants, default methods, static types and nested types. It can contain any number of methods. We cannot instantiate an interface. It cannot contain any constructors and all the mthods are abstract. It cannot contain any instance variables, it can only contain static and final variables. it can not be extended by class, it can only be implemented by class and it can extend multiple interfaces.

Example –

interface Animal{

final int a, b;

public void eat();

public void sleep();

}

class Dog implements Animal{

public void eat(){

System.out.println(“Dog eats food”);

}

public void sleep(){

System.out.println(“Dog sleeps at night”);

}

}

Still stressed from student homework?
Get quality assistance from academic writers!