Preview

Java

Satisfactory Essays
Open Document
Open Document
473 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java
OOP2: Object Oriented Programming 2 (Java)

Jocel L. Garrido,CCNA

Object Oriented Programming 2 (Java) Instructor: Jocel L. Garrido Classes 3 Parts: -Class Name -Attributes -Functions or methods

class Reading_Material public class Reading_Material {

public class Reading_Material { private String Title, Publisher; private int date_published, current_page; public int get_page() { return current_page; }

-Title -Publisher -date_published -current_page

private String Title, Publisher; private int date_published, current_page; public int get_page() { }

return current_page;

+get_page +turn_page_forward +turn_page_backward +get_Publisher +get_date_published +get_Title

Syntax: class { [] [] [] }

Example: public class Person { //attribute declarations private String name; private int age; private Date birthday; // class constructor public Person() { name = "secret"; age = 0; birthday = new Date(7,7); }

//accessor methods - setters public void setName(String X){ name= X; } }

OOP2: Object Oriented Programming 2 (Java)

Jocel L. Garrido,CCNA

• • • •

What is a Method? A method refers to a piece of code referring to behaviors associated either with an object or its class A code found in a class for responding to a message The executable code that implements the logic of a particular message for a class An operation or function that is associated with an object and is allowed to manipulate the object's data A method call is thus considered to be a request to an object to perform some task.

Creating a Method
Steps in declaring a method 1. Set the return type 2. Provide method name 3. Declare formal parameters method signature • consists of the method name and its parameters • must be unique for each method in a class A method with empty parameters

class Number { int multiply(int i, int j) { return i*j; } int divide(int i, int j) { return i/j; } double getPi() { return 3.14159265358979; }

return statement • allows the method

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Attribute-Based Programming: Attributes assist you to add declarative information in your programs. This information can then be queried at runtime using reflection.…

    • 485 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Mat 540 Week 4 Paper

    • 1775 Words
    • 8 Pages

    Although the details can be quite complex, these details are the basic principles of object-oriented programming.…

    • 1775 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    The first step in the scientific method is to observe. When you are observing you are discovering what is going on around you. The second step in the scientific method is question. To question one must make an attempt to explain the observation that was made. The next step in the scientific method is making a hypothesis. A hypothesis is made to predict a solution and an outcome. The fourth step in the scientific method is making a prediction. When making a prediction you are indicating the outcome. Next is the conclusion. The conclusion details the findings of the testing. This then leads to the final step which is the results. The results are whether your findings based on the hypothesis…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    concepts of classes, objects, constructors, methods, access control, this keyword, overloading methods and constructors, parameter…

    • 414 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    One of the main properties of the classes is inheritance. This property allows us to create new classes from existing classes, retaining the properties of the original class and adding new ones.…

    • 290 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Programming

    • 3038 Words
    • 13 Pages

    2. Each of the flowchart segments in Figure 3-35 is unstructured. Redraw each flowchart segment so that it does the same thing but is structured.…

    • 3038 Words
    • 13 Pages
    Good Essays
  • Good Essays

    Object Oriented Processes

    • 400 Words
    • 2 Pages

    Identify how you can encapsulate the data and processes you identified into an object-oriented design.…

    • 400 Words
    • 2 Pages
    Good Essays
  • Good Essays

    References: • Nirosh. (2010). Introduction to Object Oriented Programming Concepts (OOP) and More. The Code Project. Retrieved from: http://www.codeproject.com/KB/architecture/OOP_Concepts_and_manymore.aspx.…

    • 817 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Java Programming

    • 461 Words
    • 2 Pages

    Tipping has become just a normal expense already calculated into ones dining experience. It is understood that most services that provide us consumers a way to measure how satisfied we are with the experience of vending with a particular merchant; is done so through tipping.…

    • 461 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    On the order hand, Object oriented programming (OOP) have taken the best ideas of structured programming and combined them with several powerful new concept that encourage you to approach the task of programming in a new way. Object-oriented programming is a programming methodology that associates data structures with a set of operators that act upon it. In OOP’s terminology an instance of such an entity is known as an object, it gives importance to relationships between objects rather than implementation details. Object-Oriented Programming is centered on new concepts such as classes, polymorphism, inheritance, etc.…

    • 641 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Copro 2 Reviewer 2014

    • 557 Words
    • 3 Pages

    Classes is a term that describes a group or collection of objects with common properties.…

    • 557 Words
    • 3 Pages
    Good Essays
  • Good Essays

    References: Deitel, H.M., & Deitel, P.J. (2002). Java: How to program (6th ed.). Upper Saddle River, NJ: Pearson Education…

    • 356 Words
    • 2 Pages
    Good Essays
  • Better Essays

    Relational Database Model

    • 964 Words
    • 4 Pages

    When designing a Relational Database, you must create a table for each entity type, choose or invent a primary key for each table; add foreign keys to represent one-to-many relationships; create new tables to represent many-to-many relationships; define referential integrity constraints; evaluate schema quality and make necessary improvements; and choose appropriate data types and value restrictions for each field (if necessary).…

    • 964 Words
    • 4 Pages
    Better Essays
  • Better Essays

    The class I created relates to the real world. My class is made up of computers. It represents all the computers that are made or produced. Some of the attributes from my class are the make, model, processor, storage, mouse, keyboard, graphics, and the RAM of the computer. Some of the methods are updating the computer, changing the RAM, changing the mouse or keyboard, and changing the graphics and storage. The attributes of the computer are what define the object as part of the class. For example, the make could be Apple, HP, or Samsung. If we talk about the model, it could be an Apple iMac, HP Pavilion, or Toshiba Satellite. The processor it needs to run, Intel or AMD. The amount of RAM it has, 4, 8, or 16GB. The size of the storage is it 500GB, 1TB, or 2TB. Does the computer have a wireless mouse and keyboard, or does it have Bluetooth. The computer has methods for updating…

    • 1111 Words
    • 3 Pages
    Better Essays
  • Satisfactory Essays

    Identify how you can encapsulate the data and processes you identified into an object-oriented design.…

    • 506 Words
    • 2 Pages
    Satisfactory Essays

Related Topics