Skip to content Skip to navigation Skip to collection information

OpenStax_CNX

You are here: Home » Content » Object-Oriented Programming (OOP) with Java » Ap0080: Self-assessment, Classes, Constructors, and Accessor Methods

Navigation

Table of Contents

Recently Viewed

This feature requires Javascript to be enabled.
Download
x

Download collection as:

  • EPUB (what's this?)

    What is an EPUB file?

    EPUB is an electronic book format that can be read on a variety of mobile devices.

    Downloading to a reading device

    For detailed instructions on how to download this content's EPUB to your specific device, click the "(what's this?)" link.

  • More downloads ...

Download module as:

  • PDF
  • EPUB (what's this?)

    What is an EPUB file?

    EPUB is an electronic book format that can be read on a variety of mobile devices.

    Downloading to a reading device

    For detailed instructions on how to download this content's EPUB to your specific device, click the "(what's this?)" link.

  • More downloads ...
Reuse / Edit
x

Collection:

Module:

Add to a lens
x

Add collection to:

Add module to:

Add to Favorites
x

Add collection to:

Add module to:

 

Ap0080: Self-assessment, Classes, Constructors, and Accessor Methods

Module by: R.G. (Dick) Baldwin. E-mail the author

Summary: Part of a self-assessment test designed to help you determine how much you know about classes, constructors, and accessor methods in Java.

Preface

This module is part of a self-assessment test designed to help you determine how much you know about object-oriented programming using Java.

The test consists of a series of questions with answers and explanations of the answers.

The questions and the answers are connected by hyperlinks to make it easy for you to navigate from the question to the answer and back.

I recommend that you open another copy of this document in a separate browser window and use the links to under Listings to easily find and view the listings while you are reading about them.

Questions

Question 1 .

What output is produced by the program shown in Listing 1 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. An Object
  • D. None of the above
1
Listing 1: Listing for Question 1.
public class Ap090{
  public static void main(
                        String args[]){
    new Worker().makeObj();
  }//end main()
}//end class definition

class Worker{
  public void makeObj(){
    NewClass obj = NewClass();
    System.out.println(obj);

  }//end makeObj()


}// end class 

class NewClass{
  public String toString(){
    return "An Object";
  }//end toString()
}//end NewClass

Answer and Explanation

Question 2

What output is produced by the program shown in Listing 2 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. An Object
  • D. None of the above
2
Listing 2: Listing for Question 2.
public class Ap091{
  public static void main(
                        String args[]){
    new Worker().makeObj();
  }//end main()
}//end class definition

class Worker{
  public void makeObj(){
    NewClass obj = new NewClass();
    System.out.println(obj);

  }//end makeObj()

}// end class 

Class NewClass{
  public String toString(){
    return "An Object";
  }//end toString()
}//end NewClass

Answer and Explanation

Question 3

What output is produced by the program shown in Listing 3 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. An Object
  • D. None of the above
3
Listing 3: Listing for Question 3.
public class Ap092{
  public static void main(
                        String args[]){
    new Worker().makeObj();
  }//end main()
}//end class definition

class Worker{
  public void makeObj(){
    NewClass obj = new NewClass();
    System.out.println(obj);

  }//end makeObj()

}// end class 

class NewClass{
  public String toString(){
    return "An Object";
  }//end toString()
}//end NewClass

Answer and Explanation

Question 4

What output is produced by the program shown in Listing 4 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. Object containing 2
  • D. None of the above
4
Listing 4: Listing for Question 4.
public class Ap093{
  public static void main(
                        String args[]){
    new Worker().makeObj();
  }//end main()
}//end class definition

class Worker{
  public void makeObj(){
    NewClass obj = new NewClass();
    System.out.println(obj);
  }//end makeObj()
}// end class 

class NewClass{
  private int x = 2;
  
  public NewClass(int x){
    this.x = x;
  }//end constructor
  
  public String toString(){
    return "Object containing " + x;
  }//end toString()
}//end NewClass

Answer and Explanation

Question 5

What output is produced by the program shown in Listing 5 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. Object containing 2
  • D. None of the above
5
Listing 5: Listing for Question 5.
public class Ap094{
  public static void main(
                        String args[]){
    new Worker().makeObj();
  }//end main()
}//end class definition

class Worker{
  public void makeObj(){
    Subclass obj = new Subclass();
    System.out.println(obj);
  }//end makeObj()
}// end class 

class Superclass{
  private int x;
  
  public Superclass(int x){
    this.x = x;
  }//end constructor
  
  public String toString(){
    return "Object containing " + x;
  }//end toString()
    
