Friday, October 8, 2010

Eksekutif.Java

1.      What are the TWO different data types available in Java language?
  1. Primitive data type and built-in data type
  2. Primitive data type and reference data type
  3. Class type and reference data type
  4. Enumerated data type and reference data type
2.      How many different types are there in primitive data type?
a.   1                            b.   3                      c.   6                            d.   8

3.      Which of the following is NOT of integer type?
a.   byte                       b.   double             c.   int                          d.   long

4.      Which of the following is NOT a valid integer literal?
a.   1,500                     b.   888                  c.   +123                      d.   -456

5.      Which of the following is NOT a valid integer literal?
a.   12                          b.   -34.5                c.   +678L                    d.   -90

6.      Which of the following is NOT a valid floating-point literal?
a.   -98.7                      b.   +6.5                 c.   +4.3F                     d.   -2,001.0


7.      The _____ data type stores integer values in 8-bit signed locations from -128 to +127.
a.   long                       b.   char                 c.   byte                       d.   short

8.      Which of the following is NOT a valid Java identifier?
a.   formula1                b.   java                  c.   2ndPrize                d.   _NotCommon

9.      Which of the following is NOT a reserved word in Java?
a.   int                          b.   char                 c.   boolean                  d.   Struct

10.  Which of the following is a reserved word in Java?
a.   while                      b.   Public              c.   Repeat                   d.   Int

11.  How many standard arithmeticoperators are there in the Java programming language?
a.   four                       b.   five                  c.   eleven                    d.   fourteen

12.  Which of the following elements is NOT required in a variable declaration?
a.   A type                    b.   An identifier    c.   An assigned value  d.   A semicolon

13.  The location of a Java variable refers to
a.   a place in memory                               b.   a line number in a program
c.   a file name                                           d.   none of the above

14.  The symbol = in the Java programming language represents the
a.   equal operator                                      b.   assignment operator
c.   subtraction operator                             d.   none of the above

15.  To declare a variable with the name quantity for storing values of type 'int', we use the statement
a.   quantity int;                                        b.   int Quantity;         
c.   integer quantity;                                d.   int quantity;

16.  To declare an 'int' variable named num with an initial value 99, you write
a.   int num = "99";                                    b.   int num = 99;
c.   99 = num int;                                       d.   int num = ninety nine;

17.  The data type for the variable number shown below is most likely to be _____.
_____ number = 12.5;
a.   int                          b.   float                 c.   double                   d.   none of the above

18.  Which of the following assignment statements is NOT legal assuming num1 and num2 are declared as 'int'?
a.   num1 = num2;                                     b.     num1 = num2 + 10;
c.   num1 = num1 + num2;                        d.     num1 + 10 = num2;


19.  Which of the following Java expressions correctly represents the algebraic expression: ?
a.   1 + a/b*b            b.   1 + a/(b*b)          c.   (1 + a)/(b*b)          d.   1 + a/b^2

20.  Consider the following fragament of code:
int x = 5;
int y =10;
y = x;
What are the values of x and y?
a.   x is 5 and y is 10     b.   x is 10 and y is 5     c.   x is 5 and y is 5     d.   x is 10 and y is 10

21.  What is the answer for 9 / 5?
a.   1                         b.   1.0                      c.   1.8                         d.   4

22.  What is the answer for 14 % 4?
a.   2                         b.   2.0                      c.   3.5                         d.   10

23.  The diagram on the right shows how the integer literal 5 assigned to the variable named num is being stored in the computer’s main memory. What is the most appropriate data type for num?
  1. byte
  2. short
  3. int
  4. long




24.  The diagram on the right shows how the integer literal 5 assigned to the variable named num is being stored in the computer’s main memory. What is the most appropriate data type for num?
  1. byte
  2. short
  3. int
  4. long




25.  The difference between the types int and byte is
a.       int can hold both integer and floating point numbers
b.      int can hold larger integer numbers than byte
c.       byte can hold smaller integer numbers than int
d.      int can hold only floating numbers

26.  The literal value 1.5f
  1. is a single-precision floating-point number (float)
  2. is a double-precision floating-point number (double)
  3. is a String value
  4. is not a valid literal value of any type in Java
27.  In Java the variables price and PRICE
a.   are the same           b.   may be the same or different depending on what computer you use
c.   are different           d.   are not allowed as variable names

28.  Which of the following assignment statements is illegal?
a.   byte one = -34;   b.   long two = 56;               c.   short three = 1;           d.   int ten = 10.0;

29.  What is the value of the following expression: 5 + 6 / 4 - 3?
a.   -0.25                      b.   3                      c.   3.5                         d.   11

30.  What is the value of the following expression: (5 + 6)/4 - 3?
a.   -1                           b.   -0.25                c.   3                            d.   11

31.  Write Java statements for the following:
a.   p = 2(q + r)                  b.   x = y2 + z2                        c.   p = m2 + (n - 1)2
d.                      










e.                          










f.   



32.  Fill in the arithmetic operator (either +, -, /, * or %) so that both sides of the equations evaluate to the same answer. List TWO possibilities for each equation, as shown in the example:
7  6  1 = 8  4

Solution: (a)  7 - 6 -1 = 8 % 4     or            7 % 6 - 1 = 8 % 4

                     (b)  7 / 6 +1= 8 / 4 or    7 - 6 + 1 = 8 / 4
NOTE: In Java, integer division always results in an integer answer. The decimal part is truncated.
a)      6  5 = 7  4
b)      5  3  2 = 2  5
c)      11  3  4 = 6  2
d)      9  4  1 = 21  2  12
e)      7  5  1 = 11  2

No comments:

Post a Comment