Question & Answer: xplain Why at the end ot each and every answer 0-1(7 marks): select only one choice in the following 1. The keyword that is…..

xplain Why at the end ot each and every answer 0-1(7 marks): select only one choice in the following 1. The keyword that is used to let the Field can be accessed by class Name and n to create an object: a)void b)private c)public d)static 2. Many methods with the same name is known as: a)method calling b)returning c)overloading d)dupli 3. What is constructor? One ofthe follwing is False a) Constructor cannot be overloaded b) Constructor does not have returning value. c) Constructor have same name of its class name. d) Constructor can be may have parameters. 4. Given the following 2 methods, are considered as a correct overloaded methods public static void checkID(int id) public static boolean checkID(int x) a)true b)false 5. Given a class Student, and array of Students S, then one of the following stateme used to change the age of the 3rd student in S: a) S[3]·Age 20; b) S[2]·Age d) None; = 20; = 6. One of the following statements prints out the last element in B Array: a) System.out.printin( B[B.length])

media%2F5cd%2F5cdaf290-9c4a-4735-8e50-53

media%2Fb64%2Fb642526f-cd16-4b60-b1f8-81

media%2Fefc%2Fefc5e87b-aa21-46de-9b40-d2

media%2Fe7e%2Fe7e59a57-4576-4b15-bfd5-5a

media%2Fca2%2Fca20503d-4984-4eec-b27a-5c

explain why all

xplain Why at the end ot each and every answer 0-1(7 marks): select only one choice in the following 1. The keyword that is used to let the “Field” can be accessed by class Name and n to create an object: a)void b)private c)public d)static 2. Many methods with the same name is known as: a)method calling b)returning c)overloading d)dupli 3. What is constructor? One ofthe follwing is False a) Constructor cannot be overloaded b) Constructor does not have returning value. c) Constructor have same name of its class name. d) Constructor can be may have parameters. 4. Given the following 2 methods, are considered as a correct overloaded methods public static void checkID(int id) public static boolean checkID(int x) a)true b)false 5. Given a class Student, and array of Students S, then one of the following stateme used to change the age of the 3rd student in S: a) S[3]·Age 20; b) S[2]·Age d) None; = 20; = 6. One of the following statements prints out the last element in B Array: a) System.out.printin( B[B.length])

Expert Answer

 

1) D) static

Making class members (variables) static allows us to use these members just by using class name without instantiating.

2) C) Overloading

Function overloading refers to creating more than one function under same name

3) A) A constructor cannot be overloaded

This is false as we are allowed to overload the constructor ( overload means having more than one constructor )

4) B) false

Because for methods to be overloaded there should be difference in the type of parameters of the function

5) B) S[2].Age = 20;

Because in java indexing of array start from 0 .

6) B) System.out.println( B[B.length -1 ] );

array.length gives length of the array but the maximum index is length -1 because indexing starts from 0

7) D) 50

because it uses conditional operator (condition) ? True : False ;  If the condition is true then statement written after : will get executed and if the condition is True then the statement before : will be executed

Q 2) int A [] = { 2, 4, 6, 8, 10, 12 };

Q 3) OUTPUT :-

//1 – green

//2 – light green

//3 – light green

//4 – Yellow

//5 – red

//6 – red

Q) 4 )

// 1. Constructor with 0-parameters (that assigns nothing)
public Animal() {

this.name = “”;
}
// 2. Constructor that assigns all the variables
public Animal(String name, int legs) {
this.name = name;
this.legs = legs;
}

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