Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 22 // if the correct answer is a, explain why b is not correct answer.

ID: 3865912 • Letter: Q

Question

Question 22

// if the correct answer is a, explain why b is not correct answer. if the correct answer is b, explain why a is not correct answer. if correct answer is both a and b, give me the explantion

What statement(s) could you use to declare and instantiate an ArrayList object reference of Book objects named library with a default capacity of 10 elements?

ArrayList<Book > library = new ArrayList<Book>();

ArrayList<Book > library;

library = new ArrayList<Book>();

both a and b

neither a or b

Question 27

// if the correct answer is a, explain why b is not correct answer. if the correct answer is b, explain why a is not correct answer. if correct answer is both a and b, give me the explantion

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

QUESTION 29 // Give me the explanation

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

Question 38 // if the correct answer is a, explain why b is not correct answer; if the correct answer is b, explain why a is not correct answer; if correct answer is both a and b, give me the explantion; if d is the correct answer (none of the above) give me the explantation that why is not a and b

For Question 38 consider the following two classes:

     public abstract class C
     {
          private void foo1()
          {
               System.out.println( “Hello foo1” );
          }
          public abstract void foo2();
          public abstract int foo3();
          public void foo1Call()
          {
               foo1();
          }
     }
     public class D extends C
     {
          public void foo2()
          {
               System.out.println( “Hello foo2” );
          }
          public int foo3()
          {
               return 10;
          }
          private void foo4()
          {
               System.out.println( “Hello D foo4()” );
          }
     }

To instantiate an object of class C we could use the following statement(s):

C c2;
c2 = new C();

C c2 = new C();

a or b

none of the above

a.

ArrayList<Book > library = new ArrayList<Book>();

b.

ArrayList<Book > library;

library = new ArrayList<Book>();

c.

both a and b

d.

neither a or b

Question 27

// if the correct answer is a, explain why b is not correct answer. if the correct answer is b, explain why a is not correct answer. if correct answer is both a and b, give me the explantion

Assuming the class B extends class A, then

a.

An object of class B is an object of class A

b.

An object of class A is an object of class B

c.

Both a and b

d.

None of the above

QUESTION 29 // Give me the explanation

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

Question 38 // if the correct answer is a, explain why b is not correct answer; if the correct answer is b, explain why a is not correct answer; if correct answer is both a and b, give me the explantion; if d is the correct answer (none of the above) give me the explantation that why is not a and b

For Question 38 consider the following two classes:

     public abstract class C
     {
          private void foo1()
          {
               System.out.println( “Hello foo1” );
          }
          public abstract void foo2();
          public abstract int foo3();
          public void foo1Call()
          {
               foo1();
          }
     }
     public class D extends C
     {
          public void foo2()
          {
               System.out.println( “Hello foo2” );
          }
          public int foo3()
          {
               return 10;
          }
          private void foo4()
          {
               System.out.println( “Hello D foo4()” );
          }
     }

To instantiate an object of class C we could use the following statement(s):

a.

C c2;
c2 = new C();

b.

C c2 = new C();

c.

a or b

d.

none of the above

Explanation / Answer

Question 22:
What statement(s) could you use to declare and instantiate an ArrayList object reference of Book objects named library with a default capacity of 10 elements?
Answer:both a and b
Explanation: For declaring the arraylist of Book object,we can use the generic way of initializing the arraylist i.e
ArrayList<Book > library = new ArrayList<Book>();
or we can first declare and then intialize i.e:
ArrayList<Book > library;
library = new ArrayList<Book>();

Default size of ArrayList is 10 so no need to define it explicitly.

Question 27:
Assuming the class B extends class A, then
Answer:An object of class B is an object of class A
option b is not correct as this is inheritance so it is a is-a relationship i.e for example if dog extends animal than each object of dog is the object of animal as well but the reverse is not true as object of animal could be cat and cat does not belong to dog class.


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.
Answer:False

Finally block is optional if you want to keep it you can,there is no any rule that you have to define a finally block if there is more than one catch block.


Question 38 :
Answer:none of the above
Explanation:As class C is an abstract class and abstract class cannot be instantiated i.e we cannot create the object of abstract class.


Note:please do ask in case of any doubt,thanks..!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote