dev-resources.site
for different kinds of informations.
Day 11 Today class:
Published at
12/17/2024
Categories
payilagam
java
velachery
chennai
Author
reegan
Main Article
Author
6 person written this
reegan
open
class Supermarket
{
int price, discount; //global variables - non-static
String product_name; //global variables - non-static
public Supermarket(String product_name, int price, int discount) // parameterized constructor
{
this.price = price; //price = i1
this.discount = discount;
this.product_name = product_name;
}
public Supermarket(String product_name, int price)
{
this.price = price; //price = i1
this.product_name = product_name;
}
public static void main(String[] args)
{
Supermarket product1 = new Supermarket("Good Day",10,2);
Supermarket product2 = new Supermarket("Rice",55);
//product1.product_name = "Good Day";
//product1.price = 10; //Assignment Operator
//product1.discount = 2;
//product2.product_name = "rice";
//product2.price = 55;
System.out.println(product1.product_name);
System.out.println(product2.product_name);
product1.buy(); //Method Calling Statement
product1.return_product();
}
public void buy()//Method Body / Definition
{
System.out.println("Buying "+product_name + " "+ (price-discount));
}
public void return_product()
{
System.out.println("Returning "+ product_name + " "+ price);
}
}
payilagam Article's
30 articles in total
Python List Tutorial Day2
read article
System.out.println()
read article
Python List Tutorial
read article
String Functions Examples
read article
Front end day-1 (html,css)
read article
About IRC - Internet Relay Chat
read article
Python Day-29 Dictionary- Exercises, Tasks
read article
LCM & GCD of two numbers
read article
Weekend - Python Interview Questions
read article
Day14 Inheritance:
read article
Python day-28 Dictionary, Frequency of character using nested loops
read article
Objects
read article
System.out.println()
read article
Constructor
read article
Introduction
read article
Python Day-25 List functions, Tasks
read article
Day 12 Constructor in java:
read article
Day 4 - Dec 23 -->java simple program
read article
Day-5 Example for Encapsulation
read article
Day 11 Encupsulation
read article
Day 11 Today class:
currently reading
Day - 1 Task 1
read article
Day 10 Task:
read article
java task 3
read article
Day9 :Task2
read article
Java Constructors
read article
java task 3
read article
java 3 task
read article
java task1
read article
Python Day-23 Lists and list functions,Task
read article
Featured ones: