Assignment Questions for Introduction Computer Programming | CSC 3405, Assignments of Computer Science

Material Type: Assignment; Professor: Wei; Class: Intro Computer Programming; Subject: Computer Science; University: Saint Joseph's University; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-g8s-1
koofers-user-g8s-1 🇺🇸

10 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 1
Getting Started
 Multiple ChoiceMultiple Choice
1) Java is an object-oriented programming language. An object-oriented language
(a) Uses structured programming.
(b) Views a program as consisting of objects which communicate through interactions.
(c) Functionally breaks down problems into smaller, more manageable problems.
(d) All of the above.
2) In Java, the equal sign is used as the ___________ operator.
(a) increment
(b) decrement
(c) assignment
(d) negation
3) In Java, source code is compiled into object code called ______________.
(a) Bit-code
(b) Class code
(c) Method code
(d) Byte-code
1
pf3
pf4
pf5
pf8

Partial preview of the text

Download Assignment Questions for Introduction Computer Programming | CSC 3405 and more Assignments Computer Science in PDF only on Docsity!

Chapter 1

Getting Started

 Multiple Choice

  1. Java is an object-oriented programming language. An object-oriented language (a) Uses structured programming. (b) Views a program as consisting of objects which communicate through interactions. (c) Functionally breaks down problems into smaller, more manageable problems. (d) All of the above.
  2. In Java, the equal sign is used as the ___________ operator. (a) increment (b) decrement (c) assignment (d) negation
  3. In Java, source code is compiled into object code called ______________. (a) Bit-code (b) Class code (c) Method code (d) Byte-code 1
  1. The hardest kind of error to detect in a computer program is a: (a) Syntax error (b) Run-time error (c) Logic error (d) All of the above
  2. Identify the invalid Java identifier. (a) 1Week (b) Week (c) amountDue (d) amount_due
  3. What is the value of the variable amountDue? double price = 2.50; double quantity = 5; double amountDue = 0; amountDue = price * quantity; (a) 12 (b) 12. (c) 12.

(a) 28 (b) 27 (c) 26 (d) None of the above.

  1. Which operator is used to concatenate two strings? (a) + (b) – (c) * (d) /
  2. Which operator returns the remainder of integer division? (a) % (b) / (c) * (d) none of the above
  3. What is the value of the variable c in the statements that follow? String phrase = "Make hay while the sun is shining."; char c = phrase.charAt(10); (a) w

5 (b) h (c) i (d) None of the above

  1. The escape sequence the represents the new-line character is: (a) \r (b) \t (c) \n (d) \
  2. The syntax that declares a Java named constant named SALES_TAX is: (a) double SALES_TAX = 7.50; (b) public double SALES_TAX = 7.50; (c) public static double SALES_TAX = 7.50; (d) public static final double SALES_TAX = 7.50;
  3. In Java, a block comment is delimited by: (a) / / (b) /* /* (c) /* */ (d) */ */
  4. To mark a block comment for inclusion in the Javadoc documentation, the block must be delimited by: (a) /** */ (b) / */

7 c = c + 2 * a; d = d - b / c; c = c * b % c; b = b / 2;

  1. Explain the difference between an implicit type cast and an explicit type cast.
  2. What is the output produced by the following lines of code? int value1 = 3; int value2 = 4; int result = 0; result = value1++ * value2--; System.out.println("Post increment/decrement: " + result); result = ++value1 * --value2; System.out.println("Pre increment/decrement: " + result);
  3. Define the terms class, object, method and method call.
  4. What does the String method trim() do? Give an example of its use.
  5. What is the output of the following Java statements? //String method examples String str = "Java Programming!"; System.out.println(str.equals("Java Programming!")); System.out.println(str.toLowerCase()); System.out.println(str.toUpperCase());

System.out.println(str.substring(5,8)); System.out.println(str.lastIndexOf("m"));

  1. Write a Java statement to access the 7th^ character in the String variable myString and place it in the char variable c.
  2. Write a Java statement to determine the length of a string variable called input. Store the result in an integer variable called strLength.
  3. Why is using named constants a good programming practice?
  4. How are line comments and block comments used?