Java Programming (3350703) MCQs

MCQs of Object Oriented Programming Concepts

Showing 31 to 35 out of 35 Questions
31.

Which of the following can be oveloaded?

(નીચે આપેલમાંથી કયો વિકલ્પ ઓવરલોડ થઈ શકે?)

(a)

method

(મેથડ)

(b)

constructor

(કન્શટ્રક્ટર)

(c)

Both method and constructor

(મેથડ અને કન્શટ્રક્ટર બંને)

(d)

None of given

(આપેલમાંથી એકપણ નહિ)

Answer:

Option (c)

32.

What is correct way to create constructor of following class? 

public class demo
{
}

નીચે આપેલ ક્લાસ નું કન્શટ્રક્ટર બનાવવા માટે કયો વિકલ્પ સાચો છે?

public class demo
{
}
(a)

demo(){ }

(b)

demo(void){}

(c)

public  demo(){}

(d)

 Both demo(){ } and public  demo(){}

demo(){ } અને public  demo(){} બંને

Answer:

Option (d)

33.

Which of following statement is ture about constructor?

(નીચે આપેલ સ્ટેટમેન્ટમાંથી કયું કન્શટ્રક્ટર માટે સાચું છે?)

(a)

Constructor name must be same as class name

(કન્શટ્રક્ટર નું નામ અને ક્લાસ નું નામ સરખા જ હોવા જોઈએ)

(b)

constructor does not have return type

(કન્શટ્રક્ટરને રીટર્ન ટાઈપ ન હોય)

(c)

constructor called automatically when we create object of it

(જયારે ઓબ્જેક્ટ બનાવવામાં આવે ત્યારે કન્શટ્રક્ટર ઓટોમેટીક કોલ થાય છે)

(d)

All of given

(આપેલ બધા)

Answer:

Option (d)

34.

State true or false: In method overloading, two methods with same number of parameter but differ in datatype is not allowed.

(આપેલ વિધાન સાચું છે કે ખોટું: મેથડ ઓવરલોડીંગમા બે મેથડમા પેરામીટરની સંખ્યા સરખી હોય પરંતુ ડેટાટાઈપ અલગ-અલગ હોય શકે છે.)

(a)

TRUE

(b)

FALSE

Answer:

Option (b)

35.

What will be the output of following program? 

class demo
{
   int a;
   demo(int a)
   {
      a=a;
   }
   public static void main(String args[])
   {
      demo   d = new   demo(5);
      System.out.println(d.a);     
   }
}

નીચે આપેલ કોડ નું આઉટપુટ શું આવશે?

class demo
{
   int a;
   demo(int a)
   {
      a=a;
   }
   public static void main(String args[])
   {
      demo   d = new   demo(5);
      System.out.println(d.a);     
   }
}
(a)

0

(b)

5

(c)

compilation error

કમ્પાઈલેશન એરર

(d)

runtime error

રનટાઈમ એરર

Answer:

Option (a)

Showing 31 to 35 out of 35 Questions