FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-tutorial/Access-Modifiers/Main.java at main · MisaghMomeniB/java-tutorial · GitHub
MisaghMomeniB
/
java-tutorial
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-tutorial
/
Access-Modifiers
/
Main.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (39 loc) · 1.21 KB
Breadcrumbs
java-tutorial
/
Access-Modifiers
/
Main.java
Copy path
File metadata and controls
52 lines (39 loc) · 1.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// BankAccount class represents a simple bank account
class
BankAccount
{
// Private variable to store account number
private
int
accountNumber
;
// Private variable to store account balance
private
double
balance
;
// Method to set the account number
public
void
setAccountNumber
(
int
num
) {
accountNumber
=
num
;
}
// Method to set the account balance
public
void
setBalance
(
double
bal
) {
balance
=
bal
;
}
// Method to get the account number
public
int
getAccountNumber
() {
return
accountNumber
;
}
// Method to get the account balance
public
double
getBalance
() {
return
balance
;
}
}
// Main class
public
class
Main
{
// Main method - program execution starts here
public
static
void
main
(
String
[]
args
) {
// Create an object of BankAccount
BankAccount
acc
=
new
BankAccount
();
// Set account number
acc
.
setAccountNumber
(
12345
);
// Set account balance
acc
.
setBalance
(
5000
);
// Print account number
System
.
out
.
println
(
"Account Number: "
+
acc
.
getAccountNumber
());
// Print account balance
System
.
out
.
println
(
"Balance: "
+
acc
.
getBalance
());
}
}
Back
|
FazBrowse Home
|
New Git URL