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


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'Method' - 12 questions found


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 is false about main method ?Core Java
It should be declared public and static
it should have only 1 argument of type String array
We can override main method
We can overload main method

  java  main method

Which of the following is false ?Core Java
A Class cannot override both hashcode and equals method.
A class can override both hashcode and equals method.
A Class must override hashCode method if its overridding equal method.
A Class can override hashCode even if its not overridding equals method.

  hascode  equals method  overridding hashcode and equals method

Which of the following is not true for abstract classes ?Core Java
Abstract Class is only meant to be sub classed and not supposed to be instantiated.
Abstract class handlers can be used to handle derived class objects.
We can't have an abstract class without abstract methods.
Abstract class has member elements.

  abstract class  abstract methods

Which of the following keyword is expected with main method declaration ?Core Java
Final
Static
Volatile
Transient

  main method

Which of following about main method is not true ?Core Java
We can have multiple methods named main in a class
We can have var args with the main method
We can overload main method
We can override main method

  main method

Other name for setter methods is .. Core Java
Getter Methods
Redefinition Methods
Final methods
Mutator methods

  methods

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 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 of the following can be overridden ?Core Java
final instance methods
final static methods
non final instance methods
non final static methods

  overriding

What is the problem with following code ?

public class Car extends Vehicle{
   int x;

   void Car(int y){
      x = 5;
   }

   void Car(){
      this(5);
   }
}
Core Java
We cannot use this() within normal method
We cannot chain methods
We cannot overload constructors
We cannot use return type void with overloaded methods

  constructor







comments powered by Disqus