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'?
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?
How many instance variables are there in the Date class?
How many instance variables are there in the Date class?
Which type of method is the getMonth() method in the Date class?
Which type of method is the getMonth() method in the Date class?
Signup and view all the answers
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?
Signup and view all the answers
What should be returned by the getDay() method in the Date class?
What should be returned by the getDay() method in the Date class?
Signup and view all the answers
What will be the output of the code snippet provided?
What will be the output of the code snippet provided?
Signup and view all the answers
Which of the following expressions will evaluate to false?
Which of the following expressions will evaluate to false?
Signup and view all the answers
Which statement will generate a compilation error?
Which statement will generate a compilation error?
Signup and view all the answers
Which of the following statements will cause a compilation error?
Which of the following statements will cause a compilation error?
Signup and view all the answers
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?
Signup and view all the answers
'InstanceOf' operator in Java is used for:
'InstanceOf' operator in Java is used for:
Signup and view all the answers
What is the output of the program segment in the given text?
What is the output of the program segment in the given text?
Signup and view all the answers
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?
Signup and view all the answers
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?
Signup and view all the answers
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?
Signup and view all the answers
In Practice 7.18, what happens if 'datafile.txt' does not exist?
In Practice 7.18, what happens if 'datafile.txt' does not exist?
Signup and view all the answers
What does 'array = array + array;' in the text do?
What does 'array = array + array;' in the text do?
Signup and view all the answers
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?
Signup and view all the answers
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)))'?
Signup and view all the answers
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?
Signup and view all the answers
What is the significance of 'data.useDelimiter(""")' in the third code segment?
What is the significance of 'data.useDelimiter(""")' in the third code segment?
Signup and view all the answers
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?
Signup and view all the answers
What does 'count++' signify in all three code segments?
What does 'count++' signify in all three code segments?
Signup and view all the answers
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?
Signup and view all the answers
Which method is overridden in the BaseballPlayer class?
Which method is overridden in the BaseballPlayer class?
Signup and view all the answers
How can private superclass variables be accessed in subclass methods in Java?
How can private superclass variables be accessed in subclass methods in Java?
Signup and view all the answers
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?
Signup and view all the answers
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?
Signup and view all the answers
Which statement correctly invokes the superclass constructor from the BaseballPlayer class constructor?
Which statement correctly invokes the superclass constructor from the BaseballPlayer class constructor?
Signup and view all the answers
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?
Signup and view all the answers
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();
?
Signup and view all the answers
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();
?
Signup and view all the answers
What happens when p.display()
is called where Player p = new Player();
?
What happens when p.display()
is called where Player p = new Player();
?
Signup and view all the answers