Few weeks back i started reading Java™ How to Program, Sixth Edition By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.
Nice book written By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.
I wanted to share few quotations found the book from the 5th chapter.
1) The for repetition statement specifies the details of counter-controlled-repetition. The general format of the for statement is
for ( initialization; loopContinuationCondition; increment )
statement
where the initialization expression names the loop's control variable and provides its initial value, loopContinuationCondition is the condition that determines whether the loop should continue executing and increment modifies the control variable's value, so that the loop-continuation condition eventually becomes false.
2) Typically, for statements are used for counter-controlled repetition and while statements are used for sentinel-controlled repetition.
3) The scope of a variable defines where it can be used in a program. For example, a local variable can be used only in the method that declares the variable and only from the point of declaration through the end of the method.
4) The initialization, loop-continuation condition and increment portions of a for statement can contain arithmetic expressions. The increment of a for statement may also be negative, in which case it is really a decrement, and the loop counts downward.
5) If the loop-continuation condition in a for header is initially false, the program does not execute the for statement's body. Instead, execution proceeds with the statement following the for.
6) The format specifier %20s outputs a String with a field width of 20 (i.e., at least 20 character positions). If the value to be output is less than 20 character positions wide, the value is right justified in the field by default. A value can be output left justified by simply preceding the field width with the minus sign () formatting flag.
7) Methods that perform common tasks and do not require objects are called static methods.
8) Java does not include an exponentiation operator. Instead, Math.pow(x, y) can be used to calculate the value of x raised to the y th power. The method receives two double arguments and returns a double value.
9) The comma (,) formatting flag in a format specifier (e.g., %,20.2f) indicates that a value should be output with a thousands separator.
10) The do...while statement tests the loop-continuation condition after executing the loop's body; therefore, the body always executes at least once. The format for the do...while statement is
do
{
statement
} while ( condition );
11) The switch multiple-selection statement performs different actions based on the possible values of an integer variable or expression. Each action is associated with the value of a constant integral expression (i.e., a constant value of type byte, short, int or char, but not long) that the variable or expression on which the switch is based may assume. The switch statement consists of a block containing a sequence of case labels and an optional default case.
13) The expression in parentheses following keyword switch is called the controlling expression of the switch. A program compares the value of the controlling expression with each case label, and if a match occurs, the program executes the statements for that case.
14) The switch statement does not provide a mechanism for testing ranges of values, so every value that must be tested should be listed in a separate case label.
15) Listing cases consecutively with no statements between them enables those cases to perform the same set of statements.
16) Each case can have multiple statements. The switch statement differs from other control statements in that it does not require braces around multiple statements in each case.
17) Most switch statements use a break in each case to terminate the switch statement after processing the case.
18) The end-of-file indicator is a system-dependent keystroke combination which indicates that there is no more data to input.
19) Scanner method hasNext determines whether there is more data to input. This method returns the boolean value TRue if there is more data; otherwise, it returns false.
20) The break statement, when executed in one of the repetition statements, causes immediate exit from that statement. Execution continues with the first statement after the control statement.
21) The continue statement, when executed in a while, for or do...while, skips the remaining statements in the loop body and proceeds with the next iteration of the loop.
22) Logical operators enable programmers to form complex conditions by combining simple conditions. The logical operators are && (conditional AND), || (conditional OR), & (boolean logical AND), | (boolean logical inclusive OR), ^ (boolean logical exclusive OR) and ! (logical NOT).
23) The && (conditional AND) operator can be used to ensure that two conditions are both true before choosing a certain path of execution.
24) The || (conditional OR) operator can be used to ensure that either or both of two conditions are true before choosing a certain path of execution.
25) The parts of an expression containing && or || operators are evaluated only until it is known whether the condition is true or false. This feature of conditional AND and conditional OR expressions is called short-circuit evaluation.
26) The boolean logical AND (&) and boolean logical inclusive OR (|) operators work identically to the && (conditional AND) and || (conditional OR) operators, with one exception: The boolean logical operators always evaluate both of their operands (i.e., they do not perform short-circuit evaluation).
27) A simple condition containing the boolean logical exclusive OR (^) operator is TRue if and only if one of its operands is TRue and the other is false. If both operands are TRue or both are false, the entire condition is false.
28) The ! (logical NOT, also called logical negation or logical complement) operator enables a programmer to "reverse" the meaning of a condition. The logical negation operator is placed before a condition to choose a path of execution if the original condition (without the logical negation operator) is false. In most cases, the programmer can avoid using logical negation by expressing the condition differently with an appropriate relational or equality operator.
29) Unlike the logical operators &&, ||, &, | and ^, which are binary operators that combine two conditions, the logical negation operator is a unary operator that has only a single condition as an operand.
30) The %b format specifier causes the value of a boolean expression to be output as the word "true" or the word "false" based on the expression's value.
31) Any form of control ever needed in a Java program can be expressed in terms of sequence, selection and repetition statements, and these can be combined in only two waysstacking and nesting.
About the Authors
Dr. Harvey M. Deitel, Chairman and Chief Strategy Officer of Deitel & Associates, Inc., has 43 years experience in the computing field, including extensive industry and academic experience. Dr. Deitel earned B.S. and M.S. degrees from the Massachusetts Institute of Technology and a Ph.D. from Boston University. He worked on the pioneering virtual-memory operating-systems projects at IBM and MIT that developed techniques now widely implemented in systems such as UNIX, Linux and Windows XP. He has 20 years of college teaching experience, including earning tenure and serving as the Chairman of the Computer Science Department at Boston College before founding Deitel & Associates, Inc., with his son, Paul J. Deitel. He and Paul are the co-authors of several dozen books and multimedia packages and they are writing many more. With translations published in Japanese, German, Russian, Spanish, Traditional Chinese, Simplified Chinese, Korean, French, Polish, Italian, Portuguese, Greek, Urdu and Turkish, the Deitels' texts have earned international recognition. Dr. Deitel has delivered hundreds of professional seminars to major corporations, academic institutions, government organizations and the military.
Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., is a graduate of the MIT's Sloan School of Management, where he studied Information Technology. Through Deitel & Associates, Inc., he has delivered Java, C, C++, Internet and World Wide Web courses to industry clients, including IBM, Sun Microsystems, Dell, Lucent Technologies, Fidelity, NASA at the Kennedy Space Center, the National Severe Storm Laboratory, Compaq, White Sands Missile Range, Rogue Wave Software, Boeing, Stratus, Cambridge Technology Partners, Open Environment Corporation, One Wave, Hyperion Software, Adra Systems, Entergy, CableData Systems and many other organizations. Paul is one of the most experienced Java corporate trainers having taught about 100 professional Java training courses. He has also lectured on C++ and Java for the Boston Chapter of the Association for Computing Machinery. He and his father, Dr. Harvey M. Deitel, are the world's best-selling Computer Science textbook authors.
Monday, 2 February 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment