SHARE
TWEET

OOP Basics

a guest Sep 16th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaoas;
  7.  
  8. /**
  9.  *
  10.  * @author Mobile App Develop
  11.  */
  12. public class Main {
  13.     public static void main(String[] args) {
  14.         Person person1 = new Person();
  15.        
  16.         person1.firstName = "Hafizur";
  17.         person1.lastName = "Arfin";
  18.         person1.middleName = "Rahman";
  19.        
  20.         Person person2 = person1;
  21.         person2.firstName = "Fahim";
  22.        
  23.        
  24.         String fullName = person1.getFullName();
  25.         System.out.println(fullName);
  26.        
  27.         String reverseName = person1.getReverseName();
  28.         System.out.println(reverseName);
  29.     }
  30. }
  31.  
  32. /*
  33.  * To change this license header, choose License Headers in Project Properties.
  34.  * To change this template file, choose Tools | Templates
  35.  * and open the template in the editor.
  36.  */
  37. package javaoas;
  38.  
  39. /**
  40.  *
  41.  * @author Mobile App Develop
  42.  */
  43. public class Person {
  44.     String firstName;
  45.     String middleName;
  46.     String lastName;
  47.    
  48.     String getFullName(){
  49.         return firstName + " " + middleName + " " + lastName;
  50.     }
  51.    
  52.     String getReverseName(){
  53.         return lastName + " " + middleName + " " + firstName;
  54.     }
  55.    
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top