This sentence should be re-framed. At least, there should be a comma after separately. "Initialize it with a new Bird object separately, from TestClass’s main." By "separately", it is trying to imply that the initialization logic for this variable is written separately from Bird class.
Paul.
[HD Pg 374, Sec. 2.8.0 - exercises]
Moderator: admin
-
- Site Admin
- Posts: 10074
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 374, Sec. 2.8.0 - exercises]
If you like our products and services, please help us by posting your review here.
-
- Posts: 8
- Joined: Wed Jan 29, 2020 11:09 am
- Contact:
Re: [HD Pg 374, Sec. 2.8.0 - exercises]
Meaning that you would initialise this Bird instance variable in the main method itself?
Ie something like
(Let’s say the instance variable in Bird class is called myInstanceBird)
In main method
TestClass myTestclass = new TestClass();
myTestClass.myInstanceBird = new Bird();
Ie something like
(Let’s say the instance variable in Bird class is called myInstanceBird)
In main method
TestClass myTestclass = new TestClass();
myTestClass.myInstanceBird = new Bird();
-
- Site Admin
- Posts: 10074
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 374, Sec. 2.8.0 - exercises]
Correct.
If you like our products and services, please help us by posting your review here.
-
- Posts: 9
- Joined: Mon Jun 28, 2021 4:50 am
- Contact:
Re: [HD Pg 374, Sec. 2.8.0 - exercises]
I don't understand what does it mean.
"7.9 Exercises
2. Write a method that determines whether a given number N is a prime number or not by
dividing that number with all the numbers from 2 to N/2 and checking the remainder. "
A prime number is a natural (positive integer) number that has exactly two different natural divisors - one and itself. In other words, a prime number, a number that is divisible by one and by itself.
What I have to do, I don't understand... Ok, for example number is 17. I have to divide it by 2,then by 3, then by 4 and go on to 17/2, right? But it can get me nothing. I need 17%17==0 and that's all. Or am I doing something wrong?
"7.9 Exercises
2. Write a method that determines whether a given number N is a prime number or not by
dividing that number with all the numbers from 2 to N/2 and checking the remainder. "
A prime number is a natural (positive integer) number that has exactly two different natural divisors - one and itself. In other words, a prime number, a number that is divisible by one and by itself.
What I have to do, I don't understand... Ok, for example number is 17. I have to divide it by 2,then by 3, then by 4 and go on to 17/2, right? But it can get me nothing. I need 17%17==0 and that's all. Or am I doing something wrong?
-
- Site Admin
- Posts: 10074
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 374, Sec. 2.8.0 - exercises]
So, how you will check if 16 is a prime number or not? By your logic, it is a prime number because 16%16 == 0!
If you like our products and services, please help us by posting your review here.
-
- Posts: 9
- Joined: Mon Jun 28, 2021 4:50 am
- Contact:
Who is online
Users browsing this forum: Bing [Bot] and 29 guests