Answer the Questions(Multiple Choice ): Question 26 Public Constructor methods A
ID: 3860739 • Letter: A
Question
Answer the Questions(Multiple Choice):
Question 26
Public Constructor methods
Are inherited by but cannot be accessed by a subclass
Are inherited by and can be accessed with the super keyword by a subclass
Are accessible with the super keyword by a subclass but are not inherited
Are not inherited by and cannot be accessed by a subclass
2.5 points
Question 27
Assuming the class B extends class A, then
An object of class B is an object of class A
An object of class A is an object of class B
Both a and b
None of the above
2.5 points
Question 28
What is the output of this code sequence?
Scanner parse = new Scanner("AA%:BB:CC");
parse.useDelimiter(":");
while(parse.hasNext())
{
System.out.print(parse.next() + " ");
System.out.println();
}
AA%
:BB
:CC
AA% BB CC
AA%
BB
CC
None of the above
2.5 points
Question 29
It is legal to have more than one catch block to match a try block but you must have a finally block if there is more than one catch block.
True
False
2.5 points
Question 30
Assuming file data.txt exists and is successfully opened and contains the following text
CS1
What does the file data.txt contain after this code sequence is executed?
try
{
FileOutputStream fos = new FileOutputStream("data.txt ", false );
PrintWriter pw = new PrintWriter( fos );
pw.println( “Java Illuminated”);
pw.close( );
}
catch( IOException ioe )
{
ioe.printStackTrace( );
}
Java Illuminated
CS1Java Illuminated
CS1
Java Illuminated
Java Illuminated
CS1
Are inherited by but cannot be accessed by a subclass
b.Are inherited by and can be accessed with the super keyword by a subclass
c.Are accessible with the super keyword by a subclass but are not inherited
d.Are not inherited by and cannot be accessed by a subclass
Explanation / Answer
Question 26
Option C: Are accessible with the super keyword by a subclass but are not inherited
Because Constructors are not inherited it is accessible with super keyword.
Question 27
Option B: An object of class A is an object of class B
Question 28: Option B
AA% BB CC
Question 29
True:
Question 30: Option c
CS1
Java Illuminated