0% found this document useful (0 votes)
22 views7 pages

Java Student Class Implementation

The document contains a Java class named 'Student' with attributes for name, age, and grade. It includes a constructor for initializing these attributes, a method to display student details, and a method to check if the student has passed based on a grade threshold. The main method creates two student instances and displays their details along with their pass status.

Uploaded by

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

Java Student Class Implementation

The document contains a Java class named 'Student' with attributes for name, age, and grade. It includes a constructor for initializing these attributes, a method to display student details, and a method to check if the student has passed based on a grade threshold. The main method creates two student instances and displays their details along with their pass status.

Uploaded by

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

23:19 AAO 3ARI

[Link] X
1 public class Student {
2 private String name;
3 private int age;
4 private double grade;
5 C
1/ Constructor that initializes all attributes
7 public Student (String name, int age, double grade) {
8 [Link] = name;

Home End (

Editor Files Console Terminal


23:19O
[Link]
ri
X
8 [Link] = name;
[Link] = age;
10 [Link] = grade;
11
12 C
13 1/ Default constructor
14 public Student(O {
15

< Home End ( )

Editor Files Console Terminal


23:19AO
[Link] X
17 1/ Method to display student details
18 public void displayDetails() {
19 [Link]("Name: + name);
20 [Link]("Age: "
+ age)i
21 "
[Link]("Grade: + grade);
22
23
24 1/ Method to check if the student has passed
Home End (

Editor Files Console Terminal


23:20 AD

[Link]
ri
X ee

25 public boolean hasPassed() {


26 return grade >= 50.0; //passing grade is 50
27 }
28
29 public static void main(String[] args) { C
30 Student student1 = new Student("ola othman", 20, 75.5);
31 [Link]();
32 Svstem. [Link]("Has Passed: "
+ [Link]()):
Home End ( )

Editor Files Console Terminal


23:20FO
[Link] X
32 [Link]("Has Passed: + [Link]());
33
34 Student student2 = new Studernt("malak othman", 19, 45.0);
35 [Link]():
36 [Link]("Has Passed: "
+ [Link]()); C
37 }
38 }
39
Home End ( )

Editor Files Console Terminal


23:20FO
Console ee

Name: ola othman


Age: 20
Grade: 75.5
Has Passed: true
Name: malak othman
Age: 19
Grade: 45.0

Editor Files Console Terminal


23:20FO
Console ee

Grade: 75.5
Has Passed: true
Name: malak othman
Age: 19
Grade: 45.0
Has Passed: false

Editor Files Console Terminal

You might also like