Java - Online Test - Static block - javasearch.buggybread.com


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'Static block' - 4 questions found


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

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

Which of the following can be marked static ?Core Java
Methods , Variables and Initialization Blocks.
Methods , Variables , Initialization Blocks and Outer Classes and nested Classes.
Methods , Variables , Initialization Blocks and Outer Classes.
Methods , Variables , Initialization Blocks and nested Classes.

  oops  java  static  nested classes  static nested classes

How can we execute a Java class independently if it doesn't have a static main method ?Core Java
By initiating the flow in any of the static method
By initiating the flow in any of static block
By initiating the flow in any other instance method named as main
By initiating the flow in any other instance method named as main and making it final

  main method  java







comments powered by Disqus