0% found this document useful (0 votes)
24 views

CPE 317 Visual Programming Mid-Term-Exam

The document is a mid-term exam for a Visual Programming course, consisting of multiple-choice questions and coding exercises related to C#. It covers topics such as namespaces, data types, access specifiers, constructors, and the .NET framework. The exam includes practical coding tasks requiring the completion of code snippets and understanding of programming concepts.

Uploaded by

cikif83366
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

CPE 317 Visual Programming Mid-Term-Exam

The document is a mid-term exam for a Visual Programming course, consisting of multiple-choice questions and coding exercises related to C#. It covers topics such as namespaces, data types, access specifiers, constructors, and the .NET framework. The exam includes practical coding tasks requiring the completion of code snippets and understanding of programming concepts.

Uploaded by

cikif83366
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

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);

Console.WriteLine("Type of str is {0}", str.GetType().ToString());


}
}
}
Value of x: 32767
Value of result: False
New Result: 314
33082 316
Type of str is System.String
5. Boşlukları verilen çıktıya göre doldurunuz.

using System;

namespace Mide_term_Exam_3
{
class Program
{

static void Calculate(int long_edge, int short_edge,ref int perimeter, ref


int area)
{
perimeter = 2* (long_edge + short_edge);
area = long_edge* short_edge;
}
static void Main(string[] args)
{
int long_edge = 6, short_edge = 4;
int perimeter = 0, area = 0;
Calculate(long_edge,short_edge, ref perimeter, ref area);
Console.WriteLine("Perimeter of rectangle: " +perimeter + " & " +"Area
of rectangle: " + area);
Console.ReadLine();
}

}
}

Perimeter of rectangle: 20 & Area of rectangle: 24


6. Boşlukları verilen çıktıya göre doldurunuz.

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

Reversed Array Elements: 20 36 16 28 12 20 8 12 4 4

7. Which of the following statements isn’t correct about the Constructor?

A.A class can have any number of constructors.


B.A constructor doesn’t have any return type.
C.Within a class, you can create only one static constructor.
D. A constructor always have no parameters.
8. Boşlukları verilen çıktıya göre doldurunuz.

using System;

namespace Mid_term_Exam__5
{
class Program
{
enum Kind
{
Opel,
Audi,
Skoda
}

static void Main(string[] args)


{
Kind myCar = Kind.Audi;

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

9. Which of the following statements is correct?

A. Member functions of a class are by default public.


B. Object Oriented Programming paradigm stresses on dividing the logic into smaller
parts and writing procedures for each part.
C. Data members ofa class are by default public.
D. Object Oriented Programming paradigm gives equal importance to data and the
procedures that work on the data.
10. Boşlukları verilen çıktıya göre doldurunuz.

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 void Acceptdetails()


{
Console.Write("Enter Radius: ");
radius = Convert.ToDouble(Console.ReadLine());

}
public double GetArea()
{
return 2*pi*radius;
}
public void Display()
{
Console.WriteLine("Radius: {0}", radius);

Console.WriteLine("Area: {0}", GetArea());


}
}//end class Rectangle

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;

Console.WriteLine("Math.E = " + Math.E);


Console.WriteLine("Round value of number: "+ Math.Round(pi));
Console.WriteLine("Positive number = " + Math.Abs(number_1));
Console.WriteLine("Root of number = " + Math.Sqrt(number_2));
Console.WriteLine("min number = " + Math.Min(number_1, number_2));

}
}
}
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 (numbers[i] <= 0) continue;


sum += numbers[i];
adding_numbers++;

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

16. Which of the following are wrong about .NET Framework?


A. It provides a consistent object-oriented programming environment whether object code is
stored and executed locally, executed locally but Internet-distributed, or executed
remotely.
B. It provides a code-execution environment that minimizes software deployment and
versioning conflicts.
C. It provides a code-execution environment that promotes safe execution of code, including
code created by an unknown or semi-trusted third party.
D. It provides different programming models for Windows-based applications and
Web-based applications.

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

B. Common Language Runtime

C. Common Language Infrastructure

D. Component Object Model

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

19. Which of the following aren’t feature of C #?


A. C# is modern and easy to learn
B. C# is versatile
C. C# is fast, open source, and cross platform
D. C# language was created by Anders Hejlsberg at Microsoft.

You might also like