[HD Pg 374, Sec. 2.8.0 - exercises]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 374, Sec. 2.8.0 - exercises]

Post by admin »

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.
If you like our products and services, please help us by posting your review here.

BlackCat
Posts: 8
Joined: Wed Jan 29, 2020 11:09 am
Contact:

Re: [HD Pg 374, Sec. 2.8.0 - exercises]

Post by BlackCat »

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();

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 374, Sec. 2.8.0 - exercises]

Post by admin »

Correct.
If you like our products and services, please help us by posting your review here.

Leonid
Posts: 9
Joined: Mon Jun 28, 2021 4:50 am
Contact:

Re: [HD Pg 374, Sec. 2.8.0 - exercises]

Post by Leonid »

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?

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 374, Sec. 2.8.0 - exercises]

Post by admin »

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.

Leonid
Posts: 9
Joined: Mon Jun 28, 2021 4:50 am
Contact:

Re: [HD Pg 374, Sec. 2.8.0 - exercises]

Post by Leonid »

admin wrote:
Mon Jun 28, 2021 6:16 am
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!
I tried to delete my post yesterday. Because I realized what my mistake was. But nothing happened. Thank you for responding.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], pavvel and 20 guests