Podcast
Questions and Answers
In the Date class, which method should be used to change the value of the instance variable 'day'?
In the Date class, which method should be used to change the value of the instance variable 'day'?
- setDay() (correct)
- changeDay()
- updateDay()
- getDay()
For object 'birthday' of the Date class, what is the correct way to retrieve the month using an accessor method?
For object 'birthday' of the Date class, what is the correct way to retrieve the month using an accessor method?
- int month = birthday.getMonthValue();
- int theMonth = birthday.setMonth();
- int month = birthday.retrieveMonth();
- int theMonth = birthday.getMonth(); (correct)
How many instance variables are there in the Date class?
How many instance variables are there in the Date class?
- 4
- 2
- 3 (correct)
- 1
Which type of method is the getMonth() method in the Date class?
Which type of method is the getMonth() method in the Date class?
To complete the setDay() method in the Date class, what parameter should be passed?
To complete the setDay() method in the Date class, what parameter should be passed?
What should be returned by the getDay() method in the Date class?
What should be returned by the getDay() method in the Date class?
What will be the output of the code snippet provided?
What will be the output of the code snippet provided?
Which of the following expressions will evaluate to false?
Which of the following expressions will evaluate to false?
Which statement will generate a compilation error?
Which statement will generate a compilation error?
Which of the following statements will cause a compilation error?
Which of the following statements will cause a compilation error?
Given the declaration Resizable circle = new Circle(5.5);, which of the following statements will compile successfully?
Given the declaration Resizable circle = new Circle(5.5);, which of the following statements will compile successfully?
'InstanceOf' operator in Java is used for:
'InstanceOf' operator in Java is used for:
What is the output of the program segment in the given text?
What is the output of the program segment in the given text?
What should be inserted in the missing statement in method openFile() to prompt the user for a valid file name?
What should be inserted in the missing statement in method openFile() to prompt the user for a valid file name?
Which exception is caught by the catch block in Practice 7.19 if an IOException occurs?
Which exception is caught by the catch block in Practice 7.19 if an IOException occurs?
What happens if the file in Practice 7.20 contains only two integer values instead of three?
What happens if the file in Practice 7.20 contains only two integer values instead of three?
In Practice 7.18, what happens if 'datafile.txt' does not exist?
In Practice 7.18, what happens if 'datafile.txt' does not exist?
What does 'array = array + array;' in the text do?
What does 'array = array + array;' in the text do?
What will be the output of the code segment processing input one character at a time using a Scanner object?
What will be the output of the code segment processing input one character at a time using a Scanner object?
In the second code segment processing an input file one line at a time, what is the purpose of the condition 'if (Character.isDigit(input.charAt(0)))'?
In the second code segment processing an input file one line at a time, what is the purpose of the condition 'if (Character.isDigit(input.charAt(0)))'?
If the delimiter used in the third code segment breaks the string 'apple,orange,banana' into three tokens, what would be the value of 'count' printed at the end?
If the delimiter used in the third code segment breaks the string 'apple,orange,banana' into three tokens, what would be the value of 'count' printed at the end?
What is the significance of 'data.useDelimiter(""")' in the third code segment?
What is the significance of 'data.useDelimiter(""")' in the third code segment?
If 'data.hasNextLine()' returns false in the second code segment, what can be inferred?
If 'data.hasNextLine()' returns false in the second code segment, what can be inferred?
What does 'count++' signify in all three code segments?
What does 'count++' signify in all three code segments?
Which method call is illegal using a reference variable of the BaseballPlayer class?
Which method call is illegal using a reference variable of the BaseballPlayer class?
Which method is overridden in the BaseballPlayer class?
Which method is overridden in the BaseballPlayer class?
How can private superclass variables be accessed in subclass methods in Java?
How can private superclass variables be accessed in subclass methods in Java?
How can you call an overridden superclass method within a subclass method in Java?
How can you call an overridden superclass method within a subclass method in Java?
What statement completes the display() method in the BaseballPlayer class to include superclass properties?
What statement completes the display() method in the BaseballPlayer class to include superclass properties?
Which statement correctly invokes the superclass constructor from the BaseballPlayer class constructor?
Which statement correctly invokes the superclass constructor from the BaseballPlayer class constructor?
Consider class Soccer as a subclass of Sport. Which assignment of objects is invalid?
Consider class Soccer as a subclass of Sport. Which assignment of objects is invalid?
What will be printed when this statement is executed within a Java code segment: BaseballPlayer bp = new BaseballPlayer(); bp.display();
?
What will be printed when this statement is executed within a Java code segment: BaseballPlayer bp = new BaseballPlayer(); bp.display();
?
What will be printed when this Java code segment is executed: Player p = new BaseballPlayer(); p.display();
?
What will be printed when this Java code segment is executed: Player p = new BaseballPlayer(); p.display();
?
What happens when p.display()
is called where Player p = new Player();
?
What happens when p.display()
is called where Player p = new Player();
?
Flashcards are hidden until you start studying