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 1Answer
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 2
Not yet answered
Marked out of 1.00
Flag question
Question text
Which is NOT a correct explanation of the code given below.
Question 2Answer
a.
Person objRef = new Lecturer();
objRef.name = "Goo";
is an example of Upcasting
b.
Lecturer lec =(Lecturer)objRef;
lec.age =21;
is an example of Downcasting
c.
objRef.display();
lec.display();
outputs:
Lecturer
Lecturer
d.
System.out.println(lec.name +"/"+ lec.age);
outputs:
Goo/21
e.
The code will not compile.
Question 3
Not yet answered
Marked out of 1.00
Flag question
Question text
Which of the following is not true about a set of methods that are usefully polymorphic?
This question only considers inheritance-based polymorphism i.e. it does not consider Interfaces.
Question 3Answer
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 4
Not yet answered
Marked out of 1.00
Flag question
Question text
Which of the following is false with respect to downcasting.
Question 4Answer
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 and/or interfaces connected in a class/Interface hierarchy
e.
Select this option if you think none of the above are false
Question 5
Not yet answered
Marked out of 1.00
Flag question
Question text
Which of the following are required for method overriding?
(sub/super means the methods are in two classes that are in an inheritance relationship)
Question 5Answer
a.
Same name, same signature, same class
b.
Same name, different signature, same class
c.
Same name, same signature, sub/super class
d.
Same name, different signature, sub/super class
e.
Select this option if you think none of the above are required.
Question 6
Not yet answered
Marked out of 1.00
Flag question
Question text
Assume that Student is a subclass of Person, and FIT1051Student is a subclass of Student.
Which of the following is not a valid reference, given
Student s = new Student ("Ash","12345");
Question 6Answer
a.
Student student = s;
b.
Object o = s;
c.
FIT1051Student student = s;
d.
Person p = s;
Question 7
Not yet answered
Marked out of 1.00
Flag question
Question text
Which of the following best describes polymorphism in Java?
Question 7Answer
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 8
Not yet answered
Marked out of 1.00
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!