A teacher gave me this lecture with some questions, and I am somewhat confused.
Say we have a hierarchy like:
Object
|
+---A
|
+---B
|
+---C
and we made these methods in Class A:
public abstract void method1();
public abstract void method2(int i);
so... these questions were presented to us:
(a) If class B does not override any of the two methods above, can class B be compiled cleanly? If so, can an object be created from class B? If not, explain why not.
(b) Now assume that class B overrides method1 given above. Can class B be compiled cleanly? If so, can an object be created from class B? If not, explain why not.
(d) In defining class A described above, must the abstract modifier be used in the 1st line of the class definition (or is it optional given that it has abstract method(s) in it)?
(e) In defining method1 and method2 described above, must the abstract modifier be used in the method statement (or is it optional given that it has no method body)?
Ok, so if a subclass, which would be B, doesn't override the abstract methods, it becomes an abstract class, correct? But I'm not really sure if it can create an object or not, I don't believe it can, but can someone at least elaborate on this.
I used it yesterday to create an ISO, then I mounted it just to check the build number, and it was 26200.8653 which I couldn't find any info about, I knew the latest Patch Tuesday biuld was 26200.8655.
Can Confirm, this only appears to happen on Edge installed on Android, No issue on Chrome, Firefox, Samsung Browsers.
Android 16
Samsung OneUI 8.5
Newest Releases of Each Browser (Edge, Firefox, Chrome, Samsung Browser)
This happens both With and Without my VPN being active.
Yay, a forced new tab telling everyone edge just updated with a load of advertising in it twice as often as we currently get it. That'll never be abused. 😏
Question
LRoling
A teacher gave me this lecture with some questions, and I am somewhat confused.
Say we have a hierarchy like:
Object
|
+---A
|
+---B
|
+---C
and we made these methods in Class A:
public abstract void method1();
public abstract void method2(int i);
so... these questions were presented to us:
(a) If class B does not override any of the two methods above, can class B be compiled cleanly? If so, can an object be created from class B? If not, explain why not.
(b) Now assume that class B overrides method1 given above. Can class B be compiled cleanly? If so, can an object be created from class B? If not, explain why not.
© Now assume that class C overrides method2 given above (with the assumption that B overrides method1, as discussed in part(b)). Can class C be compiled cleanly? If so, can an object be created from class C? If not, explain why not.
(d) In defining class A described above, must the abstract modifier be used in the 1st line of the class definition (or is it optional given that it has abstract method(s) in it)?
(e) In defining method1 and method2 described above, must the abstract modifier be used in the method statement (or is it optional given that it has no method body)?
Ok, so if a subclass, which would be B, doesn't override the abstract methods, it becomes an abstract class, correct? But I'm not really sure if it can create an object or not, I don't believe it can, but can someone at least elaborate on this.
Any help would be appreciated.
Link to comment
https://www.neowin.net/forum/topic/233031-java-abstract-class-concept/Share on other sites
7 answers to this question
Recommended Posts