Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Quiz Questions
For Chapter 4

THIS PAGE CONTAINS A SAMPLE quiz on material from Chapter 4 of this on-line Java textbook. You should be able to answer these questions after studying that chapter. Sample answers to all the quiz questions can be found here.

Question 1: A "black box" has an interface and an implementation. Explain what is meant by the terms interface and implementation.

Question 2: A subroutine is said to have a contract. What is meant by the contract of a subroutine? When you want to use a subroutine, why is it important to understand its contract? The contract has both "syntactic" and "semantic" aspects. What is the syntactic aspect? What is the semantic aspect?

Question 3: Briefly explain how subroutines can be a useful tool in the top-down design of programs.

Question 4: Discuss the concept of parameters. What are parameters for? What is the difference between formal parameters and actual parameters?

Question 5: Give two different reasons for using named constants (declared with the final modifier).

Question 6: What is an API? Give an example.

Question 7: Write a subroutine named "stars" that will output a line of stars to standard output. (A star is the character "*".) The number of stars should be given as a parameter to the subroutine. Use a for loop. For example, the command "stars(20)" would output


Question 8: Write a main() routine that uses the subroutine that you wrote for Question 7 to output 10 lines of stars with 1 star in the first line, 2 stars in the second line, and so on, as shown below.


Question 9: Write a function named countChars that has a String and a char as parameters. The function should count the number of times the character occurs in the string, and it should return the result as the value of the function.

Question 10: Write a subroutine with three parameters of type int. The subroutine should determine which of its parameters is smallest. The value of the smallest parameter should be returned as the value of the subroutine.

[ Answers | Chapter Index | Main Index ]

  Published under free license. Design by Interspire