Aliensbrain
  • Home
  • Topics
  • Quizzes
  • Notebooks
  • Community
  • Sign in
  • programming languages Online Quiz - 17
  • What are the rules to implement an interface? Considering th...

What are the rules to implement an interface? Considering the following declaration for interface Convertable, which of the following code segments will compile?

public interface Convertable {
    int convertToInt();
    char convertToChar();
}

a)

class Digit implements Convertable {
    public char convertToChar() {
        return 0;
    }
    public int convertToInt() {
        return 0;
    }
}

b)

 abstract class Digit implements Convertable {
     int convertToInt();
     char convertToChar();
 }

c)

abstract class Digit implements Convertable {
    public int convertToInt() {
        return 0;
    }
}

d)

abstract class Digit implements Convertable {
    public int convertToInt() {
        return 0;
    }
    char convertToChar();
}

e)

  class Digit implements Convertable {
    int convertToInt() {
        return 0;
        return 0;
    }
}

f)

interface Roundable extends Convertable {
    int roundUp();
}

technology programming languages
  1. a, b, c

  2. a, d, e

  3. a, c, f

  4. a, d, f


Show answer
Correct Option: C

Find more quizzes:

© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy