Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Thirteen VERY quick questions. Answer all to receive positive rate. IF any are skipped, I will rate negatively. 1. Write a Java for -statement header

Thirteen VERY quick questions. Answer all to receive positive rate. IF any are skipped, I will rate negatively.

1. Write a Java for-statement header that generates the elements of the set

i { 1,3,5,7,9,11 }.

2. (Continuing 1) Write a while-statement that generates the same set of elements.

3. (Continuing 1) Write a do/while-statement that generates the same set of elements.

4. Write a Java for-statement header that generates the elements of the set

i { 1,2,4,8,16,32,64,128 }.

5. (Continuing 4) Write a while-statement that generates the same set of elements.

6. (Continuing 4) Write a do/while-statement that generates the same set of elements.

7. What is the scope of a for-statement control variable?

8. (Continuing 7) T or F? The following code segment contains a syntax error.

int i;

for (int j = 1; i <= 3; i++)

for (int i = 11; i <= 13; i++)

System.out.printf("%d ",i);

9. If the following code segment does not contain a syntax error, what does it output?

for (int i = 1; i <= 5; i++)

{

System.out.printf("%d ",i);

i = 6;

}

10. Many library (and programmer-defined) classes define methods that provide common tasks but do not require class objects. These methods are called static methods. Describe the syntax used to call static methods.

11. (Continuing 10) T or F? A static method can legally make use of a this reference.

12. The [Java] switch multiple-selection statement performs different actions based on the possible values of a constant integral expression of type byte, short, int or char (or a String literal or constant variable). Dr. Hanna wonders, not including long in the preceding list of allowable data types is a violation of the language design principle of conceptual integrity. Why do you think the designers of the Java programming language left the integral type long off the list? Hint Read http://wiki.c2.com/?ConceptualIntegrity and some of that web pages embedded links to begin to understand the idea conceptual integrity.

13. How is the Java programming language switch-statement syntax and semantics different from the C++ and C switch statement?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

=+5 How does HRM relate to efforts to increase innovation?

Answered: 1 week ago