(Blank)
(Blank)
Java Array
String Handling
Control statements
100

Which of the following is not java keyword?

1. static

2. try

3. Integer

4. new


Integer

100

True or False: A variable name can start with a number or special character.

a) True
b) False


a) True

100

Which of the following keywords do you HAVE to use to create a new Object?
a) static
b) void
c) new
d) public

c) new

100

Which of these operators can be used to combine (concatenate) two or more String objects?
a) +
b) +=
c) &
d) ||

a)+

100

True or False: The while loop repeats a set of code while the condition is not met.
a) True
b) False

a) True

200

Choose the appropriate data type for this value: 5.5

a) double
b) String
c) int
d) char

a) double

200

FREE POINTS!

200

Which of these is a correct array declaration?
a) []int arr = new int[5];
b) int[] arr = new int[5];
c) arr int[] = new int[5];
d) int arr[] = int [5] new;
e) int arr[] = new int[];

b) int[] arr = new int [5];

200

Which of this method of the Array class that is used to obtain the size of an array?
a) size()
b) size
c) length
d) length()

c) length

200

What is true about a break?
a) Break stops the execution of entire program
b) Break halts the execution and forces the control out of the loop
c) Break forces the control out of the loop and starts the execution of next iteration
d) Break halts the execution of the loop for certain time frame

b) Break halts the execution and forces the control out of the loop

300

Two of the following statements are true, and one is false. Identify the false statement and explain why it is false.
a) Any class can contain an unlimited number of methods.        
b) During one program execution, a method might be called any number of times.        
c) A method is usually written within another method.

c

300

True or False: Can you use the == operator to check if two String variables are the same?

a) True
b) False

b) False

300

 What will be the output of the following Java code?

int arr[] = new int [5];
for (int i = 0; i < arr.length; i++) {
     System.out.print((i * 6 + 1) + " ");
}

a) 1 2 3 4 5
b) 0 6 12 18 24
c) 1 7 13 19 25
d) 06121824

c) 1 7 13 19 25

300

Identify the false statement and explain why it is false.
a) Summing a double, int, and float results in a double.        
b) You can explicitly override the unifying type imposed by Java by performing a type cast; type casting forces a value of one data type to be used as a value of another type.        
c) When you perform arithmetic operations with operands of unlike types, you must make an explicit conversion to a unifying type.

c) charAt()

300

Fill in the blank: 

public static ____ number() {
   return 3;
}

a) void
b) int
c) return
d) String

b) int

400

What is the default value of int variable?

a) -1
b) 0.0
c) 0
d) 1

0

400

When Overloading does not occur?
a) More than one method with same name but different method signature and different number or type of parameters
b) More than one method with same name, same signature but different number of signature
c) More than one method with same name, same signature, same number of parameters but different type
d) More than one method with same name, same number of parameters and type but different signature

D) More than one method with same name, same number of parameters and type but different signature

400

Which of these is necessary to specify at time of array initialization?
a) size
b) columns
c)
d) None of the mentioned

a) Row

400

FREE POINTS!

400

What is missing?

public class example
   public void main(String[] args) {
      System.out.println("Hello");
   }
}

a) println
b) int()
c) static
d) String

c) static

500

What is instance variable?

A - Instance variables are static variables within a class but outside any method.

B - Instance variables are variables defined inside methods, constructors or blocks.

C - Instance variables are variables within a class but outside any method.

D - None of the above.

Instance variables are variables within a class but outside any method.

500

What is it called where child object gets killed if parent object is killed?
a) Aggregation
b) Composition
c) Encapsulation
d) Association

b) Composition

500

What will be the output of the following Java code?

public static void main(String args[]) {
    array variable [] = new int[10];
    for (int i = 0; i < 10; ++i) {  
           variable[i] = i;
           System.out.print(array_variable[i] + " ");                i++;
    }
}

a) 0 2 4 6 8
b) 1 3 5 7 9
c) 0 1 2 3 4 5 6 7 8 9
d) syntax error

d) syntax error

500

What will be the output of the following Java program?

    class String_demo 

    {

        public static void main(String args[])

        {

            char chars[] = {'a', 'b', 'c'};

            String s = new String(chars);

            System.out.println(s);

        }

   }

a) a
b) b
c) c
d) abc

d) abc

500

Which of the following statements is true?

a) Single line comments start with two forward slashes ( // ) and end with two backslashes ( \\ ); they can extend across as many lines as needed.        
b) Javadoc comments begin with a forward slash and two asterisks ( /** ) and end with an asterisk and a forward slash ( */ ); they are used to generate documentation with a program named javadoc.        

c) Block comments start with a forward slash and an asterisk ( /* ) and end with an asterisk and a forward slash ( */ ); they can extend across as many lines as needed.        

c

M
e
n
u