Java

Satisfactory Essays
Topics: Subroutine, 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

    Java

    • 1218 Words
    • 5 Pages

    without any errors. . Copyright Reserved. Mohd Fadzli Marhusin. 3 Computer Instruction : Cont’ You write a computer program using a high-level programming language, e.g. java. The java compiler and interpreter responsible to converting the code you write into form of on and off switches. When you execute a java program, the program is run within a contained environment…

    • 1218 Words
    • 5 Pages
    Satisfactory Essays
  • Good Essays

    Java

    • 827 Words
    • 4 Pages

    Java Problems SEQUENCE PROBLEMS: 1. Create a Java program that will print the sum of two integers. 2. Print the sum and product of three integers. 3. Print the perimeter and area of a rectangle. 4. Given the number of a baseball team’s wins and losses, compute its winning percentage. Assume that there are no ties. 5. Input the number of a team’s wins, losses, and ties, and print its winning percentage. Assume that a tie game counts as a full game played and a half-game won. 6. Given the…

    • 827 Words
    • 4 Pages
    Good Essays
  • Better Essays

    JAVA

    • 956 Words
    • 4 Pages

    called Java and eventually in 1994 after the failure of Interactive TV Java project team switched their focus to the web. On May 23rd 1995 the director of Sun Microsystems along with co-founder and executive vice president Netscape announced to the world about the Java. There is only 30 pepole team when java was started. Development of java has taken step by step process. There are many versions in Java like Versions 1.0 and 1.1 are the initial release of Java. Java 2 (Version 1.2), Kestrel (Java 1.3)…

    • 956 Words
    • 4 Pages
    Better Essays
  • Good Essays

    Java

    • 34590 Words
    • 158 Pages

    Java 2 ™ FOR DUMmIES ‰ 2ND by Barry Burd EDITION Java 2 For Dummies, 2nd Edition Published by Wiley Publishing, Inc. 111 River Street Hoboken, NJ 07030-5774 Copyright © 2004 by Wiley Publishing, Inc., Indianapolis, Indiana Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying…

    • 34590 Words
    • 158 Pages
    Good Essays
  • Good Essays

    Java

    • 5076 Words
    • 21 Pages

    Java Software Solutions: Foundations of Program Design, 6e (Lewis/Loftus) Chapter 1 Introduction Multiple-Choice Questions 1) A Java program is best classified as A) hardware B) software C) storage D) processor E) input Answer: B Explanation: B) Programs are classified as software to differentiate them from the mechanisms of the computer (hardware). Storage and the processor are two forms of hardware while input is the information that the program processes. 2) 6 bits can be…

    • 5076 Words
    • 21 Pages
    Good Essays
  • Powerful Essays

    Java

    • 3153 Words
    • 13 Pages

    subject matter, subject landscape, or even world view. This transformation may be sudden or it may be protracted over a considerable period, with the transition to understanding proving troublesome ” (H.F. Meyer and R Land, 2006, p.3). An example in Java programming, the array is the accepted standard to store more than one variable, it is virtually practised universally. But the concept, when grasped, tends to be “ritual knowledge” (Perkins 1999). It doesn’t have to be understood, one just has…

    • 3153 Words
    • 13 Pages
    Powerful Essays
  • Good Essays

    Java

    • 490 Words
    • 3 Pages

    Write a Java program to demonstrate using bitmaps and bitwise operators to sort and remove duplicates from a file of random phone numbers. Do not confuse the term bitmap used for compressing data into smaller spaces with the bitmap that has come to mean a graphic image. You will use this file of 4 million random phone numbers with possible repeats in args[0]. In addition, will be given an output filename provided inargs[1] into which you will write the sorted list of phone numbers without duplicates…

    • 490 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Java

    • 472 Words
    • 2 Pages

    Java technology is a high-level programming and a platform independent language. Java is designed to work in the distributed environment on the Internet. Java has a GUI features that provides you better "look and feel" over the C++ language, moreover it is easier to use than C++ and works on the concept of object-oriented programming model. Java enable us to play online games, video, audio, chat with people around the world, Banking Application, view 3D image and Shopping Cart. Java find its extensive…

    • 472 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    java

    • 258 Words
    • 2 Pages

    OverviewPackageClassUseTreeDeprecatedIndexHelp Java™ Platform Standard Ed. 7 Prev ClassNext ClassFramesNo FramesAll ClassesSummary: Nested | Field | Constr | MethodDetail: Field | Constr | Method java.util Class Scanner java.lang.Object java.util.Scanner All Implemented Interfaces: Closeable, AutoCloseable, Iterator public final class Scanner extends Object implements Iterator, Closeable A simple text scanner which can parse primitive types and strings using regular expressions. A…

    • 258 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Java

    • 1389 Words
    • 6 Pages

    Java Language Programming Basic Programming Elements Tiberiu Leţia: Software Engineering –Java Programming Language – Programming Basic Elements 1 Content 1. Stand alone applications and mini-applications 2. Name and identifiers 3. Java program structure 4. Data types 5. Operators 6. Flow execution control Tiberiu Leţia: Software Engineering –Java Programming Language – Programming Basic Elements 2 1. Stand alone applications and mini-applications Mini- applications = applets…

    • 1389 Words
    • 6 Pages
    Powerful Essays