B. slipstream stream C. stream slip stream D. slipstream slip stream 1. What will be the output of the program? LANGUAGE FUNDAMENTALS - GENERAL class PassA { QUESTIONS public static void main(String [] args) 4. Which four options describe the correct default { PassA p = new PassA(); values for array elements of the types indicated? p.start(); } 1. int -> 0 void start() 2. String -> "null" { long [] a1 = {3,4,5}; long [] a2 = fix(a1); 3. Dog -> null System.out.print(a1[0] + a1[1] + a1[2] + " "); System.out.println(a2[0] + a2[1] + a2[2]); 4. char -> '\u0000' } 5. float -> 0.0f long [] fix(long [] a3) { 6. boolean -> true a3[1] = 7; return a3; } A. 1, 2, 3, 4 } B. 1, 3, 4, 5 A. 12 15 C. 2, 4, 5, 6 B. 15 15 D. 3, 4, 5, 6 C. 345375 D. 375375 5. Which one of these lists contains only Java programming language keywords? 2. What will be the output of the program? A. class, if, void, long, Int, continue class Test B. goto, instanceof, native, finally, default, throws { C. try, virtual, throw, final, volatile, transient public static void main(String [] args) D. strictfp, constant, super, implements, do { Test p = new Test(); E. byte, break, assert, switch, include p.start(); } 6. Which is a reserved word in the Java programming void start() language? { boolean b1 = false; boolean b2 = fix(b1); A. method System.out.println(b1 + " " + b2); B. native } C. subclasses boolean fix(boolean b1) D. reference { E. array b1 = true; return b1; } 7. Which is a valid keyword in java? }
A. true true A. interface
B. false true B. string C. true false C. Float D. false false D. unsigned
3. What will be the output of the program? FLOW CONTROL - GENERAL QUESTIONS
class PassS switch(x)
{ public static void main(String [] args) { { default: PassS p = new PassS(); p.start(); System.out.println("Hello"); } } void start() { String s1 = "slip"; String s2 = fix(s1); System.out.println(s1 + " " + s2); 8. Which two are acceptable types for x? } String fix(String s1) 1. byte { s1 = s1 + "stream"; 2. long System.out.print(s1 + " "); return "stream"; 3. char } } 4. float 5. Which of the following is NOT the name of a Java primitive data type? public class While a. int { b. float public void loop() { c. double int x= 0; d. String while ( 1 ) /* Line 6 */ { 6. Is the value ONE always going to be represented by System.out.print("x plus one is using the same pattern of bits? " + (x + 1)); /* Line 8 */ } } a. Yes---there is only one "one" so there will } be just one pattern. b. No---"one" can be represented using several 9. Which statement is true? integer data types or floating point data types. A. There is a syntax error on line 1. c. Yes---it will always be stored in one bit. B. There are syntax errors on lines 1 and 6. d. No---the pattern will change each time the C. There are syntax errors on lines 1, 6, and 8. program is run. D. There is a syntax error on line 6. 7. Say that a particular item of data does NOT use a 10. Modulus operator, %, can be applied to which of primitive data type. What must it be? these? a) Integers a. An object. b) Floating – point numbers b. A number. c) Both Integers and floating – point numbers c. A literal. d) None of the mentioned d. A boolean. 8. How many places of decimal precision are there in the following number: +1200004.5 THE BASICS a. 4 1. What is a data type? b. 5 c. 8 a. The part of the CPU that does arithmetic. d. More than a million b. A part of main memory used to store data. c. A particular scheme for represending values 9. Can character data be stored in computer memory? with bit patterns. d. The collection of variables that a program a. No---computers can only store numbers. uses. b. No---computer memory can only store patterns. 2. How many patterns can be created using a single c. Yes---characters are stored in special bit? memory. d. Yes---a primitive data type is used to store a. 1 characters. b. 2 c. 4 10. In which of the following answers does the d. 8 number of bits increase from fewest (on the left) to most (on the right)? 3. What is a Java primitive data type? a. byte long short int a. A method for representing values that is so b. int byte short long useful that it is a fundamental part of the c. byte short int long language. d. short byte long int b. A crude form of representing numbers. c. The part of Java that is the same as in older languages. d. A data type that cannot be used as part of an object.
4. Does every Java variable use a data type?
a. No---only numeric variables use data types.
b. No---data types are optional. c. Yes---all variables are of the same data type. d. Yes---each variable must be declared along with its data type.