Question: Question 1 True or False: In a class-based object oriented language (like Java) classes define types of objects - including the things these object know
Question 1
True or False: In a class-based object oriented language (like Java) classes define types of objects - including the things these object know and the things these objects can do.
| True |
| False |
Question 2
The Java keyword new is used for what purpose?
| to reset an object to its default state |
| to declare a variable |
| to clear all local variables |
| to declare or define a method |
| to instantiate an object of a class |
Question 3
True or False: The purpose of a constructor is to initialize an object into a valid state.
| True |
| False |
Question 4
True or False: A constructor method is guaranteed to execute when an object is instantiated.
| True |
| False |
Question 5
Consider the following Java class declaration. How many methods are defined in this class?
class Bunny { int age; String name; void hop() { System.out.println(name + " hops around."); } void eat(String food) { System.out.println(name + " eats the " + food + "."); } void sleep() { System.out.println(name + " takes a nap."); } } | 0 |
| 1 |
| 2 |
| 3 |
| 4 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
