Java Programming Fundamentals

Test your knowledge of core Java concepts including arrays, strings, exceptions, collections, garbage collection, and server-side development

17 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Java enabled portable server-side applications are

  1. Web services
  2. Enterprise JavaBeans
  3. Java Servlets
  4. All the above
Question 2 Multiple Choice (Single Answer)

What will be the output ?

  1. Inside TRY Inside FINALLY
  2. Inside TRY
  3. Inside TRY Inside CATCH Inside FINALLY
  4. None of the above
Question 3 Multiple Choice (Single Answer)

Guess the output ?

  1. 6
  2. 33
  3. 123
  4. Exception
Question 4 Multiple Choice (Single Answer)

Guess the output :

  1. 15
  2. 123
  3. 6
  4. Exception
Question 5 True/False

Can inner class have static members?

  1. True
  2. False
Question 6 Multiple Choice (Single Answer)

Which one is faster in java ?

  1. No difference
  2. 1
  3. 2
  4. Cannot be determined
Question 7 Multiple Choice (Single Answer)

After the following code fragment, what is the value in a? String s; int a; s = "Foolish boy."; a = s.indexOf("fool");

  1. -1
  2. 0
  3. 4
  4. none
Question 8 Multiple Choice (Single Answer)

Given the following code fragment: int A[]; int i = 0; A = new int A[4]; while (i < 4) { A[i] = 10; i = i + 1; } What is the value of A[3]?

  1. 0
  2. 3
  3. 10
  4. Compile Error
Question 9 Multiple Choice (Single Answer)

What is the purpose of this bit of code void init() { ... } ?

  1. a class that initializes the applet
  2. A required method in an applet
  3. A place to declare variablesA place to declare variables
  4. none of the above
Question 10 Multiple Choice (Single Answer)

What is the value of k after the following code fragment? int k = 0; int n = 12 while (k < n) { k = k + 1; }

  1. 0
  2. 11
  3. 12
  4. -1
Question 11 Multiple Choice (Single Answer)

If you have reference variable of parent class type and you assign a child class object to that variable and invoke static method. Which method will be invoked? Parent/Child.

  1. Parent
  2. Child
  3. Both
  4. None of these
Question 12 True/False

Can we declare derived class first and then base class in java?

  1. True
  2. False
Question 13 True/False

Is Array operations are faster than Vector.

  1. True
  2. False
Question 14 True/False

Final variables declared without initialization can be initialized in static initializer ( static final var) or in constructor( final var). True/False?

  1. True
  2. False
Question 15 True/False

Is the following statement correct: char ch = 'd'; if(ch < 32.00){ }

  1. True
  2. False
Question 16 True/False

If there is an exception in finalize method, will the object be garbage collected?

  1. True
  2. False
Question 17 Multiple Choice (Single Answer)

Which one of these statements are valid? Char \u0061r a =’a’; Char \u0062 = ’b’; Char c =’\u0063’Which one is not correct A. x = = Float.NaN B. Float.isNan(x); C. Myobject .equals(float.NaN);

  1. A
  2. B
  3. C
  4. All