Question
Exercise 1 - (4 Marks) Consider the following declaration of class XClass: 1. How many members does class XClass have? 2. How many constructors
Exercise 1 - (4 Marks) Consider the following declaration of class XClass: 1. How many members does class XClass have? 2. How many constructors does class XClass have? 3. Write the definition of the default constructor of the class XClass so that the instance variables are initialized to 0. 4. Write the definition of the constructor with parameters of the class XClass so that the instance variable u is initialized to the value of a and the instance variable w is initialized to the value of b. Write the definition of the member func so that u is set to 10 and w is set to 15.3 5. 6. Write the definition of the member print that prints the contents of u and w 7. Write a Java statement that prints the values of the instance variables of x 8. Write a Java statement that creates the XClass object T and initializes the instance variables of T to 20 and 35.0, respectively. public class XClass ( } private int u; private double w; public XClass() 1 public XClass (int a, double b) ( } public void func() { public void print () } XClass x= new XClass (10, 20.75);
Step by Step Solution
3.43 Rating (115 Votes )
There are 3 Steps involved in it
Step: 1
1 How many members does XClass have XClass has 4 members Two instance variablesu and w and two met...Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started