Devaney Marcondes

Greenhorn
+ Follow
since Nov 22, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Devaney Marcondes

Another typo mistake to add:
On page 371 instead of:
System.out.println(" Movie " + movieName + "(" + year ")" + " grossed " + revenue );
Must be:
System.out.println(" Movie " + movieName + "(" + year + ")" + " grossed " + revenue );
You're so great, this example clarified my doubts , but the answer B accept white spaces in the middle.


And it prints:



If we follow the question literally, the question don't say anything about space, but when I read "to match an e-mail address", I think that couldn't have a space.
Anyway, thanks a lot for your attention.

Hi.
In this case the regex "\b\D\w+@\w+\.com\b" will fine too, because it don't print anything.

Look:


In my opinion either both is correct or both are wrong (in this case the correct answer is D- None of the above.)
If you think that only B is correct, could you make a sample?
;-)

Thanks

T. Sharma wrote:

Devaney Marcondes wrote:

I will correct myself but the book answer is still incorrect.
The correct answer is C.
The book explanation say:

Answer: B. “b\ D\ w*@\ w +\. com\ b” (“\ b” is used to mark word boundaries,
“\ D” is used to match any non-digit number, and “\ w*”
is used to match any word of length zero or more.
The remaining part is similar to that used earlier.)

For this reason \w* is wrong because if the email is "@notaemail.com" the regex “b\ D\ w*@\ w+\. com\ b” will accept it.
The right regex is “b\ D\w+@\ w +\. com\ b” (with the plus before @).



Dear Devanev, with due respect I think your explanation is not correct. You are missing "\D" which is used in this question to satisfy the requirement of the question that the email address must not start with a digit. Thus, the regex will not match to "@notaemail.com" because the regex looks for a not digit (due to "\D") which is missing. Since, "\D" is already used, there should be "\w*" (and not "\w+") to make the expression correct; otherwise it will not match to addresses like "a@notaemail.com". I hope it will help.

You are right about the typo, we will include that in our errata doc. Thanks for that.


Thanks a lot for your answer.
You're right about to not use "\w+", whatever, the answer B is wrong too.
Try to execute the code below:



Thanks.

Devaney Marcondes wrote:In my opinion the question 5 of the chapter 7 have 2 correct answer.
The B and C are correct.



I will correct myself but the book answer is still incorrect.
The correct answer is C.
The book explanation say:

Answer: B. “b\ D\ w*@\ w +\. com\ b” (“\ b” is used to mark word boundaries,
“\ D” is used to match any non-digit number, and “\ w*”
is used to match any word of length zero or more.
The remaining part is similar to that used earlier.)

For this reason \w* is wrong because if the email is "@notaemail.com" the regex “b\ D\ w*@\ w+\. com\ b” will accept it.
The right regex is “b\ D\w+@\ w +\. com\ b” (with the plus before @).

------
On the page 207 have a typing error:
instead "In matchStr, check for matchLen characters starting from matchStartOffset."
must be instead: "In matchingStr, check for matchLen characters starting from matchStartOffset."


In my opinion the question 5 of the chapter 7 have 2 correct answer.
The B and C are correct.

Jose Ricardo Santos wrote:

About the practical exam (Appendix H) don't you think that:

Question 13 - If the continue statement is allowed in switch statement then the break is also (as well the continue) in all conditional statements. After all, since the conditional statement is inside a loop, you can have a break or continue statement. Don't you agree?


13 - The continue and break statements are allowed within what types of statements?
A. Loop statements
B. All conditional statements
C. The switch statement
D. Expression statements

answer (book): A and C

In my opnion the answer is wrong.
Only A is right. If you try put the continue statement in the switch will occur a compilation error.
Try this:



The exception say:
TestClass.java:11: error: continue outside of loop
default: continue;
^
1 error

Roel De Nijs wrote:If you try to cast between different inheritance trees (like casting a String to an Integer or your example) you'll get a compiler error. If you perform a wrong casting in the same inheritance tree, you'll get a runtime exception (e.g. casting an object to a String)


Yes. Thus C and D are correct.
And what do you think about this question?

If a variable is cast to a invalid objec, what is the effect?

A- (I don't Remember)
B- (I don't Remember)
C - A compile error will occur.
D - A runtime exception will be thrown.

Explanation: D is correct. This will causee a runtime exception to be throw.
A, B and C are incottect. A and B are incorrect because there is no way to proceed once a
casting error encountered. C is incorret because the compiler is unable to determine this is an error until runtime.

In my opinion the answer C and D are right. Why?
Look that:








The MyClassTest won't be compiled.

Deepak Lal wrote:what is the answer given to this question and the reason please ?
According to me the answer is C. Code obfuscation.Please correct me If im wrong.



Answer:  Book answer is B and D. Polymorphism aids in creating reusable code, because it allows the code to be written more abstractly, thus B is correct. Similar to B, polymorphism allows the code to be generic by using generic data types that any more specific object can fulfill. Thus, D is also correct.
"A" and "C" are incorrect. A is incorrect because polymorphism has no effect on the level of optimization of the code. C is incorrect because obfuscated code (code that is intentionally difficult to read) is not related to polymorphism.

In my opinion, "A" is correct to. I don't agree with you that the answer "C" is correct.
Hi everyone.
I would like know, in your opinion, what is "optimization code".
In my opinion, to optimize a code means make a code with the "Best practices" as possible to do this code become more readable and MAYBE a faster program.
I make this question because in the book OCA JAVA SE 7 - Programmer I - Study Guide - Exam 1Z0-803 do Robert Liguori e Edward Finegan has a question that say:
Polymorphism helps to facilitate which of the following? (Choose all that apply.)

A. Highly optimized code
B. Code reuse
C. Code obfuscation
D. Code that is generic and flexible

The A is one of the answer that I marked, but the book say this answer is wrong and the explanation say:
"A" is incorrect because polymorphism has no effect on the level of optimization of the code.
In my opinion the polymorphism optimize the code and MAYBE not optimize the program.

Roel De Nijs wrote:

Devaney Marcondes wrote:Experts, what do you think?


D is the correct answer, all methods are valid overloads of the given method.

Why do you think only C is a valid overload? What are the rules for a valid overload?



Because I was wrong.
I thought that to overload a method the overloading method should have the same return.
I did a mistake.

Sorry and thank you.
I didn't want open another topic because the title is the same but the question is different.

Given this method signature:

public void logEvent(String eventDescription) {/*Method Body */}


Which method overloads it?

A -

B -

C -

D - All of above


Correct Answer D: All of the above
References EXPLANATION: D is correct. They are all valid ways to overload the given method.
A, B, and C are incorrect. Each of these is not true; therefore, D is the correct answer


#####################################################

In my opinion the answer C is correct and the explanation doesn't make sense.
Experts, what do you think?
In the first question in the first chapter (Self test understanging Packages)
The answer B is wrong because the package Java.util.* (with the capital J) not exist.

Roel De Nijs wrote:
As a side note: These explanations are very weird. It seems that they should belong to another question, because this question has nothing to do with inheritance, but (based on A & B) with (in)valid implementations of an interface.


You are right. The software indicated me that I was wrong and the explaining was a little strange.
I found a nother strange question:

Question Java 7's Garbage-First (G1) garbage collector is planned as the long-term replacement of
which collector?
Correct Answer D: Concurrent Mark-Sweep (CMS) Collector


References EXPLANATION: D is correct. Java 7's Garbage-First (G1) garbage collector
is planned as the long-term replacement of the Concurrent Mark-Sweep (CMS) collector.
A, B, and C are incorrect. A is incorrect because the G1 collector is replacing the CMS Collector,
not the Serial Collector. B is incorrect because the G1 collector is replacing the

LearnKey, Inc. Copyright 2006, All Rights Reserved.Page 6
CMS Collector, not the Parallel Collector. C is incorrect because the G1 Collector is replacing the CMS Collector, not the Parallel Compacting Collector.
REFERENCES: See Finegan, Edward and Robert Liguori. "OCA Java SE 7 Programmer I Study Guide (Exam 1Z0-803)." New York, McGraw-Hill, 2012.
Chapter 5: Understanding Methods and Variable Scope
OBJECTIVE: Understand Variable Scope
----------------------------
The answer could be right, but I didn't find any reference about the CMS in this book.
If someone would find I will be grateful if show me where it is.

Thanks.