  public void setX(int x){
    this.x = x;
  }//end setX()
}//end Superclass

class Subclass extends Superclass{
  public Subclass(){
    setX(2);
  }//end noarg constructor
}//end Subclass

Answer and Explanation

Question 6

What output is produced by the program shown in Listing 6 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. Object containing 5
  • D. Object containing 2
  • E. None of the above
6
Listing 6: Listing for Question 6.
public class Ap095{
  public static void main(
                        String args[]){
    new Worker().makeObj();
  }//end main()
}//end class definition

class Worker{
  public void makeObj(){
    NewClass obj = new NewClass(5);
    System.out.println(obj);
  }//end makeObj()
}// end class 

class NewClass{
  private int x = 2;
  
  public NewClass(){
  }//end constructor
  
  public NewClass(int x){
    this.x = x;
  }//end constructor
  
  public String toString(){
    return "Object containing " + x;
  }//end toString()
}//end NewClass

Answer and Explanation

Question 7

What output is produced by the program shown in Listing 7 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. Object containing 0, 0.0, false
  • D. Object containing 0.0, 0, true
  • E. None of the above
7
Listing 7: Listing for Question 7.
public class Ap096{
  public static void main(
                        String args[]){
    new Worker().makeObj();
  }//end main()
}//end class definition

class Worker{
  public void makeObj(){
    NewClass obj = new NewClass();
    System.out.println(obj);
  }//end makeObj()
}// end class 

class NewClass{
  private int x;
  private double y;
  private boolean z;
  
  public String toString(){
    return "Object containing " + 
                          x + ", " + 
                          y + ", " + z;
  }//end toString()
}//end NewClass

Answer and Explanation

Question 8

What output is produced by the program shown in Listing 8 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. 2
  • D. 5
  • E. None of the above
8
Listing 8: Listing for Question 8.
public class Ap097{
  public static void main(
                        String args[]){
    new Worker().makeObj();
  }//end main()
}//end class definition

class Worker{
  public void makeObj(){
    NewClass obj = new NewClass(5);
    System.out.println(obj.getX());
  }//end makeObj()
}// end class 

class NewClass{
  private int x = 2;
    
  public NewClass(){
  }//end constructor
  
  public NewClass(int x){
    this.x = x;
  }//end constructor

  public int getX(){
    return x;
  }//end getX()
}//end NewClass

Answer and Explanation

Question 9

What output is produced by the program shown in Listing 9 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. 10
  • D. None of the above
9
Listing 9: Listing for Question 9.
public class Ap098{
  public static void main(
                        String args[]){
    new Worker().makeObj();
  }//end main()
}//end class definition

class Worker{
  public void makeObj(){

    NewClass obj = new NewClass();
    obj.setX(10);
    System.out.println(obj.getX());
    
  }//end makeObj()
}// end class 

class NewClass{
  private int y;
 
  public void setX(int y){
    this.y = y;
  }//end setX()

  public int getX(){
    return y;
  }//end getX()
}//end NewClass

Answer and Explanation

Question 10

What output is produced by the program shown in Listing 10 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. 2
  • D. 5
  • E. 10
  • F. None of the above
10
Listing 10: Listing for Question 10.
public class Ap099{
  public static void main(
                        String args[]){
    new Worker().makeObj();
  }//end main()
}//end class definition

class Worker{
  public void makeObj(){
    NewClass obj = new NewClass(5);
    obj.x = 10;
    System.out.println(obj.x);
  }//end makeObj()
}// end class 

class NewClass{
  private int x = 2;
    
  public NewClass(){
  }//end constructor
  
  public NewClass(int x){
    this.x = x;
  }//end constructor
  
  public void setX(int x){
    this.x = x;
  }//end setX()

  public int getX(){
    return x;
  }//end getX()
}//end NewClass

Answer and Explanation

Listings

I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the listings while you are reading about them.

Miscellaneous

This section contains a variety of miscellaneous information.

Note:

Housekeeping material
  • Module name: Ap0080: Self-assessment, Classes, Constructors, and Accessor Methods
  • File: Ap0080.htm
  • Originally published: 2002
  • Published at cnx.org: 12/05/12
  • Revised: 01/02/13

Note:

Disclaimers:

Financial : Although the Connexions site makes it possible for you to download a PDF file for this module at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should be aware that some of the HTML elements in this module may not translate well into PDF.

I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.

In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. I neither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please be aware that it is a copy of a module that is freely available on cnx.org and that it was made and published without my prior knowledge.

Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.

Answers

Answer 10

A. Compiler Error

Explanation 10

Variables declared private really are private

The code in the following fragment attempts to ignore the setter and getter methods and directly access the private instance variable named x in the object referred to by the reference variable named obj .

Note:
    obj.x = 10;
    System.out.println(obj.x);

This produces a compiler error. The compiler error produced by JDK 1.3 is reproduced below.

Note:
Ap099.java:19: x has private access in
NewClass
    obj.x = 10;
       ^
Ap099.java:20: x has private access in
NewClass
    System.out.println(obj.x);
                          ^

Back to Question 10

Answer 9

C. 10

Explanation 9

A setter and a getter

This is a very simple program that uses a setter (modifier or mutator) method named setX to set the value 10 in a property named x that is stored in an instance variable named y in an object instantiated from the class named NewClass ..

The program also uses a getter (accessor) method named getX to get and display the value of the property named x . (Note that according to JavaBeans design patterns, the name of the property is unrelated to the name of variable in which the property value is stored.)

Back to Question 9

Answer 8

D. 5

Explanation 8

Hide your data and expose your methods

For reasons that I won't go into here, good object-oriented design principles state that in almost all cases where an instance variable is not declared to be final , it should be declared private . (A final variable behaves like a constant.)

What is private access?

When an instance variable is declared private , it is accessible only by methods of the class in which it is defined. Therefore, the only way that the "outside world" can gain access to a private instance variable is by going through an (usually public ) instance method of the object.

Accessor, modifier, mutator, setter, and getter methods

Historically, methods that have been defined for the purpose of exposing private instance variables to the outside world have been referred to as accessor and modifier methods. (Modifier methods are also sometimes called mutator methods.)

