Professional Documents
Culture Documents
2- How many times will the word “Zanko” be printed in the following code?
a. 5 b. infinite c. 7 d. 6
a. 4 b. 3 c. 0 d. 2
8- What will be printed on the screen after running the following code?
9-
using System;
public class Example
{
static int a;
private int b;
const int c;
public int getItem(int i, int j)
{
a = i;
b= j;
c = i + j;
}
public Example(int d)
{
a = b = 5;
}
~Example(int k)
{
a = b = k;
}
}
namespace Exam_Question2
{
class Program
{
static void Main(string[] args)
{
Example ob = new Example();
ob.getItem(4, 5);
ob.a = 6;
}
}
}
11-
using System;
public class Base
{
int sum(int x, y)
{
int result;
result = x + y;
}
int g() {
Console.WriteLine( "This is for test" );
int h() {
Console.WriteLine( "I will kill you if you don't find this
error" );
}
}
}
namespace Exam
{
class Program
{
static void Main(string[] args)
{
Base ob = new Base;
int a = ob.sum + ob.g();
}
}
}
}
static int do_calc(int n1, ref int n2)
{
n1 = n1 + 5;
n2 = n2 * 5;
Console.WriteLine(n1+ n2);
return n1;
}
14- Consider the following array: a[] = {3, -1, -6, 2}. What is the value of
a[a[3] - a[1]]?
17- Create a class Rectangle with attributes length and width, each of which
defaults to 1.
Provide member functions that calculate the perimeter and the area of the
rectangle.
Also, provide set and get methods for the length and width attributes. The set
functions should verify that length and width are each floating point numbers
larger than 0.0 and less than 20.0.
The get functions should get the variables from the user.
Head of Department 7 Examiner
18- Define a jagged array that contains 3 rows. The number of elements for
each row is variable and can be defined by the user. Write a program to add
up (sum) all elements of the array. See the following example.
1 0 2 3
-1 1 Sum = 7
2 -2 1
Success,