Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What is a parameterized constructor?
Think about its role when creating objects.
Write a simple parameterized constructor for a class called 'Car' with a 'model' attribute.
Use the class structure we discussed.
What is a parameterized constructor?
Remember the difference from a default constructor.
True or False: A parameterized constructor can have a return type.
Think about how constructors work in classes.
Create a class 'Employee' with parameters for 'name', 'id', and 'salary'. Write a parameterized constructor and demonstrate instantiation.
Think about how each employee's details will be initialized.
Modify the existing Student class to include a 'grade' parameter along with 'age'. How would you implement this?
Consider how multiple parameters work in a constructor.
5 more questions in this section. Enroll free to practise them all.
Enroll free