1 create a class called book defines properties title


Please paste all of your code into this Word document and submit a single Word document for your solution.  Please enter your answers in bolded or a different color font, so they're easy to find - thanks!  Note that the PowerPoint and the MSDN website resource on Object-Oriented Programming for this week might be helpful.

1. Create a class called Book defines properties Title, Author and Year.  Add a method called Display() that outputs the Title and Author

2. Create a class called BookTest that uses an object initializer to create an object of class Book (from step 1) and initialize all of its properties.  Note: you will need to create a constructor method to do this 

Answer the following in essay form: 

3.Before adding a constructor method, describe what is called when we create an instance of type Book?

A: Constructors are uncommon routines used to introduce types and make occasions of types. A type constructor is utilized to instate static information in a type. A type constructor is called by the common language runtime (CLR) before any occurrences of the type are made. Type constructors are static (Shared in Visual Basic) and can't take parameters. A case constructor is utilized to make examples of a type. Occasion constructors can take parameters, yet are not required to do as such. An occasion constructor without any parameters is known as a default constructor.

4. What concept would we be practicing if we created two new constructor methods?

A: New constructor method create a new function in java

5. Why is it important to use exception handling?

A: Exception handling is important for handling exceptions in the program. We can easily handle them by using try catch blocks.

6.What's the purpose of private vs. public when we're adding new properties and/or methods to our class?  How does this apply to information hiding?

A:  PRIVATE

Visible to the class only (private).

Methods, Variables and Constructors that are declared private can only be accessed within the declared class itself.

Private access modifier is the most restrictive access level. Class and interfaces cannot be private.

Variables that are declared private can be accessed outside the class if public getter methods are present in the class.

Using the private modifier is the main way that an object encapsulates itself and hide data from the outside world.

PUBLIC

Visible to the world (public).

A class, method, constructor, interface etc declared public can be accessed from any other class. Therefore fields, methods, blocks declared inside a public class can be accessed from any class belonging to the Java Universe.

However if the public class we are trying to access is in a different package, then the public class still need to be imported.

Because of class inheritance, all public methods and variables of a class are inherited by its subclasses.

7. What is composition?  How could we use Composition in our Book class?

A: In the visual arts-in unique painting, image design, images, and sculpture-composition is the placement or association of visual factors or constituents in a work of art, as particular from the field of a piece. It can be proposal of because the institution of the elements of artwork in step with the principles of art.

The term composition manner 'putting together,' and can observe to any work of art, from track to writing to images, that's organized or put collectively utilizing mindful inspiration. In the visible arts, composition is ordinarily used interchangeably with various phrases such as design, form, visual ordering, or formal structure, depending on the context. In photo design for press and desktop publishing composition is probably known as web page layout.

8. What is data abstraction?

A:Data abstraction is one of the principle of object oriented programming. It is used to display only necessary and essential features of an object to outside the world.Means displaying what is necessary and encapsulate the unnecessary things to outside the world.Hiding can be achieved by using "private" access modifiers.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: 1 create a class called book defines properties title
Reference No:- TGS01185861

Expected delivery within 24 Hours