Skip to content

Commit

Permalink
Class & Objects practice code added
Browse files Browse the repository at this point in the history
  • Loading branch information
mdyasinahmed committed Jul 13, 2023
1 parent bff5186 commit a9fc57f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/OOPS/classes and objects/OOPS.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import java.util.*;

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

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

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

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

class Student{
String name;
int age;
class Student{
String name;
int age;

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

// Creating Object
public class OOPS{
Expand Down
Binary file added src/OPPs_Prac/OOPs.class
Binary file not shown.
22 changes: 22 additions & 0 deletions src/OPPs_Prac/OOPs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Student{
String name;
String id;
int age;

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

public class OOPs{
public static void main(String args[]){
Student s1 = new Student();

s1.name = "Yasin";
s1.id = "222-115-095";
s1.age = 20;
s1.printInfo();
}
}
Binary file added src/OPPs_Prac/Student.class
Binary file not shown.

0 comments on commit a9fc57f

Please sign in to comment.