• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 18 pages
Exam (elaborations)

CP 213 - Java Object Oriented Programming Questions and Answers Already Passed Latest Update

Document preview thumbnail
Preview 3 out of 18 pages

CP 213 - Java Object Oriented Programming Questions and Answers Already Passed Latest Update What are the 3 ways to use square brackets with an array name? - Answers 1. Used to create an array type variable 2. Used with an integer value to create a new array 3. Used to name an indexed variable What happens when an array index is out of bounds? - Answers Your program will end with a run time error message What are the 3 ways of initializing an array? - Answers 1. In enclosed braces 2. Individual initialization of each indexed variable 3. Using a for loop What happens if you do not initialize the elements in an array? - Answers They will be automatically initialized to default values for the base type What are the default values for: 1. Numeric Types 2. Char types 3. Boolean types 4. Class types - Answers 1. The primitive value of 0 of their type 2. (char)0 3. False 4. Null What is a vararg specification? - Answers It specifies that the method can accept any number of arguments ex. type...Array_Name must be the last item on the parameter list What is an enumerated type - Answers A simple type consisting of a short list of named values What is a ragged array? - Answers An array with different rows that have different columns What are the 3 different uses for the keyword final? - Answers 1. Used to turn off late binding 2. Used to prevent inheritance and having derived classes 3. Used to prevent any changes to methods or variables When an exception is thrown inside a method using the throw statement, but not caught, what exactly needs to be done with the method definition in order for it to be syntactically correct? - Answers Include a throws clause What is the difference between overloading and overriding a method name? - Answers Overloading - methods that have the same name but different number of parameters or different parameter locations

Content preview

CP 213 - Java Object Oriented Programming Questions and Answers Already Passed Latest
Update 2025-2026

What are the 3 ways to use square brackets with an array name? - Answers 1. Used to create an
array type variable

2. Used with an integer value to create a new array

3. Used to name an indexed variable

What happens when an array index is out of bounds? - Answers Your program will end with a
run time error message

What are the 3 ways of initializing an array? - Answers 1. In enclosed braces

2. Individual initialization of each indexed variable

3. Using a for loop

What happens if you do not initialize the elements in an array? - Answers They will be
automatically initialized to default values for the base type

What are the default values for:

1. Numeric Types

2. Char types

3. Boolean types

4. Class types - Answers 1. The primitive value of 0 of their type

2. (char)0

3. False

4. Null

What is a vararg specification? - Answers It specifies that the method can accept any number of
arguments



ex. type...Array_Name



must be the last item on the parameter list

,What is an enumerated type - Answers A simple type consisting of a short list of named values

What is a ragged array? - Answers An array with different rows that have different columns

What are the 3 different uses for the keyword final? - Answers 1. Used to turn off late binding

2. Used to prevent inheritance and having derived classes

3. Used to prevent any changes to methods or variables

When an exception is thrown inside a method using the throw statement, but not caught, what
exactly needs to be done with the method definition in order for it to be syntactically correct? -
Answers Include a throws clause

What is the difference between overloading and overriding a method name? - Answers
Overloading - methods that have the same name but different number of parameters or
different parameter locations



Overriding - changing the meaning of the method in a derived class compared to the definition
in the base class

Can an interface ever contain method bodies? - Answers No

Is it okay if a class definition implements two interfaces, each of which have the same definition
for the constant pi - Answers No - if a class implements several interfaces, each constant must
be defined in only one interface

What is the difference between the comparable and comparator classes? - Answers
Implementing the comparable interface on a class defines the default sort order for objects of
that class; implementing the comparator interface on a class allows you to create an alternative
sort order for that class

What does the validate method do? - Answers It guarantees the visual representation of a
content pane is up to date

What is the rule for changing the access permission of an overridden method? - Answers They
can only be changed to be more accessible

What is a covariant return type? - Answers Changing the return type of a method to a
descendent type

Can you change the return type of a method when overriding? - Answers No, only if you are
changing the return type to a descendent type

What does the super constructor do? - Answers It allows you to invoke a constructor of the base

, class from within a derived class

What are the 4 restrictions of using the super constructor? - Answers 1. You cannot use an
instance variable as an argument

2. Must be the first action taken in a constructor definition

3. Cannot use the name of the constructor

4. If a constructor definition of a derived class does not include an invocation of a constructor
for the base class, then the no-argument constructor of the base class is invoked automatically
as the first action of the derived class constructor

Can inherited private instance variables be mentioned by name in a derived class? - Answers No.
You must use public accessor or mutator methods defined in the base class

Can inherited private methods be accessed in the derived class? - Answers No. They cannot be
accessed indirectly with other methods. They may be indirectly available if the method is used
in the definition of a public method of the base class

What are the two classifications of instance variables and methods that allow them to be
accessed by name in a derived class? - Answers 1. Protected access (always gives access)

2. Package access (gives access if the derived class is in the same package as the base class)

Where can a protected method/instance variable be accessed from by name? (3) - Answers 1.
Its own class

2. Any class derived from it

3. Any class in the same package

Why is the protected classification considered weaker than the package access classification? -
Answers It allows direct access to any programmer willing to go through the bother of defining
a suitable derived class

When is it best to use package access classification? - Answers When you have a package of
cooperating classes that act as a single encapsulated unit

What is the default package? How does this relate to access classifications? - Answers It is the
unnamed package of a class that does not belong to another package



Will have package access to any of the classes that are not in a defined class

Can a derived class object access variables and methods of a protected base class object? -
Answers No, it can only use instance variables and methods for the object of its own class

Document information

Uploaded on
September 25, 2025
Number of pages
18
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$10.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
TutorJosh
3.5
(82)
Sold
520
Followers
17
Items
33619
Last sold
3 days ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions