What is the result of the following code fulfillment:

class A {
    public void m(int k) {
        System.out.println("class A, method m : " + ++k);

class B extends A {
    public int m(int k) {
        System.out.println("class B, method m : " + k++);
        return k;

public class MainClass {
    public static void main(String args[]) {
        A a = new B();
Explanation: in the methods void m(int k) Class A and int m(int k) Class B the types of the returned values don't match, which causes a compiler error.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes