public class XClass
{
private int u;
private double w;
Public XClass () { }
Public XClass ( int a, double b)
Public void func() { }
public void print() { }
}
XClass x = new XClass (10, 20.75);


Q1. How many members does class XClass have?

Q2. How many private members does class XClass have?

Q3. How many constructors does class XClass have?

Q4. write the definition of the member func so that u is set to 10 and w is set to 15.3?

Q5. write the definition of member print that prints the contents of u and w?

Q6. write the definition of the default constructor of class XClass so that the instance variables are initialised?

Q7. write the definition of the Xclass constructor that takes two parameters so that u is initalised to a and w is initalised to b?

Q8. write a java statement that prints the values of the instance variable of x?

Q9. write a java statement that creates the XClass object t and initalises the instance variables of 1 to 20 and 35.0 respectively.

Recommended Answers

All 4 Replies

Which question? I see 9 questions.
Answer the ones you know, and we MAY be able to help with the rest.

However, this forum is not for you to submit your homework assignments for us to do.

You should at the very least try to answer them yourself first.

Nice advise jerbo :D

The reality is i do not understand this question as i am very new to java, it is not homework it is online tests which i am doing any help will be very grateful

Q1. Try looking up java members in google or structure the question differently like "whats a member in java?" then apply that answer to your question youve got. I mean i don't even know what it means by members.

Q2. How many private members does class XClass have?
Have a guess and say why you think and we will tell you if your right.

Q3. How many constructors does class XClass have?
Look up Java Constructors in a book or on the web, then check back at your code and see if you recognise anything.

Q4. write the definition of the member func so that u is set to 10 and w is set to 15.3?

Maybe you should go through a basic java tutorial if you are new to it :) It will give you somewhere to start. When youve done that come back see what you suggest for the answers and we can give you hints e.t.c

Try these:
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.