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


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'Static' - 14 questions found


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

Which of the following cannot be marked static ?Core Java
Constructors , Classes ( Outer ) , Classes ( nested ), Interfaces , Local variables , Inner Class methods and instance variables.
Constructors , Classes ( Outer ) , Interfaces , Local variables , Class variables , Class Methods , Inner Class methods and instance variables.
Constructors , Classes ( Outer ) , Interfaces , Local variables , Inner Class methods and instance variables.
Constructors , Classes ( Outer ) , Classes (Nested), Interfaces , Local variables , Inner Class methods and instance variables.

  oops  java  static  nested classes  static nested classes

Which of the following is not the difference between Singleton and Static class ( Class with static members only ) ?Core Java
Only one object can be created for Singleton class whereas No objects are created for static class.
Singleton class instance is initiated using new keyword whereas static class instance is created using static method.
Singleton class can be serialized whereas Static class cannot be.
Singleton Class can participate in runtime Polymorphism whereas Static class cannot.

  java  oops  singleton  design pattern  static class

Which of the following do you think is the primary reason you would never use a static class even the application doesn't need multiple requests or threads ?Core Java
Serialization
Runtime Polymorphism
Lazy Loading
Memory

  static class  static vs singleton  java  oops  objects

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 is not true for static keyword ?Core Java
Static members are shared by all objects of the class.
We can override static methods.
Static methods operate on static variables only.
Static Elements are accessed using class name.

  static

Static Polymorphic in Java is achieved through .. Core Java
Method Overloading
Method Overriding
Variable Overloading
Variable Overriding

  polymorphism  static polymorphism

Which of the following was not introduced with Java 5 ?Core Java
Generics
Strings within Switch
Enums
Annotations

  java  java5

Which of the following is true ?Core Java
We can serialize static variables
We can serialize transient variables
We can serialize final variables
We can serialize instance methods

  serialization  java  file io

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

Which of the following can be overridden ?Core Java
final instance methods
final static methods
non final instance methods
non final static methods

  overriding

Which of following are serialized ?Core Java
static variables
transient variables
instance variables
method local variables

  serialization

Which of following can be nested into another ?Core Java
class within another class
class within interface
interface within class
All of above

  nested classes   nested interface  inner classes







comments powered by Disqus