Note: Write a Java program given below Question # 1:  Define a class for Students with field name, age, marks. Define getter and setter for all the fields. In the setter method, if age is less than 0, print that Age is less than zero. Similarly, if marks is less than zero or greater than 100, print in correct marks and don’t assign marks to member variable. In the Test class, create student’s object and assign the marks and age to appropriate values. Try assigning incorrect values to check if getter and setter methods work as expected.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

Note: Write a Java program given below

Question # 1: 

Define a class for Students with field name, age, marks. Define getter and setter for all the fields. In the setter method, if age is less than 0, print that Age is less than zero. Similarly, if marks is less than zero or greater than 100, print in correct marks and don’t assign marks to member variable. In the Test class, create student’s object and assign the marks and age to appropriate values. Try assigning incorrect values to check if getter and setter methods work as expected.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning