Top

Language Fundamentals - General Questions

1.

The == operator can be used to compare two String objects. The result is always true if the two strings are identical.

Answer: B

String objects must be compared using the "equals" method of one of the objects. Food for thought: will the == operator ever return true when two string objects are compared using it?

Enter details here

2.

Objects of a subclass can be assigned to a super class reference.

Answer: A

Objects of a super class may not be assigned to a sub class reference. Food for thought: why is it so?

Enter details here

3.

Objects of a super class can always be assigned to a subclass reference.

Answer: B

Objects of a subclass may be assigned to a super class reference. Food for thought: is there a loss in functionality when this is done?

Enter details here

4.

An individual array element from an array of type int, when passed to a method is passed by value.

Answer: A

Individual elements of an array of this type are passed by value as a parameter to a method. Any changes to them in the method will not change the value of the array element

Enter details here

5.

An array in the Java programming language has the ability to store many different types of values.

Answer: B

All elements of an erray must be of the same type. However, it is possible to declare an array of objects, which may of instances of different classes.

Enter details here

Loading…