adplus-dvertising

Welcome to the Classes and Methods MCQs Page

Dive deep into the fascinating world of Classes and Methods with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Classes and Methods, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Classes and Methods, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Classes and Methods. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Classes and Methods. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Classes and Methods MCQs | Page 25 of 30

Q241.
Java constructor overloading follows ___ principle in Object-Oriented programming.
Discuss
Answer: (c).Polymorphism
Q242.
Java allows calling or invoking a method from a constructor. State TRUE or FALSE.
Discuss
Answer: (a).TRUE
Q243.
What is the output of the below Java program?
public class Constructor9
{
  Constructor9()
  {
    show(); 
  }
  void show()
  {
    System.out.println("JAM JAM");
  }
  public static void main(String[] args)
  {
    Constructor9 con = new Constructor9();
  }
}
Discuss
Answer: (a).JAM JAM
Q244.
To successfully overload a method in Java, the return types must be ___.
Discuss
Answer: (c).Same but using superclass or subclass types also work
Q245.
To successfully overload a method in Java, the argument-list or parameter-list must be ___.
Discuss
Answer: (b).Different
Q246.
What is the output of the below Java program with multiple methods?
public class MethodOverloading1
{
  void show(int a, char b)
  {
    System.out.println("KING KONG");
  }

  void show(char a, int b)
  {
    System.out.println("JIM JAM");
  }
 
  public static void main(String[] args)
  {
    MethodOverloading1 m = new MethodOverloading1();
    m.show(10, 'A');
    m.show('B', 10);
  }
}
Discuss
Answer: (c).KING KONG
JIM JAM
Q247.
To successfully overload a method in Java, the method names must be ___.
Discuss
Answer: (a).Same
Q248.
What is the output of the below Java program?
public class MethodOverloading2
{
  int info()
  {
    System.out.println("PLANE");
    return 0;
  }

  void info()
  {
    System.out.println("AIRPORT");
  }

  public static void main(String[] args)
  {
    MethodOverloading2 m = new MethodOverloading2();
    int a = m.info();
  }
}
Discuss
Answer: (c).Compiler error
Q249.
What is the output of the below Java program with method overloading?
class Wood{ }
class SubWood extends Wood{ }

public class MethodOverloading3
{
  Wood display(int a)
  {
    System.out.println("PINE");
    return new Wood();
  }
  SubWood display()
  {
    System.out.println("TEAK");
    return new SubWood();
  }

  public static void main(String[] args)
  {
    MethodOverloading3 m = new MethodOverloading3();
    m.display();
  }
}
Discuss
Answer: (b).TEAK
Q250.
What is the output of the below Java program trying to overload a method "jump"?
class Rabbit{ }
class WildRabbit extends Rabbit{ }

public class MethodOverloading4
{
  Rabbit jump()
  {
    System.out.println("Rabbit Jump");
    return new Rabbit();
  }
  WildRabbit jump()
  {
    System.out.println("Wild Rabbit Jump");
    return new WildRabbit();
  }

  public static void main(String[] args)
  {
    MethodOverloading4 obj = new MethodOverloading4();
    obj.jump();
  }
}
Discuss
Answer: (c).Compiler error

Suggested Topics

Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!