Question: Which of the following would cause a syntax error? Question 1 Answer a . A sub class reference variable referencing an object of the sub
Which of the following would cause a syntax error?
Question Answer
a
A sub class reference variable referencing an object of the sub class type
b
A sub class reference variable referencing an object of the type of the sub class's super class
c
A super class reference variable referencing an object of the super class type
d
A super class reference variable referencing an object of the type of one of its sub classes
e
If you think none of the above will cause a syntax error, select this option
Question
Not yet answered
Marked out of
Flag question
Question text
Which is NOT a correct explanation of the code given below.
Question Answer
a
Person objRef new Lecturer;
objRef.name "Goo";
is an example of Upcasting
b
Lecturer lec LecturerobjRef;
lec.age ;
is an example of Downcasting
c
objRef.display;
lec.display;
outputs:
Lecturer
Lecturer
d
System.out.printlnlecname lec.age;
outputs:
Goo
e
The code will not compile.
Question
Not yet answered
Marked out of
Flag question
Question text
Which of the following is not true about a set of methods that are usefully polymorphic?
This question only considers inheritancebased polymorphism ie it does not consider Interfaces.
Question Answer
a
They must have identical signatures and therefore belong to separate classes
b
Their classes share a common ancestor class from which they are ultimately inherited
c
Each should produce a specialised effect appropriate to their class and therefore different to each other
d
To be invoked polymorphically, an object of their class's type must be referenced by a variable of an ancestor's type common to all of them
e
If you think all of the above are true, select this option
Question
Not yet answered
Marked out of
Flag question
Question text
Which of the following is false with respect to downcasting.
Question Answer
a
It can be done without declaring a new variable
b
It's necessary when you want to invoke a method available in the object's class but not in its reference variable's class
c
The downcast must always be to the object's class
d
You can only downcast between classes andor interfaces connected in a classInterface hierarchy
e
Select this option if you think none of the above are false
Question
Not yet answered
Marked out of
Flag question
Question text
Which of the following are required for method overriding?
subsuper means the methods are in two classes that are in an inheritance relationship
Question Answer
a
Same name, same signature, same class
b
Same name, different signature, same class
c
Same name, same signature, subsuper class
d
Same name, different signature, subsuper class
e
Select this option if you think none of the above are required.
Question
Not yet answered
Marked out of
Flag question
Question text
Assume that Student is a subclass of Person, and FITStudent is a subclass of Student.
Which of the following is not a valid reference, given
Student s new Student Ash;
Question Answer
a
Student student s;
b
Object o s;
c
FITStudent student s;
d
Person p s;
Question
Not yet answered
Marked out of
Flag question
Question text
Which of the following best describes polymorphism in Java?
Question Answer
a
The ability of undefined data to be processed in at least one form
b
The ability for a data to be processed in more than one form
c
The ability of data to be defined in one form
d
The ability of data in a single form, to be reused by all subclasses
Question
Not yet answered
Marked out of
Flag question
Question text
Which of the following is not true about interfaces in Java?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
