Unit 01
Unit 02
Unit 03
Hand Code
Any 01-03
100

Provide three different primitive types.

Primitive Types: byte, short, int, long, float, double, char, boolean


100

The process of instantiating a class is called?

Instantiation

100

Explain the concept of Inheritance.

Inheritance allows a programmer to define a general class, and then later define more specific classes that share or inherit all of the properties of the more general class.

100

Write a method that reads a file and prints the first line.

Define a class that prints "Hello, World!" in the main method.

public class Prompt { public static void main(String[] args){ System.out.println("Hello, World!"); } }

100

Do you need to declare a constructor in order to compile a class? 

No, every class comes with a default constructor. It has no parameters

200
When it comes to JUnit, what annotation is used for the unit test class? What about the test method?

@Testable annotates the unit test class

@Test annotates each test method

200

When declaring the visibility of a method or variable, what are the three main types that are used? Explain who is granted access.

public – grants access to everyone
protected – grants access to this class and
inherited classes
private – grants access to this class only

200

Suppose class A extends class B. How should class A invoke the constructor, access attributes, or call a method from class B.

super();

super.attribute;

super.method();

200

Write a method that will ask the user for their input.

Make sure to follow proper coding procedures.

Scanner scanner = new Scanner(System.it); System.out.print("Enter age: "); int age = scanner.nextInt();

200

How should you go about comparing two objects with different memory addresses?

Overriding and defining an equals method.

300

What is the main difference between primitive and reference types?

The basic difference is that primitive variables store the actual values, whereas reference variables store the addresses of the objects they refer to

300

Explain the difference between checked and unchecked exceptions.

Unchecked Exceptions: You are not explicitly required to handle an unchecked exception in any way

Checked Exceptions: The programmer must handle the exception in some way; otherwise, a compile error will occur.

300

WILD CARD

- 150 Points

300

Define the following as a class diagram (UML).

A pet usually has a name, age, and breed. You can usually get the Pet's attribute and adopt a Pet whenever, which also consists of renaming the Pet.

300

WILD CARD

+ 150 Points

400

Is converting a less complex type (small int) to a more complex type (large int) considered safe?

Yes

400

What is the difference between overloading and overriding?

When two or more methods in the same class have the same name but different parameters, it's called Overloading. 

When the method signature (name and parameters) are the same in the superclass and the child class, it's called Overriding.

400

Suppose we have a Child class that Extends the Parent class. When we instantiate an instance of the child Class, can the variable be a type of the Parent class?


Parent parent1 = new Parent("Anakin"); Child child = new Child("Jon", 19); Parent parent2 = child;

400

Write a method that reads a file and prints the first line.

 Make sure to follow proper coding procedures.

FileReader fileReader = new FileReader("file.txt"); BufferedReader reader = new BufferedReader(fileReader); String line = reader.readLine(); reader.close(); fileReader.close();

400

What are some constraints of utilizing abstract classes and interfaces?

You can only extend one abstract class and implement many interfaces. 


500

When it comes to reading a file, we utilize the java.io.FileReader class and java.io.BufferedReader class. Explain the significance of the BufferedReader.

The java.io.FileReader is a little hard to use because it only supports reading characters (one at a time or in chunks). The  java.io.BufferedReader provides a readLine() method that reads up to the next newline from the file.

500

Explain the concept/idea of encapsulation.

Encapsulation is the idea of locating
information and actions related to an object in
one place.

500

What makes an abstract class different from an interface?

An abstract class allows you to create functionality that subclasses can implement or override.

An interface only allows you to define functionality, not implement it.

500

Define the following as a class diagram (UML).

A class diagram that utilizes inheritance through abstraction or interfaces.

500

Throughout the semester, we utilized the keyword static multiple times. Define static and provide a side effect/outcome of utilizing it.

Static indicates to Java that only one instance of this item will ever exist and that it belongs to the class.

You can access it using class.staticMember instead of object.member (which means you need to initialize an instance of a class first before calling the method)