(Note that since the advent of Sun's JavaBeans Component design patterns, these methods have also come to be known as getter methods and setter methods in deference to the design-pattern naming conventions for the methods.)

A private instance variable with an initializer

The class named NewClass declares a private instance variable named x and initializes its value to 2, as shown in the following code fragment:

Note:
  private int x = 2;

Two constructors

The class contains both a noarg constructor and a parameterized constructor as shown in the following fragment:

Note:
  public NewClass(){
  }//end constructor
  
  public NewClass(int x){
    this.x = x;
  }//end constructor

Calling the noarg constructor

If an object of the class is instantiated by calling the noarg constructor, the initial value of 2 remains intact, and that object contains an instance variable with an initial value of 2.

Calling the parameterized constructor

If an object of the class is instantiated by calling the parameterized constructor, the initial value of 2 is overwritten by the value of the incoming parameter to the parameterized constructor. In this case, that value is 5, because the object is instantiated by the following code fragment that passes the literal value 5 to the parameterized constructor. Thus, the initial value of the instance variable in that object is 5.

Note:
    NewClass obj = new NewClass(5);

A getter method

Because the instance variable named x is private , it cannot be accessed directly for display by the code in the makeObj method of the Worker class. However, the NewClass class provides the following public getter or accessor method that can be used to get the value stored in the instance variable.

(The name of this method complies with JavaBeans design patterns. If you examine the name carefully, you will see why Java programmers often refer to methods like this as getter methods.)

Note:
  public int getX(){
    return x;
  }//end getX()

Calling the getter method

Finally, the second statement in the following code fragment calls the getter method on the NewClass object to get and display the value of the instance variable named x .

Note:
    NewClass obj = new NewClass(5);
    System.out.println(obj.getX());

Back to Question 8

Answer 7

C. Object containing 0, 0.0, false

Explanation 7

Default initialization values

The purpose of this question is to confirm that you understand the default initialization of instance variables in an object when you don't write code to cause the initialization of the instance variable to differ from the default.

By default, all instance variables in a new object are initialized with default values if you don't provide a constructor (or other mechanism) that causes them to be initialized differently from the default.

  • All instance variables of the numeric types are initialized to the value of zero for the type. This program illustrates default initialization to zero for int and double types.
  • Instance variables of type boolean are initialized to false.
  • Instance variables of type char are initialized to a 16-bit Unicode character for which all sixteen bits have been set to zero. I didn't include initialization of the char type in the output of this program because the default char value is not printable.
  • Instance variables of reference types are initialized to null.

Back to Question 7

Answer 6

C. Object containing 5

Explanation 6

A parameterized constructor

This program illustrates the straightforward use of a parameterized constructor.

The class named NewClass defines a parameterized constructor that requires an incoming parameter of type int .

(For good design practice, the class also defines a noarg constructor, even though it isn't actually used in this program. This makes it available if needed later when someone extends the class.)

Both constructors are shown in the following code fragment.

Note:
  public NewClass(){
  }//end constructor

  public NewClass(int x){
    this.x = x;
  }//end constructor

The parameterized constructor stores its incoming parameter named x in an instance variable of the class, also named x .

(The use of the keyword this is required in this case to eliminate the ambiguity of having a local parameter with the same name as an instance variable. This is very common Java programming style that you should recognize and understand.)

Call the parameterized constructor

The following code fragment calls the parameterized constructor, passing the literal int value of 5 as a parameter.

Note:
    NewClass obj = new NewClass(5);

Hopefully you will have no difficulty understanding the remaining code in the program that causes the value stored in the instance variable named x to be displayed on the computer screen.

Back to Question 6

Answer 5

A. Compiler Error

Explanation 5

If you define any constructors, ...

The discussion for Question 4 explained that if you define any constructor in a new class, you must define all constructors that will ever be needed for that class. When you define one or more constructors, the default noarg constructor is no longer provided by the system on your behalf.

Question 4 illustrated a simple manifestation of a problem arising from the failure to define a noarg constructor that would be needed later. The reason that it was needed later was that the programmer attempted to explicitly use the non-existent noarg constructor to create an instance of the class.

A more subtle problem

The problem in this program is more subtle. Unless you (or the programmer of the superclasses) specifically write code to cause the system to behave otherwise, each time you instantiate an object of a class, the system automatically calls the noarg constructor on superclasses of that class up to and including the class named Object . If one or more of those superclasses don't have a noarg constructor, unless the author of the subclass constructor has taken this into account, the program will fail to compile.

Calling a non-existing noarg constructor

This program attempts to instantiate an object of a class named Subclass , which extends a class named Superclass . By default, when attempting to instantiate the object, the system will attempt to call a noarg constructor defined in Superclass .

Superclass has no noarg constructor

The Superclass class defines a parameterized constructor that requires a single incoming parameter of type int . However, it does not also define a noarg constructor. Because the parameterized constructor is defined, the default noarg constructor does not exist. As a result, JDK 1.3 produces the following compiler error:

Note:
Ap094.java:40: cannot resolve symbol

symbol  : constructor Superclass  ()
location: class Superclass
  public Subclass(){

Back to Question 5

Answer 4

A. Compiler Error

Explanation 4

Constructors

Java uses the following kinds of constructors:

  • Those that take arguments, often referred to as parameterized constructors , which typically perform initialization on the new object using parameter values.
  • Those that don't take arguments, often referred to as default or noarg constructors, which perform default initialization on the new object.
  • Those that don't take arguments but perform initialization on the new object in ways that differ from the default initialization.

Constructor definition is optional

You are not required to define a constructor when you define a new class. If you don't define a constructor for your new class, a default constructor will be provided on your behalf. This constructor requires no argument, and it is typically used in conjunction with the new operator to create an instance of the class using statements such as the following:

Note:
    NewClass obj = new NewClass();

The default constructor

The default constructor typically does the following:

  • Calls the noarg constructor of the superclass
  • Assists in the process of allocating and organizing memory for the new object
  • Initializes all instance variables of the new object with the following four default values:
    • numeric = 0,
    • boolean = false,
    • char = all zero bits
    • reference = null

Are you satisfied with default values?

As long as you are satisfied with the default initialization of all instance variables belonging to the object, there is no need for you to define a constructor of your own.

However, in the event that you have initialization needs that are not satisfied by the default constructor, you can define your own constructor. Your new constructor may or may not require arguments. (In case you have forgotten, the name of the constructor is always the same of the name of the class in which it is defined.)

A non-default noarg constructor

If your new constructor doesn't require arguments, you may need to write code that performs initialization in ways that differ from the default initialization. For example, you might decide that a particular double instance variable needs to be initialized with a random number each time a new object is instantiated. You could do that with a constructor of your own design that doesn't take arguments by defining the constructor to get initialization values from an object of the Random class.

A parameterized constructor

If your new constructor does take arguments, (a parameterized constructor) you can define as many overloaded versions as you need. Each overloaded version must have a formal argument list that differs from the formal argument list of all of the other overloaded constructors for that class.

(The rules governing the argument list for overloaded constructors are similar to the rules governing the argument list for overloaded methods, which were discussed in a previous module.)

Use parameter values for initialization

In this case, you will typically define your parameterized constructors to initialize some or all of the instance variables of the new object using values passed to the constructor as parameters.

What else can a constructor do?

You can also cause your new constructor to do other things if you so choose. For example, if you know how to do so, you could cause your constructor (with or without parameters) to play an audio clip each time a new object is instantiated. You could use a parameter to determine which audio clip to play in each particular instance.

The punch line

So far, everything that I have said is background information for this program. Here is the punch line insofar as this program is concerned.

If you define any constructor in your new class, you must define all constructors that your new class will ever need.

If you define any constructor, the default constructor is no longer provided on your behalf. If your new class needs a noarg constructor (and it probably does, but that may not become apparent until later when you or someone else extends your class) you must define the noarg version in addition to the other overloaded versions that you define.

A violation of the rule

This program violated the rule given above. It defined the parameterized constructor for the class named NewClass shown below

Note:
  public NewClass(int x){
    this.x = x;
  }//end constructor

However, the program did not also define a noarg constructor for the NewClass class.

Calling the noarg constructor

The code in the makeObj method of the Worker class attempted to instantiate a new object using the following code:

Note:
    NewClass obj = new NewClass();

Since the class definition didn't contain a definition for a noarg constructor, the following compiler error was produced by JDK 1.3.

Note:
Ap093.java:18: cannot resolve symbol
symbol  : constructor NewClass 
()
location: class NewClass
    NewClass obj = new NewClass();

Back to Question 4

Answer 3

C. An Object

Explanation 3

We finally got it right!

Did you identify the errors in the previous two programs before looking at the answers?

This program declares the class named NewClass correctly and uses the new operator correctly in conjunction with the default noarg constructor for the NewClass class to create a new instance of the class (an object) .

Making the class public

One of the things that I could do differently would be to make the declaration for the NewClass class public (as shown in the following code fragment) .

Note:
public class NewClass{
  public String toString(){
    return "An Object";
  }//end toString()
}//end NewClass

I am a little lazy

The reason that I didn't declare this class public (and haven't done so throughout this series of modules) is because the source code for all public classes and interfaces must be in separate files. While that is probably a good requirement for large programming projects, it is overkill for simple little programs like I am presenting in this group of self-assessment modules.

Dealing with multiple files

Therefore, in order to avoid the hassle of having to deal with multiple source code files for every program, I have been using package-private access for class definitions other than the controlling class (the controlling class is declared public) . Although I won't get into the details at this point, when a class is not declared public, it is common to say that it has package-private access instead of public access.

Back to Question 3

Answer 2

A. Compiler Error

Explanation 2

Java is a case-sensitive language

Java keywords must be written exactly as specified. The keyword class cannot be written as Class , which is the problem with this program.

The inappropriate use of the upper-case C in the word Class caused the following compiler error.

Note:
Ap091.java:25: 'class' or 'interface' expected
Class NewClass{

The solution to the problem

This problem can be resolved by causing the first character in the keyword class to be a lower-case character as shown in the following code fragment.

Note:
class NewClass{
  public String toString(){
    return "An Object";
  }//end toString()
}//end NewClass

Back to Question 2

Answer 1

A. Compiler Error

Explanation 1

Instantiating an object

There are several ways to instantiate an object in Java:

  • Use the newInstance method of the class named Class .
  • Reconstruct a serialized object using an I/O readObject method.
  • Create an initialized array object such as {1,2,3}.
  • Create a String object from a literal string such as "A String".
  • Use the new operator.

Of all of these, the last two are by far the most common.

What you cannot do!

You cannot instantiate a new object using code like the following code fragment that was extracted from this program.

Note:
NewClass obj = NewClass();

This program produces the following compiler error:

Note:
Ap090.java:18: cannot resolve symbol
symbol  : method NewClass  ()
location: class Worker
    NewClass obj = NewClass();

The solution to the problem

This problem can be solved by inserting the new operator to the left of the constructor as shown in the following code fragment.

Note:
    NewClass obj = new NewClass();

Back to Question 1

-end-

Collection Navigation

Content actions

Download:

Collection as:

EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Reuse / Edit:

Reuse or edit collection (?)

Check out and edit

If you have permission to edit this content, using the "Reuse / Edit" action will allow you to check the content out into your Personal Workspace or a shared Workgroup and then make your edits.

Derive a copy

If you don't have permission to edit the content, you can still use "Reuse / Edit" to adapt the content by creating a derived copy of it and then editing and publishing the copy.

| Reuse or edit module (?)

Check out and edit

If you have permission to edit this content, using the "Reuse / Edit" action will allow you to check the content out into your Personal Workspace or a shared Workgroup and then make your edits.

Derive a copy

If you don't have permission to edit the content, you can still use "Reuse / Edit" to adapt the content by creating a derived copy of it and then editing and publishing the copy.