CPE 317 Visual Programming Mid-Term-Exam
CPE 317 Visual Programming Mid-Term-Exam
2.12.2020
Name-Surname:
Number: Time: 60 minutes
Questions
1. Which of the following is the correct about namespaces in C#?
A - A namespace is used for providing to keep one set of names separate from another..
B - The class names declared in one namespace does not conflict with the same class names
declared in another.
C - Namespaces help us to control the visibility of the elements present in it.
D - All of the above.
2. Which of the following converts a type to a single Unicode character, where possible in
C#?
A - ToSingle
B - ToByte
C - ToChar
D - ToDateTime
3. Which of the following access specifier in C# allows a child class to access the member
variables and member functions of its base class?
A - Public
B - Private
C - Protected
D - Internal
4. Boşlukları verilen çıktıya göre Relational ve Arithmetic Operators kullanarak doldurunuz.
using System;
namespace Mid_Term_Exam_1
{
class Program
{
static void Main(string[] args)
{
bool result;
int new_result;
int x;
int y= 314;
var str = "Hello World";
x = Int16.MaxValue;
Console.WriteLine("Value of x: " + x);
result = !(x != y); //result = !(x > y);
Console.WriteLine("Value of result: " + result);
new_result = x < y ? x : y;
Console.WriteLine("New Result: " + new_result);
if (!(new_result <= 0))
Console.WriteLine(++x + y++ + " " + ++y);
else
Console.WriteLine(--x + y-- + " " + --y);
using System;
namespace Mide_term_Exam_3
{
class Program
{
}
}
using System;
namespace Mid_Term_Exam_4
{
class Program
{
static void Multiple(ref int[] array)
{
for (int i = 0; i < array.Length; i = i + 2)
{
array[i] = array[i] * 2 ;
}
Console.WriteLine("Dimensions of the Array=" + array.Rank + "\n" + " Elements: "
+string.Join(",", array));
}
static void Main(string[] args)
{
int[] first_array = new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 };
Multiple(ref first_array);
Array.Reverse(first_array);
Console.Write("Reversed Array Elements: ");
foreach (int i in first_array)
{
Console.Write(i + " ");
}
Console.ReadLine();
}
}
}
Dimensions of the Array= 1
Elements: 4,4,12,8,20,12,28,16,36,20
using System;
namespace Mid_term_Exam__5
{
class Program
{
enum Kind
{
Opel,
Audi,
Skoda
}
switch (myCar)
{
case Kind.Opel:
Console.WriteLine("My car is Opel");
break;
case Kind.Audi:
Console.WriteLine("My car is Audi");
break;
case Kind.Skoda:
Console.WriteLine("My car is Skoda");
break;
}
}
}
}
My car is Audi
using System;
namespace Mid_term_Exam__5
{
class Program
{
static int Calculate(out int i)
{
int multiple = 1;
i = 6;
for (int j = 1; j <= i; j++)
{
multiple = multiple * j;
}
return multiple;
}
static void Main(string[] args)
{
int i;
var result = Calculate(out i);
Console.WriteLine("Result is:"+result);
}
}
}
Result is:720
Boşlukları verilen çıktıya
11.System;
using göre dol
using System.Collections;
namespace Mid_Term_Exam_6
{
class Program
{
static void Main(string[] args)
{
ArrayList myList = new ArrayList(10);
myList.Add(1);
myList.Add(3);
myList.Add(5);
myList.Add(7);
myList.Add(9);
myList.Add(11);
myList.Add(13);
myList.Add(15);
myList.Add(17);
myList.Add(19);
myList.RemoveRange(0, 4);
Console.WriteLine("The ArrayList: ");
foreach (int i in myList)
{
Console.WriteLine(i);
}
Console.WriteLine(!myList.Contains(15));
myList.Insert(1, 21);
Console.WriteLine("The ArrayList: ");
foreach (int i in myList)
{
Console.WriteLine(i);
}
}
}
}
The ArrayList:
11
13
15
17
19
False
The ArrayList:
21
11
13
15
17
19
12. Boşlukları verilen çıktıya göre doldurunuz.
using System;
namespace Mid_Term_Exam_7
{
class Circle
{
private double radius;
double pi = Math.PI;
}
public double GetArea()
{
return 2*pi*radius;
}
public void Display()
{
Console.WriteLine("Radius: {0}", radius);
class ExecuteArea
{
static void Main(string[] args)
{
Circle r = new Circle();
r.Acceptdetails();
r.Display();
Console.ReadLine();
}
}
}
Enter Radius: 4
Radius: 4
Area: 25,12
13. Math sınıfı
using System;
namespace Mid_term_Exam_10
{
class Program
{
static void Main(string[] args)
{
int number_1 = -25;
int number_2 = 64;
const double pi= Math.PI;
}
}
}
Math.E = 2,718281828459045
Round value of number: 3
Positive number = 25
Root of number = 8
Root of number = -25
14. Bu program dizinin elemanlarını verilen şarta göre toplamaktadır. Boşlukları verilen
çıktıya göre doldurunuz.
using System;
namespace Mide_Term_Exam_8
{
class Program
{
static void Main(string[] args)
{
int[] numbers = new int[] { 1, 4, 0, 3, -4, 1, -1, 3, 6, -2, 1 };
int sum = 0;
int adding_numbers = 0;
for (int i = 0; i < numbers.Length; i++)
{
if (adding_numbers == 5) break;
}
Console.WriteLine("Sum of Adding numbers = {0}", sum);
}
}
}
Sum of Adding numbers = 12
15. Datetime expression
using System;
namespace Mid_Term_Exam_9
{
class Program
{
static void Main(string[] args)
{
DateTime date_find = DateTime.Now;
Console.WriteLine(date_find.ToLongDateString());
Console.WriteLine(date_find.ToLongTimeString());
Console.WriteLine(date_find.ToShortDateString());
Console.WriteLine(date_find.ToShortTimeString());
Console.WriteLine(date_find.ToString());
}
}
}
29 Kasım 2020 Pazar
01:00:10
29.11.2020
01:00
29.11.2020 01:00:10
17. Which of the following components of the .NET framework provide an extensible
set of classes that can be used by any .NET compliant programming language?
A. .NET class libraries
18.
. Which of the following doesn’t constitute the .NET Framework?
A. ASP.NET Applications
B. CLR
C. Framework Class Library
D. Microsoft Intermediate Language