Question
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started