Question 1

Explain what is meant by primitive, and explain the difference between primitive and reference variables?

Question 2

in the java collections framework, state the main difference between a linkedList and an arrayList.Also give the name of the interface that these two classes implement.

Question 3

What is the class which each other class in ultimately a descendant(subclass) of? Name two of its methods and their purpose.

Question 4

What does it mean to catch and exception? Explain the circumstance where this might be needed.

Question 5

explain why we might need to provide our own implementation of the toString method when writing a class and what might happen if we didnt

Question 6

Explain what is meant by the term Cohesion in relation to each of these

  • Method
  • Class

you may like to make use of a class named Student to help explain your answer.(Assume this class defines a range of attributes, including :name , ID number, Degree, campus, email address.)

Question 7

When writing a subclass of existing class,depending on the visibility specification of methods and attributes of the existing original class,the subclass may or may not be able to access or use the members of the original class.

  • if an attribute is public in the superclass, can the subclass modify its value modify its value by a direct assignment statement?
  • if an attribute is private in the superclass, van the subclass modify its value by a direct assignment statement?
  • For the cases where a direct assignment statement in the subclass is not possible, what could we do to achieve a change to the value of the attribute that is in the superclass?

Question 8

the various type of exception(Checked or unchecked.

  • what type of exception (Checked or unchecked) is IOException(which is from the java.io package)
  • what type of exception(checked or unchecked)is
  • If you are designing your own type of exception, and want it to be a checked exception, which class should your custom exception class extend from?

Question 9

Explain why we might need to use a Wrapper class. Describe an example of where you might use a wrapper class.

We use a wrapper class to further simplify the process of using the class being wrapped. For example, we have System.in class which is to stream inputs from the keyboard. If we want to read a string, there is no such method in the System.in to do it so we have to build our own way of reading string using the System.in. However, to make it easier we can just wrap it with a Scanner class the use the methods in the scanner class to read strings, integers, decimals, and so on. The scanner class will take care of how things will get done.

Question 10

When dealing with files, we can open a filein append mode.What does this mean in each of the following two cases?

  • if the file did not exist when we open it for append mode
  • if the file already existed when we open it for append mode

Question 11

what is the meaning of the following keywords

  • instanceof
  • implements
  • package
  • this

Question 12

  • whatis meant by privacy leakagewith regards to a class in an object-Oriented program?In other Words, When or how does it occur?
  • why is privacy leakage a potential problem?
  • List two(2) ways which help you avoid privacy leaks

Question 13

Java provides a mechanism called exception Handling.

  • How does this inclusion of this mechanism in java make a program better than if this mechanism was not available?
  • Give an example of a specific situation that might cause an Exception when a program is running.
  • What happens at run-time, if the code has been written without considering the possibility of the exception occurring, but that exception actually occurs?

Question 14

If we want to have an ArrayList of integer numbers(e.g monthly rainfall totals, what is the way that we declare a suitable variable to refer this list, and what is the way to create the new empty list,ensuring that only integers will be able to be added to the list later on?

Question 15

What is an abstract data type? Provide a reason why you might choose to use this?

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.