Package aquarium.*;
public class Water{
public String toString() { return ""; }
}
Package aquarium.*;
public class Shark{
static int numfins;
static Water water;
public static void Main(String[] args){
String s1 = water.toString();
String s2 = numfins.toString();} }
The answer for this question is numfins.to
String() does not compile because numfins is a primitive;
What is static Water water ; in this question .... Why two water words are used here...
which are true of following code???
Moderator: admin
-
- Posts: 14
- Joined: Thu Dec 22, 2016 8:55 pm
- Contact:
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: which are true of following code???
Water with capital W is the class name. water with small w is the static variable name. This variable is being declared to be of type Water.
BTW, what happened when you asked your doubt to the author of the book that you have taken this from? Are they not responding?
BTW, what happened when you asked your doubt to the author of the book that you have taken this from? Are they not responding?
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 53 guests