Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following Java code, what method m will be executed when b.m() is executed.. class A { void m() {..} } class B extends

Given the following Java code, what method m will be executed when b.m() is executed.. class A { void m() {..} } class B extends A {void m() {..} } class Client { public static void main (String args[]) { A a = new A(); B b = new B(); b.m(); }}

a. Method m belonging to class B will be executed.

b.

Since B is a sub-class A, method m belonging to class B will be executed after method m belong to class A is executed. Super class methods are always executed first.

c.

Since B is a sub-class A, method m belonging to class A will be executed after method m belong to class B is executed. Sub class methods are always executed first.

d.

All other answers are wrong

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions