CSC 300 Midterm Review:

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is cyclomatic complexity and how is it calculated?

Cyclomatic complexity in code is a software metric used to indicate the complexity in the program. M = E - N + 2P E = the number of edges of the graph N = the number of nodes of the graph P = represents number of nodes that have exit points

What does inheritance allow you to do in object-oriented programming?

Inheritance enables you to define new classes based upon an existing class, allowing for easier reusability.

Describe refactoring.

Refactoring simply means "improving the design of existing code without changing its observable behavior".

Define encapsulation.

The act of grouping both data and the operations that affect that data into a single class/object is known as encapsulation.

True or False? Method overrides can be less restrictive?

True

True or False? Method overrides cannot have different argument lists?

True

True or False? The following a valid override? void a() { ... } // a() method in superclass public void a() { ... } // a() method in subclass

True

True or False? We can't override the instance variables of a superclass?

True

True or False? When using inheritance we inherit all members of the superclass not designated as private?

True

Polymorphism ________. a. Refers to the ability of two or more objects belonging to different classes to respond to exactly the same message in different class-specific ways b. Simplifies code maintenance c. Does not simplifies code maintenance d. Refers to the ability of two or more objects belonging to different classes to respond to exactly the same message in different class-specific ways and simplifies code maintenance.

a

Which access modifier limits member visibility to the class they reside in? a. private b. protected c. public d. all three

a

Which is an extended class known as? a. superclass b. extension c. subclass d. hierarchial

a

An abstract class in Java usually contains one or more abstract methods. a. constructors b. methods c. variables d. None

b

How do we gain access to the private instance variables of a class? a. Using public methods of the calling class b. Using public methods of the called class c. By their identifier d. We can't

b

How many classes can you extend in a Java class definition? a. 0 b. 1 c. 2 d. as many as you like

b

In which class do we put the extends keyword? a. superclass b. subclass c. hierarchial d. all three

b

What is the output of the below Java program with an abstract class? - abstract class Coffee { Coffee() { System.out.println("Inside Constructor of Coffee.."); } } class ColdCoffee extends Coffee { ColdCoffee() { System.out.println("Inside Constructor of ColdCoffee.."); } } public class AbstractClassTesting { public static void main(String[] args) { ColdCoffee cf = new ColdCoffee(); } } a. compile error b. Inside Constructor of Coffee Inside Constructor of ColdCoffee c. Inside Constructor of ColdCoffee d. Inside Constructor of Coffee

b

When we override a method in a subclass and we invoke that method using an instance of the subclass, what gets called at runtime? a. The superclass method b. The subclass method

b

All Interface methods in Java are public and abstract by default. a. public b. abstract c. public and abstract d. None of the above

c

All Interface variables are public and final by default in Java. a. public b. final c. public and final d. None

c

An abstract class in Java can be created using the keyword abstract. a. final b. interface c. abstract d. static

c

Static variables can be accessed without creating an instance of a class. a. Public b. New c. Static d. private

c

What is garbage collection in java? ________ a. The operating system periodically deletes all of the java files available on the system. b. Any package imported in a program and not used is automatically deleted. c. When all references to an object are gone, the memory used by the object is automatically reclaimed. d. The JVM checks the output of any Java program and deletes anything that doesn't make sense. e. When all references to an object are gone the memory used by the object is not reclaimed.

c

Choose a correct statement about Java Interfaces? All of the above a. Interface contains only abstract methods by default. b. A Java class can implement multiple interfaces c. An Interface can extend or inherit another Interface. d. All the above

d

Choose a correct statement about abstract classes? All of the above a. An abstract class can extend a concrete class b. An abstract class can extend another abstract class c. An abstract class can implement any number of interfaces. d. All the above.

d

How do we achieve a hierarchical connection in Java ? a. Using the extents keyword b. Using the extend keyword c. Using the extent keyword d. Using the extends keyword

d

We can explicitly code super(param list) to access what? a. superclass members b. superclass methods c. superclass variables d. superclass constructors

d

Which access modifiers can we explicitly apply to our members? a. private b. protected c. public d. all three

d

Define aggregation and give a simple example.

Aggregation occurs when a class is a field in another class. Example: Truck and Car may both be classes in DealerInventory.

What is an abstract class? What is its purpose?

An abstract class in java is a class that is never instantiated. And its purpose is to be a parent to several related classes


Set pelajaran terkait

Clin Med III Exam 1: Endocrine, Neuro

View Set

Leadership/Mgmt module questions

View Set

Chapter 26: Growth and Development of the Toddler - ML6

View Set

CH 16 - International Trade and Exchange Rates

View Set

Counseling Licensure Exam Study Guide

View Set

Unit 1 Computer Science practice questions

View Set

W18: Med-Surg EAQ Quiz - Respiratory System

View Set