

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A series of exercises and questions designed to reinforce understanding of fundamental object-oriented programming concepts in java. It covers topics such as classes, objects, constructors, methods, inheritance, and polymorphism. The exercises provide practical examples and scenarios to solidify knowledge and promote deeper comprehension of these core principles.
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


What is an object in Java? - correct answer An object is something that contains both state and behavior. What is the difference between a class and an object? - correct answer Objects are instances of classes. The class is the general template, and the object is the specific version. What does it mean to be a client of a class? - correct answer Being a client of a class means that we can use its methods and functionality without necessarily understanding how it works. What is a constructor in Java? - correct answer A constructor allows us to create a new instance of a class, usually initializing instance variables. Which of the following is the correct /* implementation / code for the constructor in the Card class? - correct answer suit = cardSuit; value = cardValue; What is an instance method? - correct answer An instance method is a piece of code called on a specific instance of the class. It is called with a receiver object. Which of the following is correct / implementation */ code? I. - correct answer III only What is the difference between a getter method and an accessor method? - correct answer There is no difference. They refer to the same idea. Which of these is an example of calling a static method? - correct answer Math.abs(x) double sum(int one, double two) - correct answer I II and IV Which variables are in scope at the point labeled // POINT A? In other words, which variables exist at that point in the code? - correct answer sum and count What is printed by the following program? - correct answer hi What is the this keyword? - correct answer The this keyword refers to the current instance of the class.
What is the output of the following code snippet? - correct answer false What is the output of the following code snippet? - correct answer true How do you call the superconstructor from a subclass? - correct answer You call it by making a call with the word super in the subclass constructor. Which of the following is a false statement about the classes? - correct answer Both SciFi and Fantasy inherit constructors from Movie. Say you are trying to create a set of classes that represent tools. You will have a Tool class as well as a Hammer class and Screwdriver class. Hammer and Screwdriver are both subclasses of Tool. Which is the proper first line of each class? - correct answer public class Hammer extends Tool public class Screwdriver extends Tool What is the definition of polymorphism? - correct answer Polymorphism lets a method do different things depending on the type of the object it is called on. What method must a class contain to implement the Comparable interface? - correct answer public int compareTo(T other)