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 19 of 30

Explore more Topics under Java Programming

Q181.
What is the output of the below Java program?
//bingo.java file
public class Hello
{
  public static void main(String[] args)
  {
    System.out.println("BINGO");
  }
}
Discuss
Answer: (c).Compiler error
Q182.
State TRUE or FALSE.
A Java class provides encapsulation.
Discuss
Answer: (a).TRUE
Q183.
What is the output of the below java class?
class Fox
{
  int legs = 2;
}
class Testing2
{
  public static void main(String[] args)
  {
    Fox t1 = new Fox();
    System.out.println("T1 before: " + t1.legs);
    t1.legs = 4;
    System.out.println("T1 After: " + t1.legs);
  }
}
Discuss
Answer: (c).T1 before: 2
T1 After: 4
Q184.
The value of one primitive variable is assigned to another primitive variable by ___ in Java.
Discuss
Answer: (a).Pass by value
Q185.
A primitive variable is passed from one method to another method by ___ in Java.
Discuss
Answer: (a).Pass by value
Q186.
An object or primitive value that is passed from one method to another method is called ___ in Java. (Argument / Parameter)
Discuss
Answer: (b).Parameter
Q187.
An object or a primitive value that is received in a method from another method is called ___ in Java. (Argument / Parameter)
Discuss
Answer: (a).Argument
Q188.
What is the output of the below Java program that passes an object to another method?
class Food
{
  int items;
  int show()
  {return items;}
}

class Testing9
{
  public static void main(String[] args)
  {
    Food f = new Food();
    f.items = 5;
    System.out.println("Items Before = " + f.show());
    change(f);
    System.out.println("Items After = " + f.show());
  }
  static void change(Food foo)
  { foo.items = 10; }
}
Discuss
Answer: (c).Items Before = 5
Items After = 10
Q189.
What is the output of the below Java program that passes primitive values?
class Testing10
{
  int rats = 5;

  public static void main(String[] args)
  {
    Testing10 t1 = new Testing10();
    System.out.println("Rats Before = " + t1.rats);
    modify(t1.rats);
    System.out.println("Rats After = " + t1.rats);
  }
  static void modify(int r)
  { r = 20; }
}
Discuss
Answer: (a).Rats Before = 5
Rats After = 5
Q190.
Java object assignment happens by ___.
Discuss
Answer: (b).Pass by Reference

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!