<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/index.php?action=history&amp;feed=atom&amp;title=CSC_216_F09%2FSurvivor%3A_Java_Questions</id>
	<title>CSC 216 F09/Survivor: Java Questions - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/index.php?action=history&amp;feed=atom&amp;title=CSC_216_F09%2FSurvivor%3A_Java_Questions"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC_216_F09/Survivor:_Java_Questions&amp;action=history"/>
	<updated>2026-05-26T01:42:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC_216_F09/Survivor:_Java_Questions&amp;diff=27707&amp;oldid=prev</id>
		<title>Llan3 at 00:16, 18 November 2009</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC_216_F09/Survivor:_Java_Questions&amp;diff=27707&amp;oldid=prev"/>
		<updated>2009-11-18T00:16:42Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;===Questions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This page contains questions for the game &amp;quot;Survivor: Java&amp;quot;.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The questions listed below is followed by answers.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1. 	True or false, int could hold up to 11 digit of numbers.&lt;br /&gt;
False, only up to 2147483647.&lt;br /&gt;
&lt;br /&gt;
2.	What is the difference between int and double?&lt;br /&gt;
Int holds integers, while double holds float point numbers.&lt;br /&gt;
&lt;br /&gt;
3.	To compile, what file extension should you save all your source codes?&lt;br /&gt;
They should be saved as .java files.&lt;br /&gt;
&lt;br /&gt;
4.	How do you comments in java?&lt;br /&gt;
By using // and /*..*/&lt;br /&gt;
&lt;br /&gt;
5.	What is the difference between run-time error and logic error?&lt;br /&gt;
None, they are the same.&lt;br /&gt;
&lt;br /&gt;
6.	What is the difference between logic error and syntax error?&lt;br /&gt;
Syntax error is when the code is written wrong, while logic error is when the program does not do what the programmer programmed it to do.&lt;br /&gt;
&lt;br /&gt;
7.	What is wrong with the given code:	&lt;br /&gt;
	int class =01;&lt;br /&gt;
Class is a reserved word, therefore, cannot be used.&lt;br /&gt;
&lt;br /&gt;
8.	What is the difference between = and == ?&lt;br /&gt;
= is used for assigning, and == is used for comparison.  &lt;br /&gt;
&lt;br /&gt;
9.	What is a parameter?&lt;br /&gt;
A parameter is an input to a method.&lt;br /&gt;
&lt;br /&gt;
10.	True or False, multiple object variables can contain references to the same object.&lt;br /&gt;
True.&lt;br /&gt;
&lt;br /&gt;
11.	What is wrong with the following code:&lt;br /&gt;
	public int calcNum() {&lt;br /&gt;
	num = 99;&lt;br /&gt;
	}&lt;br /&gt;
Missing a return statement.&lt;br /&gt;
&lt;br /&gt;
12.	What keyword should be used when making a constant variable?&lt;br /&gt;
The keyword “final”.&lt;br /&gt;
&lt;br /&gt;
13.	True or false, Boolean can only be three different values.&lt;br /&gt;
False, only two.&lt;br /&gt;
&lt;br /&gt;
14.	What does the % do in java?&lt;br /&gt;
Calculate the remainder of two numbers dividing.&lt;br /&gt;
&lt;br /&gt;
15.	What does n++ do?&lt;br /&gt;
Increment n by 1.&lt;br /&gt;
&lt;br /&gt;
16.	What are roundoff errors?&lt;br /&gt;
It occurs when numbers are cut short and used for calculation.&lt;br /&gt;
&lt;br /&gt;
17.	True or false, the index of an array starts at 1.&lt;br /&gt;
False, starts at 0.&lt;br /&gt;
&lt;br /&gt;
18.	What is the difference between String and char?&lt;br /&gt;
Char holds only 1 letter, while string can hold many.&lt;br /&gt;
&lt;br /&gt;
19.	What does printf do?&lt;br /&gt;
printf is used to print a formatted content.&lt;br /&gt;
&lt;br /&gt;
20.	True or false, Scanner class can be used to read keyboard input in a console window?&lt;br /&gt;
True.&lt;br /&gt;
&lt;br /&gt;
21.	True or false, a static method does not operate on an object?&lt;br /&gt;
True.&lt;br /&gt;
&lt;br /&gt;
22.	What does casting do?&lt;br /&gt;
It turns values of one type to another.&lt;br /&gt;
&lt;br /&gt;
23.	What is the switch statement used for?&lt;br /&gt;
The switch statement is used as a sequence of if and else statement.&lt;br /&gt;
&lt;br /&gt;
24.	What is &amp;amp;&amp;amp; and || used for?&lt;br /&gt;
&amp;amp;&amp;amp; is used as an and and || is used as an or in conditional statements.&lt;br /&gt;
&lt;br /&gt;
25.	What is De Morgan’s Law?&lt;br /&gt;
The law tells us that we can simplify expression in which the not operator is applied to terms joined by the &amp;amp;&amp;amp; and ||.&lt;br /&gt;
&lt;br /&gt;
26.	What is the difference between while and for loops?&lt;br /&gt;
For loop is used to loop through a known numbers of iterations, while the number of iteration on a while loop is not known.&lt;br /&gt;
&lt;br /&gt;
27.	What is an array used for?&lt;br /&gt;
Storing a set of variable of the same type.&lt;br /&gt;
&lt;br /&gt;
28.	What is wrong with the following code:&lt;br /&gt;
	Int I = 0;&lt;br /&gt;
	Int count = 0;&lt;br /&gt;
	While(i&amp;lt;10) {&lt;br /&gt;
	Count++;&lt;br /&gt;
	}&lt;br /&gt;
It is an infinite loop.&lt;br /&gt;
&lt;br /&gt;
29.	What is the result of the following code:&lt;br /&gt;
	Int I = 5;&lt;br /&gt;
	double j = 1.0;&lt;br /&gt;
	System.out.println(i * j);&lt;br /&gt;
5.0&lt;br /&gt;
&lt;br /&gt;
30.	Why do people use long instead of int?&lt;br /&gt;
Long holds more numbers than int.&lt;br /&gt;
&lt;br /&gt;
31. 	What is the purpose of Javadoc?&lt;br /&gt;
The primary purpose of Javadoc is to provide information for developers who use the classes.&lt;br /&gt;
&lt;br /&gt;
32.	 Use the  	 statement to specify the value that a method returns to its caller.&lt;br /&gt;
return.&lt;br /&gt;
&lt;br /&gt;
33. 	What should you declare all instance fields as?&lt;br /&gt;
private.&lt;br /&gt;
&lt;br /&gt;
34. 	True or False, constructors contain instructions to initialize objects.&lt;br /&gt;
True.&lt;br /&gt;
&lt;br /&gt;
35. 	What are the two most commonly used number types in Java?&lt;br /&gt;
int and double.&lt;br /&gt;
&lt;br /&gt;
36. 	Where would you insert the following statement:&lt;br /&gt;
	public static final double CM_PER_INCH = 2.54;&lt;br /&gt;
Inside of a class.&lt;br /&gt;
&lt;br /&gt;
37. 	What is the meaning of the following statement?&lt;br /&gt;
	balance = balance + amount;&lt;br /&gt;
The statement adds the amount value to the balance value.&lt;br /&gt;
&lt;br /&gt;
38. 	What is a string?&lt;br /&gt;
A string is a sequence of characters. Strings are objects of the string class.&lt;br /&gt;
&lt;br /&gt;
39. 	String positions are counted starting with what number?&lt;br /&gt;
0.&lt;br /&gt;
&lt;br /&gt;
40. 	True or False, the if statement lets a program carry out different actions depending on a condition.&lt;br /&gt;
True.&lt;br /&gt;
&lt;br /&gt;
41. 	What is wrong with the following code:&lt;br /&gt;
	if(amount &amp;lt;= balance)&lt;br /&gt;
		newBalance = balance – amount; balance = newBalance;&lt;br /&gt;
Only the first statement is included inside the if statement. Braces must be used to include both.&lt;br /&gt;
&lt;br /&gt;
42. 	How do you express “Not equal” as a relational operator?&lt;br /&gt;
!=&lt;br /&gt;
&lt;br /&gt;
43. 	What is the value of s.length() if s is the string “ “ containing a space?&lt;br /&gt;
1.&lt;br /&gt;
&lt;br /&gt;
44. 	What is wrong with the following code:&lt;br /&gt;
	if(ch == ‘S’ || ‘M’) …&lt;br /&gt;
You need to write two Boolean expressions such as: if(ch == ‘S’ || ch == ‘M’) …&lt;br /&gt;
&lt;br /&gt;
45. 	When does the following statement print false?&lt;br /&gt;
	System.out.println(x &amp;gt; 0 || x &amp;lt; 0);&lt;br /&gt;
When x is zero.&lt;br /&gt;
&lt;br /&gt;
46. 	True or False, you cannot store the outcome of a condition in a Boolean variable.&lt;br /&gt;
False, you can store the outcome of a condition in a Boolean variable.&lt;br /&gt;
&lt;br /&gt;
47. 	What type of statement executes a block of code repeatedly and has a condition control how often the loop is executed?&lt;br /&gt;
A while statement.&lt;br /&gt;
&lt;br /&gt;
48. 	What is wrong with the following code:&lt;br /&gt;
	for(int i = 1; i &amp;lt;= years){&lt;br /&gt;
		if(balance &amp;gt;= targetBalance)&lt;br /&gt;
			i = years + 1;&lt;br /&gt;
		else{&lt;br /&gt;
			balance = balance * 2;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
You need to increment i in the for loop.&lt;br /&gt;
&lt;br /&gt;
49. 	Can loops be nested?&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
50. 	A table with rows and columns is a typical type of what kind of loop?&lt;br /&gt;
A nested loop.&lt;br /&gt;
&lt;br /&gt;
51. 	What is the Boolean operator for AND?&lt;br /&gt;
&amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
52. 	What is the result of the following code:&lt;br /&gt;
	String greeting = “Hello World”;&lt;br /&gt;
	int luckyNumber = 13;&lt;br /&gt;
	System.out.println(greeting + luckyNumber);&lt;br /&gt;
&lt;br /&gt;
53. 	What type of error is a violation of the rules of the programming language?&lt;br /&gt;
Syntax.&lt;br /&gt;
&lt;br /&gt;
54. 	True or False, a parameter is an input to a method.&lt;br /&gt;
True.&lt;br /&gt;
&lt;br /&gt;
55. 	True or False, the method value of a method is a result that the method has computed for use by the code that called it.&lt;br /&gt;
False. It is the return value.&lt;br /&gt;
&lt;br /&gt;
56. 	In Java, are numbers objects?&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
57. 	What does ‘API’ stand for?&lt;br /&gt;
Application Programming Interface.&lt;br /&gt;
&lt;br /&gt;
58. 	The constructor name is 		 the same as the class name.&lt;br /&gt;
Always.&lt;br /&gt;
&lt;br /&gt;
59. 	What type of coverage is a measure of how many parts of a program have been tested?&lt;br /&gt;
Test Coverage.&lt;br /&gt;
&lt;br /&gt;
60. 	What mathematical method is used to calculate the absolute value of a number?&lt;br /&gt;
Math.abs(x).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Llan3</name></author>
	</entry>
</feed>