explain why all xplain Why at the end ot each and every answer 0-1(7 marks): sel
ID: 3867545 • Letter: E
Question
explain why all
Explanation / 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;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.