Hans Machine Test
Hans Machine Test
Note:
5. The correct way of creating objects of a class Hello is: (Choose all that apply)
A. Hello obj1 = new Hello();
B. Hello obj2; obj = new Hello();
C. Hello obj3;
D. Hello obj4 = Hello();
E. obj5 = new Hello();
6. What will be the output of following program?
using System;
namespace HansConsoleApplication
{
class Hello
{
int a, b;
public void SetValue(int a, int b)
{
a = a;
b = b;
}
public void DisplayValue()
{
Console.WriteLine(a + " " + b);
}
}
class MyGreeting
{
static void Main(string[] args)
{
Hello obj = new Hello();
obj.SetValue(1, 2);
obj.DisplayValue();
}
}
}
A. 1 2
B. 12
C. 0 0
D. None of the above
class Calculation
{
static void Main(string[] args)
{
int a=5;
int b=2;
float c= a/b;
Console.WriteLine("The Result" + c);
}
}
A. 2.5
B. 2
C. 2.0
D. Error
8. Which is default value of Boolean type in C#?
A. True
B. 1
C. False
D. 0
A. 10 20 10
B. 10 20 20
C. 10 10 10
D. Compilation Error
<script type="text/javascript">
var name = "Hans";
function DisplayName ()
{
var name = "Sagar";
document.write(name);
}
</script>
A.Hans
B.Sagar
C.Error
D.None of above
<script type="text/javascript">
var name1 = "WCF quiz";
function DisplayName ()
{
var name2 = "ASP.NET MCQs";
if(name1 != "")
document.write(name1);
else
document.write(name2);
}
</script>
<script type="text/javascript">
var name1 = "WPF Quiz";
function DisplayName ()
{
var name2 = "ASP.NET MCQs";
(name1.replace('P','C')=="WCF Quiz"?document.write(name1):document.write(name2));
}
</script>
A.WPF Quiz
B.WCF Quiz
C.ASP.NET MCQs
14. You can add a row using SQL in a database with which of the following?
A. ADD
B. CREATE
C. INSERT
D. MAKE
A. LIKE only
B. IN only
C. NOT IN only
D. IN and NOT IN
19. Find the SQL statement below that is equal to the following: SELECT NAME FROM CUSTOMER
WHERE STATE = 'VA';
20. SELECT DISTINCT is used if a user wishes to see duplicate columns in a query.
A. True
B. False
Part ‘B’
2. C# supports multiple-inheritance
A. True
B. False
4. Events in Web forms are processed before the “Page Load” event
A. True
B. False
8. DISTINCT and its counterpart, ALL, can be used more than once in a
SELECT statement.
A. True
B. False
10. Is this the correct way in Java Script to create three dimensional
array
A. True
B. False
Part ‘C’
Answer: Polymorphism: It is a main part of object oriented programming which can define
as a it have ability to provide the code and data into more than one form. There are two
types like Compile time and Run Time we also know as static and Dynamic ,compile time
there are two types- operator overloading and method overloading and run time is a
operator loading these are two main method where I can achieve the polymorphism in C#.
along with Method Overloading when you need multiple methods with the same name but
different parameters and Use Method Overriding when you need to provide different
behavior for a method in derived classes while keeping the same method signature.
Answer: Authentication we can define as a assume a user Logging into a website with
username & password and also used for Checking identity purpose .
Authorization we can define as a assume a user After logging in a regular user can only view
the profile but admin can manage all users and also used for Checking permissions.
Answer: Convert.ToString it is used for Converts a value to a string and also handle the null
condition in code apart from it is works for any types of data.
.ToString () it is used for Calls the ToString() method of an object and No throws Null
Reference Exception approach and Works only if the object is not null.
Q4. What is the difference between a primary key and unique key?
Answer:
Primary Key: It can define as a Uniquely identifies each row in a table and must be unique
for each row and not allow NULL Values and Only one primary key per table.
Unique Key: we can define as a ensures unique values in a column but allows multiple NULL
and it Must be unique but NULL are allowed and it can have multiple unique keys per table.
Q5. Write a query to delete the rows which are duplicate (don’t delete both duplicate
records.