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

HNDIT1012 Visual Programming - Question - PaperV1.1 - Password Added

The document is the question paper for the HNDIT1012 Visual Application Programming exam. It contains 6 questions testing concepts related to visual programming, variables, control structures, classes, methods, events, files and more. Students are required to answer 5 out of the 6 questions in the paper.

Uploaded by

ravinduashan66
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

HNDIT1012 Visual Programming - Question - PaperV1.1 - Password Added

The document is the question paper for the HNDIT1012 Visual Application Programming exam. It contains 6 questions testing concepts related to visual programming, variables, control structures, classes, methods, events, files and more. Students are required to answer 5 out of the 6 questions in the paper.

Uploaded by

ravinduashan66
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

[All Rights Reserved]

SLIATE
SRI LANKA INSTITUTE OF ADVANCED TECHNOLOGICAL EDUCATION
(Established in the Ministry of Higher Education, vide in Act No. 29 of 1995)

Higher National Diploma in Information Technology


First Year, First Semester Examination – 2021
HNDIT1012 – Visual Application Programming
Instructions for Candidates: No. of questions : 06
Answer five questions only. No. of pages : 06
All questions carry equal marks. Time :Three hours

Question 01
1. Consider the following Graphical User Interface(GUI) and identify 03 components used.
(03 Marks)

2. Suggest suitable names for the components named by A, B, C and D at above figure
(04 Marks)
3. Write the code to clear all fields when user clicks on clear button. (05 Marks)

4. Write the code to calculate the area for a given width and height of a rectangle. (08 Marks)

Question 02
1. Following application will calculate Body Mass Index (BMI) for a given value of height (in
Meters) and weight (in Kilograms). (05 Marks)

Write the code to calculate and show the BMI value in the BMI Text Box when user clicks
on Calculate button.
HNDIT 1012 – Visual Programming (2021 – First Year - 1st Semester ) 1
2. Write the code to Reset button where it can erase all the Text box values and its colors.
(05 Marks)
3. Application should display outputs for status and indicator fields based on the values for BMI
as shown in the below table. Write the code for this function.

BMI Value Status Indicator


background Color
Less than 18.5 Under Weight Red
18.5 - 25 Normal Blue
25 - 30 Obesity Class I Orange
30 - 40 Obesity Class II Pink
Above 40 Obesity Class III Brown

Please consider the names of status and indicator fields as txtStatus and txtIndicator for
you answer. (10 Marks)

Question 03
1. Define the term “Computer Program”. (03 Marks)
2. State two examples for Language translator softwares (02 Marks)
3. What is the purpose of Verbatim String in C# (02 Marks)
4. Write the outputs of the following codes (06 Marks)
a.
for (int i = 1; i <= 12; i=i+2)
{
if (i == 8)
{
break;
}
Console.WriteLine(i);
}
b.
int n = 0;
while (n < 5)
{
n++;
Console.WriteLine(n.ToString());
}
c.
int counter = 1;
do
{
Console.WriteLine($"Hello World!"+counter);
counter++;
} while (counter <1);

5. Consider the following expressions and write their outputs (07 Marks)
a. Console.WriteLine( (2.0 * 3.0) / 4); (01 Mark)

b. Console.WriteLine((2>3)&&(4>5)); (02 Marks)


c. (04 Marks)
int num = 1;
Console.WriteLine(num);
Console.WriteLine(++num);
Console.WriteLine(num++);
Console.WriteLine(num);

HNDIT 1012 – Visual Programming (2021 – First Year - 1st Semester ) 2


Question 04
1. Briefly explain the term .Net Framework (03 Marks)
2. Aravinda wants to select names for a variables for his application. State two best practices he
can follow when he naming a variable? (04 Marks)
3. State two types of comments in C# and briefly explain them. (05 Marks)
4. Consider the below given GUI. (08 Marks)

Write the code for the Login button to permit access to a user with the username “admin” and
the password “123” as login information. If the user provides the correct login information
the program will show a message box "Your Permitted - Valid User" otherwise program
will show a message box "Error in User Name or Error Password".

Question 05
1. Define the term “Event” in a C# application (02 Marks)
2. State Four (04) user events can be used in a C# Application (04 Marks)
3. Write the output of the following commands (04 Marks)
a.
String [] cars = { "Volvo", "BMW", "Toyota", "Ford", "Mazda", "Bugatti" };

for(int a = 0; a < cars.Length; a++)


{
Console.Write(cars[a]+"\t");
}

b.
cars[0] = "Nissan";

for (int a = 0; a < cars.Length; a++)


{
Console.Write(cars[a] + "\t");
}

4. Briefly explain the purpose of the below code using a suitable drawing. (05 Marks)
public void DrawLineInt(PaintEventArgs e)
{
Pen blackPen = new Pen(Color.Black, 3);
int x1 = 100;
int y1 = 100;
int x2 = 500;
int y2 = 100;
e.Graphics.DrawLine(blackPen, x1, y1, x2, y2);
}
5. Sunil is a Trainee software developer. He is working on a C# project. He is continuously
receiving syntax errors. Write Three advices or best practices which can be used by Sunil to
reduce project errors. (05 Marks)

HNDIT 1012 – Visual Programming (2021 – First Year - 1st Semester ) 3


Question 06
Consider the following GUI for a notepad application which can read and write a text file
specified by a user. When user click on open button and save button the program will show a
File dialog box and read or save a file with a given file name.

1. Write the code to clear the text box in the above application. Assume the text box name is
txtMain. (02 Marks)
2. Write the code segment to exit the form when user click on the Exit button. (02 Marks)
3. State the purpose of FileDialog class? (02 Marks)
4. Name four file writing and reading methods names used in C# language. (04 Marks)
5. Following code will open a file with a given location and display the content in the text box.
Fill in the blanks with the suitable codes. (10 Marks)
private void btnOpen_ ……(1)…….(object sender, EventArgs e)
{
OpenFileDialog ……(2)…… = new ……(3)…… ();
fileDialog. ……(4)…… = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
……(5)…….FilterIndex = 0;
fileDialog.InitialDirectory = @"E:\asp c#"; // give your default directory

// Reading a text file line by line

if (fileDialog.ShowDialog() == DialogResult. ……(6)……)


{
txtMain.Text = fileDialog.FileName;
string[] readBuffer = ……(7)…….IO.File.ReadAllLines(fileDialog.FileName);
for (int i = 0; i < ……(8)…….Length; ……(9)……)
txtMain. ……(10)…… = readBuffer[i] + "\n";
}
}

HNDIT 1012 – Visual Programming (2021 – First Year - 1st Semester ) 4

You might also like