Skip to content

Commit

Permalink
java classes practice code added
Browse files Browse the repository at this point in the history
  • Loading branch information
mdyasinahmed committed Jul 9, 2023
1 parent 6cc4257 commit 05140fe
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/OOPS/CLASSES.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@


// Java - Class
class Pen{
String color;
String type;

public void write(){
System.out.println("Write Something.");
}

public void printColor(){
System.out.println(this.color);
}

public void printType(){
System.out.println(this.type);
}
}

class Student{
String name;
int age;

public void printInfo(){
System.out.println(this.name);
System.out.println(this.age);
}
}


public class CLASSES{
public static void main(String args[]){
Pen pen1 = new Pen();
pen1.color = "blue";
pen1.type = "gel";
pen1.write();

Pen pen2 = new Pen();
pen2.color = "black";
pen2.type = "ballpoint";

pen1.printColor();
pen2.printColor();


Student s1 = new Student();
s1.name = "Yasin";
s1.age = 20;
s1.printInfo();
}
}
Empty file added src/OOPS/CONSTRACTORS.java
Empty file.

0 comments on commit 05140fe

Please sign in to comment.