PYTHON
C
C++
JAVA
100

x=10 

for i in range(x):    

     if x==5:        

         break        

         print("H")

print(x)

  10

100

Differentiate between Actual Parameters and Formal Parameters.

The Parameters which are sent from main function to the subdivided function are called as Actual Parameters and the parameters which are declared a the Subdivided function end are called as Formal Parameters.

100

What do you mean by call by value and call by reference?

In call by value method, we pass a copy of the parameter is passed to the functions. For these copied values a new memory is assigned and changes made to these values do not reflect the variable in the main function.


In call by reference method, we pass the address of the variable and the address is used to access the actual argument used in the function call. So changes made in the parameter alter the passing argument.


100

What are the Memory Allocations available in Java?Name any 3.

  • Class Memory
  • Heap Memory
  • Stack Memory
  • Program Counter-Memory
  • Native Method Stack Memory
300

def outer_fun(a, b):

    def inner_fun(c, d):

        return c + d

    return inner_fun(a, b)
 res = outer_fun(5, 10)
print(res)

15

300

void change(int,int);  

int main()  

{  

    int a=25,b=50;  

    change(a,b); 

    printf("The value assigned to a is: %d",a);  

    printf("n");  

    printf("The value assigned to of b is: %d",b);  

    return 0;  

}  

void change(int x,int y)  

{  

    x=100;  

    y=200;  

}

The value assigned to of a is: 25
The value assigned to of b is: 50

300

What will be the value of x in the following C++ program


#include<iostream>

using namespace std;

int main(){

     int a=1;

     int x=(a++)++;

     cout<<x<<endl;

     return 0;

}

1)Compile Time Error

2)3

3)1

4)2


2

300

public class Demo{

      public static void main(String[] arr){

                   Integer num1 = 100;

                   Integer num2 = 100;

                   Integer num3 = 500;

                   Integer num4 = 500;


                   if(num1==num2){

                            System.out.println("num1 == num2");

                    }

                    else{

                           System.out.println("num1 != num2");

                   }

                   if(num3 == num4){

                             System.out.println("num3 == num4");

                   }

                   else{

                           System.out.println("num3 != num4");

                    }

           }

num1 == num2
num3 != num4

500

class A:

    def __init__(self):

        self.calcI(30)

    def calcI(self, i):

        self.i = 2 * i
class B(A):

    def __init__(self):

        super().__init__()

        print("i from B is", self.i)

    def calcI(self, i):

        self.i = 3 * i
b = B()


A. The __init__ method of only class B gets invoked.
B. The __init__ method of class A gets invoked and it displays “i from B is 0”.
C. The __init__ method of class A gets invoked and it displays “i from B is 60”.
D. The __init__ method of class A gets invoked and it displays “i from B is 90”

D. The __init__ method of class A gets invoked and it displays “i from B is 90”

500

#include <stdio.h>
int main()
{
    int a=10,b=20,*p,s=0;
         p = &a;
    a++;
    (*p)++;
    s = a + b + *p;
         printf("%d\n",s);
    return 0;
}

44

500

#include<iostream>

using namespace std;

int &fun() {

  static int a = 10;

  return a;

}

 

int main() {

  int &y = fun();

  y = y +30;

  cout<<fun();

  return 0;

}


40

500

class Boo

{

    Boo(String s) { }

    Boo() { }

}

class Bar extends Boo

{

    Bar() { }

    Bar(String s) {super(s);}

    void zoo()

    {

    // insert code here

    }

}

which one create an anonymous inner class from within class Bar?

A. Boo f = new Boo(24) { };

B. Boo f = new Bar() { };

C. Bar f = new Boo(String s) { };

D. Boo f = new Boo.Bar(String s) { };


 B. Boo f = new Bar() { };

1000

class xyz:

    def__init__(self): 

       print("hey, I am initialized , xyz")

    def sub_xyz(self,b):

      print("Printing from class xyz:",b) 

class xyz1(xyz):

   def __init__(self):

     print("hey, I am initialized, xyz1")

     super().__init__()

   def sub_xyz(self,b):

     print("Printing from class xyz1:", b)

     super().sub_xyz(b+1) 

class xyz2(xyz1):

   def __init__(self):

     print("hey, I am initialized, xyz2")

     super().__init__()

   def sub_xyz(self,b):

     print("Printing from class xyz2:",b)

     super().sub_xyz(b+1)

if __name__ == '__main__':

   ob =xyz2()

   ob.sub_xyz(10)

 

hey, I am initialized , xyz2

hey, I am initialized , xyz1

hey, I am initialized , xyz

Printing from class xyz2:10

Printing from class xyz1:11

Printing from class xyz: 12

1000

FIND THE ERROR IN THE CODE AND FIND THE OUTPUT OF THE PROGRAM


#include int main(){

static int i;

 for(++i;++i;++i) {

 printf("%d ",i);

 if(i=4) break;

            }

            return 0;

 }

ERROR: if(i==4)

OUTPUT: 2 4

1000

Find the errors in the code and determine the value of p in the given code?


    #include <iostream>

    using namespace std;

    int main()

    {

        int p;

        boolean a = True;

        boolean b = False;

        int x = 10;

        int y = 5;

        p = ((x | y) + (a + b));

        cout >> p;

        return 0;

    }

a) 12

b) 0

c) 2

d) 16

ERRORS:

bool a = true;

bool b = false;


cout << p;

P:16

1000

What will be the output of the program?

class Output
{
 final static short i = 2;
 public static int j = 0;
 
 public static void main(String [] args)
 {
 for (int k = 0; k < 3; k++)
 {
 switch (k)
 {
 case i: System.out.print(" 0 ");
 case i-1: System.out.print(" 1 ");
 case i-2: System.out.print(" 2 ");
 }
 }
 }
}

A)2 1 0 1 0 0

B)0 1 2 1 2 2

C)2 1 2 0 1 2

D)0 1 2

E)Compilation Error

C)2 1 2 0 1 2