Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
336 views1 page

Access Modifier

The document contains a Java class definition for an 'Account' with instance variables for account number, type, and balance, along with methods to get and set these values. It also includes a 'Demo' class that creates an 'Account' object, displays its details, updates the balance, and prints the updated information. The code demonstrates basic object-oriented programming concepts in Java.

Uploaded by

sanjay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
336 views1 page

Access Modifier

The document contains a Java class definition for an 'Account' with instance variables for account number, type, and balance, along with methods to get and set these values. It also includes a 'Demo' class that creates an 'Account' object, displays its details, updates the balance, and prints the updated information. The code demonstrates basic object-oriented programming concepts in Java.

Uploaded by

sanjay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

class Account

{
// instance variables
private int accNo;
private String accType;
private int balance;
public int getAccno()
{
return this.accNo;
}
public String getaccType()
{
return this.accType;
}
public int getBalance()
{
return this.balance;
}
public void setBalance(int balance)
{
this.balance=balance;
}

public Account(int accNo,String accType,int balance)


{
this.accNo=accNo;
this.accType=accType;
this.balance=balance;
}
public Account()
{

}
}
public class Demo {
public static void main(String[] args)
{
Account accobj=new Account(12562001,"Savings",2000);
System.out.println(accobj.getAccno()+" "+accobj.getaccType()+"
"+accobj.getBalance());
accobj.setBalance(31000);
System.out.println("After updation .......................");
System.out.println(accobj.getAccno()+" "+accobj.getaccType()+"
"+accobj.getBalance());
}
}

You might also like