Java - Online Test - Final - javasearch.buggybread.com


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'Final' - 10 questions found


Which of the following is not possible ?Core Java
try block followed by catch
try block followed by finally
try block followed by catch block and then finally
try block without catch or finally block

  exceptions  java  try-catch  finally

Which of the following is wrong for final instance variables ?Core Java
They cannot be changed after initialization
They can be initialized directly within static method
They can be declared and initialized together at the same place
They can be initialized within constructor

  java  final  final variable  java keywords

Which of the following is false for final ?Core Java
Final methods cannot be overriden
Final methods cannot be overloaded
Final classes cannot be subclassed
Final class cannot be abstract

  java  final  java keyword

Which keyword specify that a variable is effectively final ?Core Java
final
No Keyword
Both of the above
None of the above

  java  java 8  java8  final  effectively final

Which of the following methods are used by Java Garbage Collection Mechanism ?Core Java
final
finally
finalize
All of the above

  garbage collection  finalize

In which case finally won't get executed ?Core Java
in case of exception
in case of normal execution
in case of return statement before end of try block
in case of force program termination

  finally

Which of the following class cannot be extended or inherited ?

StringBuffer , StringBuilder
Core Java
StringBuffer
StringBuilder
Both cannot be extended
Both can be extended

  final classes  StringBuffer  StringBuilder

What will be the output upon executing following class ?

public class BuggyBread {

static {
System.out.println("Static Block");
}

{
System.out.println("Instance Initialization Block");
}

BuggyBread(){
System.out.println("Constructor");
}

public static void main(String[] args){
System.out.println("Main Method");
new BuggyBread();
}
}
Core Java
Instance Initialization Block
Constructor
Static Block
Main Method
Static Block
Instance Initialization Block
Constructor
Main Method
Main Method
Static Block
Instance Initialization Block
Constructor
Static Block
Main Method
Instance Initialization Block
Constructor

  static block  Instance Initialization Block

What will be the output of executing following class ?

public class BuggyBread {

static {
System.out.println("Static Block");
}

{
System.out.println("Initialization Block");
}

BuggyBread(){
System.out.println("Constructor");
}

public static void main(String[] args){
System.out.println("Main Method");
}
}
Core Java
Static Block
Main Method
Static Block
Instance Initialization Block
Main Method
Static Block
Constructor
Main Method
Static Block
Instance Initialization Block
Constructor
Main Method

  static block  Instance Initialization Block

Which of the following about Garbage collection is false ?Core Java
We can call Garbage collection explicitly
Garbage Collection guarantees that the application will not run out of memory
finalize method is used by Java for Garbage Collection
Garbage Collection Mechanism delete unclaimed objects that are no longer required

  garbage collection







comments powered by Disqus