Similar Collections


    No collections found

questions

Title
Which of these keywords is used to define packages in Java

Which of these keywords is used to define packages in Java?


  1. pkg
  2. Pkg
  3. package
  4. Package
discuss
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package

Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?


  1. Public
  2. Protected
  3. No Modifier
  4. All of the mentioned
discuss
Which of these access specifiers can be used for a class so that its members can be accessed by a different class in the different package

Which of these access specifiers can be used for a class so that its members can be accessed by a different class in the different package?


  1. Public
  2. Protected
  3. Private
  4. No Modifier
discuss
Which of the following is the correct way of importing an entire package ‘pkg’

Which of the following is the correct way of importing an entire package ‘pkg’?


  1. import pkg.
  2. Import pkg.
  3. import pkg.*
  4. Import pkg.*
discuss
Which of the following is an incorrect statement about packages

Which of the following is an incorrect statement about packages?


  1. Package defines a namespace in which classes are stored
  2. A package can contain other package within it
  3. Java uses file system directories to store packages
  4. A package can be renamed without renaming the directory in which the classes are stored
discuss
Which of the following package stores all the standard java classes

Which of the following package stores all the standard java classes?


  1. lang
  2. java
  3. util
  4. java.packages
discuss
What is the output of this program

What is the output of this program?

Note : packages.class file is in directory pkg;

    package pkg;
    class display 
    {
        int x;
        void show() 
        {
            if (x > 1)
                System.out.print(x + " ");
        }
    }
    class packages 
    {
        public static void main(String args[]) 
        {
            display[] arr=new display[3];
            for(int i=0;i<3;i++)
                arr[i]=new display();
            arr[0].x = 0;      
            arr[1].x = 1;
            arr[2].x = 2;
            for (int i = 0; i < 3; ++i)
                arr[i].show();
         }
    }

  1. 0
  2. 1
  3. 2
  4. 0 1 2
discuss
What is the output of this program

What is the output of this program?

    package pkg;
    class output 
    {
        public static void main(String args[])
        { 
            StringBuffer s1 = new StringBuffer("Hello");
            s1.setCharAt(1, x);
            System.out.println(s1);
        }
    }

  1. xello
  2. xxxxx
  3. Hxllo
  4. Hexlo
discuss
What is the output of this program

What is the output of this program?

Note : Output.class file is not in directory pkg.

   package pkg;
    class output 
    {
        public static void main(String args[])
        {
            StringBuffer s1 = new StringBuffer("Hello World");
            s1.insert(6 , "Good ");
            System.out.println(s1);
        }
   }

  1. HelloGoodWorld
  2. HellGoodoWorld
  3. Compilation error
  4. Runtime error
discuss
Which of these keywords is used to define interfaces in Java

Which of these keywords is used to define interfaces in Java?


  1. interface
  2. Interface
  3. intf
  4. Intf
discuss
Which of these access specifiers can be used for an interface

Which of these access specifiers can be used for an interface?


  1. Public
  2. Protected
  3. private
  4. All of the mentioned
discuss
Which of these keywords is used by a class to use an interface defined previously

Which of these keywords is used by a class to use an interface defined previously?


  1. import
  2. Import
  3. implements
  4. Implements
discuss
Which of the following is the correct way of implementing an interface salary by class manager

Which of the following is the correct way of implementing an interface salary by class manager?


  1. class manager extends salary {}
  2. class manager implements salary {}
  3. class manager imports salary {}
  4. none of the mentioned
discuss
What is the output of this program

What is the output of this program

    interface calculate
    {
        void cal(int item);
    }
    class display implements calculate
    {
        int x;
        public void cal(int item)
        {
            x = item * item;            
        }
    }
    class interfaces
    {
        public static void main(String args[])
        {
            display arr = new display;
            arr.x = 0;      
            arr.cal(2);
            System.out.print(arr.x);
        }
    }

  1. 0
  2. 2
  3. 4
  4. None of the mentioned
discuss
What is the output of this program

What is the output of this program

    interface calculate
    {
        void cal(int item);
    }
    class displayA implements calculate
    {
        int x;
        public void cal(int item)
        {
            x = item * item;            
        }
    }
    class displayB implements calculate
    {
        int x;
        public void cal(int item)
        {
            x = item / item;            
        }
    }
    class interfaces 
    {
        public static void main(String args[])
        {
            displayA arr1 = new displayA;
            displayB arr2 = new displayB;
            arr1.x = 0;
            arr2.x = 0;      
            arr1.cal(2);
            arr2.cal(2);
            System.out.print(arr1.x + " " + arr2.x);
        }
    

  1. 0 0
  2. 2 2
  3. 4 1
  4. 1 4
discuss
What is the output of this program

What is the output of this program?

interface calculate 
{
            int VAR = 0;
            void cal(int item);
}
        class display implements calculate 
        {
            int x;
          public  void cal(int item)
          {
                if (item<2)
                    x = VAR;
                else
                    x = item * item;            
            }
        }
 class interfaces 
{
 
            public static void main(String args[]) 
            {
                display[] arr=new display[3];
 
               for(int i=0;i<3;i++)
               arr[i]=new display();
               arr[0].cal(0);    
               arr[1].cal(1);
               arr[2].cal(2);
               System.out.print(arr[0].x+" " + arr[1].x + " " + arr[2].x);
            }
}

  1. 0 1 2
  2. 0 2 4
  3. 0 0 4
  4. 0 1 4
discuss
Which of the following access specifiers can be used for an interface

Which of the following access specifiers can be used for an interface?


  1. Protected
  2. Private
  3. Public
  4. Public, protected, private
discuss
Which of the following is the correct way of implementing an interface A by class B

Which of the following is the correct way of implementing an interface A by class B?


  1. class B extends A{}
  2. class B implements A{}
  3. class B imports A{}
  4. None of the mentioned
discuss
All methods must be implemented of an interface

All methods must be implemented of an interface.


  1. True
  2. False
discuss
What type of variable can be defined in an interface

What type of variable can be defined in an interface?


  1. public static
  2. private final
  3. public final
  4. static final
discuss
total MCQs: 111

MCQs

111

Views

155

Best Answers

299

Points

5