Java - Online Test - Access specifier -


Search Java Test Questions

 223 test questions in repository.

Java - Test Questions on 'Access specifier' - 5 questions found

Which access specifiers can be used with top level class ?Core Java
public or default
public or private
public or protected
protected or default

  access specifier  oops  java  class

Overridden methods must have the same ... Core Java
name and argument list
name, argument list, and return type
name, argument list, return type and belong to the same class

  java  overriding

How can we create objects if we make the constructor private ?Core Java
We can't create objects if constructor is private
We can only create objects if we follow singleton pattern
We can only create one object
We can create new object through static method or static block

  constructor   private constructor

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


What will be the output of following code ?

public class BuggyBread {

   private int x;
   private Integer y;

   private BuggyBread(int x,int y){};

   public static void main(String[] args){
      BuggyBread buggybread = new BuggyBread(1,2);
Core Java
compilation error due to private constructor
compilation error due to uninitialized elements
0 null
0 0


comments powered by Disqus