Tag: programming languages

Questions Related to programming languages

  1. The keyword extends is used to specify that an interface inherits from another interface.

  2. The keyword extends is used to specify that a class inherits from an interface.

  3. The keyword implements is used to specify that an interface inherits from another interface.

  4. The keyword implements is used to specify that a class inherits from an interface.

  5. The keyword implements is used to specify that a class inherits from another class.


Correct Option: A,D
  1. Less restrictive than public

  2. More restrictive than public, but less restrictive than protected.

  3. More restrictive than protected, but less restrictive than private.

  4. More restrictive than private.

  5. Less restrictive than protected from within a package, and more restrictive than protected from outside a package.


Correct Option: C
  1. static public void main(String[] args) { /* ... */ }

  2. public static int main(String[] args) { /* ... */ }

  3. public static void main(String args) { /* ... */ }

  4. public int main(Strings[] args, int argc) { /* ... */ }


Correct Option: A
  1. from base to the derived class

  2. from derived to base

  3. only the derived class

  4. only the base class


Correct Option: A
  1. A subclass must define all the methods from the superclass

  2. It is possible for a subclass to define a method with the same name and parameters as a method defined by the superclass.

  3. It is possible for a subclass to define a field with the same name as a field defined by the superclass.

  4. It is possible for two classes to be the superclass of each other.


Correct Option: B,C
  1. The class will fail to compile, since the class Other has not yet been declared when referenced in class AClass.

  2. The class will fail to compile, since import statements must never be at the very top of a file.

  3. The class will fail to compile, since the package declaration can never occur after an import statement.

  4. The class will fail to compile, since the class Other must be defined in a file called Other.java.

  5. The class will fail to compile, since the class Other must be declared public.


Correct Option: C