Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

_ 4 Which of the following is the default value of a local variable? A - null B-

ID: 3590137 • Letter: #

Question


_ 4 Which of the following is the default value of a local variable? A - null B-0 C - Depends upon the type of variable D - Not assigned 5. Which of the following is true about protected access modifier? A - Variables, methods and constructors which are declared protected can be accessed by any class. B - Variables, methods and constructors which are declared protected can be accessed by any class lying in same package. c·vanables, methods and constructors which are declared protected in the superclass can be accessed only by its child class. D None of the above. Which of the following is false about String? A - String is immutable. B String can be created using new operator C - String is a primary data type D - None of the above 6. . Consider the code segment below public class AGoodClass public void oneMethod) t System.out.printin("Hello again!!) public static void main IString [I args) f AGoodclass cenew AGoodclass ce.oneMethod) What is the output from above code? A- "Hello again!! B The code does not compile because there is no constructor C The code does not compile because the oneMethod is not correct D - None of above 8. Composition represents A - HAS-A relationship. B IS-A relationship. -9. which statement below is correct about static variables A- static variables can only be accessed by static methods B - static variables can not be inherited. C - static variables can not be accessed using class prefix. D-static variables can be accessed even without creating an object of class.

Explanation / Answer

Ans 4 - ->c, it depends upon the type of the variable.If the variable is of integer type then it will be having default value 0 if string type the null if float then 0.0 and so on.

Ans 5--> b, The protected access specfier allows u access the protected memebers and constructors to be accessed in the same package as well as to the subclasses which inherits the class in which protected members were declared.

3rd option i.e c is wrong becoz here it is said that protected members are only accessible to the child classes. But as we knw it is accessible to the classes of same pacakge hence it was a wrong option.

Ans 6--> c ,The string is not a primary data type as the primary data types are the most basic data types such as char ,int float etc whereas string is the advancement of char data type with some more memory as string is tge the collection of characters.

Ans 7-->a, the output will be Hello again!! .

As we all knw that execution of a program starts through main function...so going to main it first created a object of the cls and the called the function onemethod(). So the output is Hello again!!.