Write a Student class to get the desired output as shown below. 1. Create a Student class and a class variable called ID initialized with 0. 2. Create a constructor that takes 4 parameters: name, department, age and cgpa. 3. Write a get_details() method to represent all the details of a Student 4. Write a class method from_String() that takes 1 parameter which includes name, department, age and cgpa all four attributes in string.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question
100%
Write a Student class to get the desired output as shown below.
1. Create a Student class and a class variable called ID initialized with 0.
2. Create a constructor that takes 4 parameters: name, department, age and cgpa.
3. Write a get_details() method to represent all the details of a Student
4. Write a class method from_String() that takes 1 parameter which includes
name, department, age and cgpa all four attributes in string.
#Write your code here for subtasks 1-6.
OUTPUT
ID: 1
s1 = Student("Samin", "CSE", 21, 3.91)
s1.get_details()
print("--
s2 = Student("Fahim", "ECE", 21, 3.85)
s2.get_details()
print("-
s3 = Student("Tahura", "EEE", 22, 3.01)
s3.get_details()
print("-
s4 = Student.from_String("Sumaiya-BBA-23-3.96")
s4.get_details()
Name: Samin
Department: CSE
Age: 21
CGPA: 3.91
----")
----")
ID: 2
Name: Fahim
%3D
Department: ECE
Age: 21
CGPA: 3.85
-")
%3D
ID: 3
Name: Tahura
Department: EEE
Age: 22
CGPA: 3.01
# Write the answer of subtask 5 here
# Write the answer of subtask 6 here
ID: 4
#You are not allowed to change the code above Name: Sumaiya
Department: BBA
Age: 23
CGPA: 3.96
5. Explain the difference between a class variable and an instance variable. Print
your answer at the very end of your code.
6. What is the difference between an instance method and class method? Print your
answer at the very end
Transcribed Image Text:Write a Student class to get the desired output as shown below. 1. Create a Student class and a class variable called ID initialized with 0. 2. Create a constructor that takes 4 parameters: name, department, age and cgpa. 3. Write a get_details() method to represent all the details of a Student 4. Write a class method from_String() that takes 1 parameter which includes name, department, age and cgpa all four attributes in string. #Write your code here for subtasks 1-6. OUTPUT ID: 1 s1 = Student("Samin", "CSE", 21, 3.91) s1.get_details() print("-- s2 = Student("Fahim", "ECE", 21, 3.85) s2.get_details() print("- s3 = Student("Tahura", "EEE", 22, 3.01) s3.get_details() print("- s4 = Student.from_String("Sumaiya-BBA-23-3.96") s4.get_details() Name: Samin Department: CSE Age: 21 CGPA: 3.91 ----") ----") ID: 2 Name: Fahim %3D Department: ECE Age: 21 CGPA: 3.85 -") %3D ID: 3 Name: Tahura Department: EEE Age: 22 CGPA: 3.01 # Write the answer of subtask 5 here # Write the answer of subtask 6 here ID: 4 #You are not allowed to change the code above Name: Sumaiya Department: BBA Age: 23 CGPA: 3.96 5. Explain the difference between a class variable and an instance variable. Print your answer at the very end of your code. 6. What is the difference between an instance method and class method? Print your answer at the very end
Expert Solution
steps

Step by step

Solved in 2 steps with 5 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,