Question And Answer.

Similar documents
.Net Technologies. Components of.net Framework

Chapter 1 Getting Started

CS313D: ADVANCED PROGRAMMING LANGUAGE

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Introduction to Programming Using Java (98-388)

Chapter 2: Using Data

Understand Computer Storage and Data Types

Introduce C# as Object Oriented programming language. Explain, tokens,

C#: framework overview and in-the-small features

Darshan Institute of Engineering & Technology for Diploma Studies

Introduction To C#.NET

Appendix G: Writing Managed C++ Code for the.net Framework

Introduction to C# Applications

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

Programming in C++ 6. Floating point data types

UNIT 1. Introduction to Microsoft.NET framework and Basics of VB.Net

INDEX. A SIMPLE JAVA PROGRAM Class Declaration The Main Line. The Line Contains Three Keywords The Output Line

Visual C# Instructor s Manual Table of Contents

Fig 1.1.NET Framework Architecture Block Diagram

VARIABLES AND TYPES CITS1001

3. Java - Language Constructs I

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

PROGRAMMING FUNDAMENTALS

Duhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain

B.V. Patel Institute of BMC & IT, UTU 2014

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

CSC 1214: Object-Oriented Programming

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

C# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it.

CS242 COMPUTER PROGRAMMING

DAD Lab. 1 Introduc7on to C#

This tutorial has been prepared for the beginners to help them understand basics of c# Programming.

C# Types. Industrial Programming. Value Types. Signed and Unsigned. Lecture 3: C# Fundamentals

Full file at

Industrial Programming

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Agenda & Reading. VB.NET Programming. Data Types. COMPSCI 280 S1 Applications Programming. Programming Fundamentals

Object Oriented Programming with Visual Basic.Net

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

Introduction to C++ with content from

CEN 414 Java Programming

Zheng-Liang Lu Java Programming 45 / 79

Chapter-8 DATA TYPES. Introduction. Variable:

Chapter 2 Elementary Programming

CS11 Java. Fall Lecture 1

C++ Programming: From Problem Analysis to Program Design, Third Edition

Fundamentals of Programming

VISUAL PROGRAMMING_IT0309 Semester Number 05. G.Sujatha & R.Vijayalakshmi Assistant professor(o.g) SRM University, Kattankulathur

Objectives. In this chapter, you will:

QUESTION BANK: INTRODUCTION TO PROGRAMMING (HCS102) a. Compare and contrast unboxing and widening using code snippets [10]

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

Programming. Syntax and Semantics

Pace University. Fundamental Concepts of CS121 1

NOOTAN PADIA ASSIST. PROF. MEFGI, RAJKOT.

IT 528 Developing.NET Applications Using C# Gülşen Demiröz

c++ keywords: ( all lowercase ) Note: cin and cout are NOT keywords.

UNIT- 3 Introduction to C++

Chapter 2. Elementary Programming

Module 4: Data Types and Variables

Full file at

C# Fundamentals. built in data types. built in data types. C# is a strongly typed language

Computer Components. Software{ User Programs. Operating System. Hardware

BASIC ELEMENTS OF A COMPUTER PROGRAM

CONTENTS: Array Usage Multi-Dimensional Arrays Reference Types. COMP-202 Unit 6: Arrays

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

Assumptions. History

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

Program Fundamentals

PES INSTITUTE OF TECHNOLOGY

IT 1033: Fundamentals of Programming Data types & variables

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

Expressions & Flow Control

Fundamental of Programming (C)

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

CSI33 Data Structures

Values and Variables 1 / 30

COMP 202 Java in one week

Chapter 12 Microsoft Assemblies. Software Architecture Microsoft Assemblies 1

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

ESc101 : Fundamental of Computing

Computers and Programming Section 450. Lab #1 C# Basic. Student ID Name Signature

S.Sakthi Vinayagam Sr. AP/CSE, C.Arun AP/IT

Declaration and Memory

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals

Introduction to Java

3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

[0569] p 0318 garbage

Lesson 02 Working with Data Types. MIT 31043: VISUAL PROGRAMMING By: S. Sabraz Nawaz Senior Lecturer in MIT

Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1

Basics of Java Programming

Getting started with Java

Transcription:

Q.1 What would be the output of the following program? using System; namespaceifta classdatatypes static void Main(string[] args) inti; Console.WriteLine("i is not used inthis program!"); A. i is not used in this program! B. Compilation Error C. No output D. None of the Above ANSWER : Option A i is not used in this program! If a variable is not initialized but is not used anywhere, there is no issue and the program executes perfectly fine. The error comes only when we try to access the value of an uninitialized variable. Q.2 Correct output for code is? static void Main(string[] args) float a = 10.553f; long b = 12L; int c; c = Convert.ToInt32(a + b); Console.WriteLine(c); A. 23.453 B. 22 C. 23 D. 22.453 ANSWER : Option C 23 The two datatype ^aeur~float^aeurtm and ^aeur~long^aeurtm after arithmetic operation completely converted to nearest whole number 23. Page 1

Q.3 Which of the following statement is true about data types in C#? I. Size of byte and sbyte is same. II. Size of short and ushort is same. III. Size of int and uint is same. IV. Size of long and ulong is same. V. Size of double and Decimal is same. A. I, V. B. II, V C. III, IV, V D. I, II, III, IV ANSWER : Option D I, II, III, IV Size of byte and sbyte : 1 byte Size of short and ushort: 2 bytes Size of int and uint: 4 bytes Size of long and long: 8 bytes Size of double: 8 bytes Size of Decimal: 16 bytes Q.4 Which of the following statement correctly assigns a value 33 to a variable c? byte a = 11, b = 22, c; A. c = (byte) (a + b); B. c = (byte) a + (byte) b; C. c = (int) a + (int) b; D. c = (int)(a + b); ANSWER : Option A c = (byte) (a + b); Because the arithmetic expression on the right-hand side of the assignment operator evaluates to int by default. For short and byte types compiler asks for explicit conversion. Q.5 Which of the following lines perform Automatic Type Conversion? (Choose all that apply) using System; namespaceifta classautoconvertion static void Main(string[] args) byte b=10; //line8 Page 2

short s=20; //line9 inti; i=b; //line11 Console.WriteLine("i=" +i); i=s; //line13 Console.WriteLine("i=" +i); A. Line8 B. Line9 C. Line11 D. Line13 ANSWER : Option a, b, c, d Line8 Line9 Line11 Line13 C# performs an automatic type conversion when storing a literal integer constant into variables of type byte, short, long and char.thus, All the options are correct.in the line8 and line9 the integer constant 10 and 20 are assigned to byte and short respectively. Here Automatic Type Conversion occurs. In the line11 and line13 "Widening" happens i.e. byte and short are widened/ typecast into a larger datatype i.e. int. Q.6 Which of the given stream method provides the access to the input console in C#.NET? A. Console.Out B. Console.Error C. Console.In D. All of the mentioned ANSWER : Option C Console.In Console.In is an instance of TextReader, and we can use the methods and properties defined by TextReader to access it to read the input from the keyboard. Q.7 Which of the given stream method provides the access to the output console by default in C#.NET? A. Console.In B. Console.Out Page 3

C. Console.Error D. All of the mentioned ANSWER : Option B Console.Out The standard output stream Console.Out sends output to the screen by default. Q.8 Which of the following statements are correct about datatypes in C#.NET? I. Every datatype is either a value type or a reference type. II. Value types are always created on the heap. III. Reference types are always created on the stack. IV. Mapping of every value type to a type in Common Type System facilitates Interoperability in C#.NET. V. Every reference type gets mapped to a type in Common Type System. A. 1, 3 B. 2, 5 C. 1, 4 D. 3, 4 ANSWER : Option C 1, 4 DataType is either a value type or a reference type, other than that no other type is available. Value types are always created on the Stack.Reference types are always created on the Heap. Mapping of every value type to a type in Common Type System facilitates Interoperability in C#. NET so that MSIL be prepared that is same for all language. Q.9 What would be the output of the following program? using System; namespaceifta classdatatypes static void Main(string[] args) byte b; short s; inti; long l; float f; double d; Page 4

boolbl; char c; Console.WriteLine("byte="+b+" short="+s+" int="+i); Console.WriteLine("long="+l+" float="+f+" double="+d); Console.WriteLine("char="+c+" bool="+bl); A. byte=0 short=0 int=0 long=0 float=0 double=0 char= bool=false B. byte=0 short=0 int=0 long=0 float=0.000000 double=0.000000 char= bool=false C. Compilation Error D. None of the Above ANSWER : Option C Compilation Error We get the following Error: Description: Use of unassigned local variable In C#, Every local variable has to be initialized before it can be used. Q.10 Which of the following statements are TRUE about the.net CLR? It provides a language-neutral development & execution environment. It ensures that an application would not be able to access memory that it is not authorized to access. It provides services to run "managed" applications. The resources are garbage collected. It provides services to run "unmanaged" applications. A. Only 1 and 2 B. Only 1, 2 and 4 C. 1, 2, 3, 4 D. Only 4 and 5 ANSWER : Option C 1, 2, 3, 4 CLR (Common Language Runtime) is a heart of Dot Net Framework. It is a core runtime environment of.net Framework for executing applications. The main function of Common Language Runtime (CLR) is to convert the Managed Code into native code and then execute the Program. It acts as a layer between Operating Systems and the applications written in.net languages. CLR handles the execution of code and provides useful services for the implementation of the program. In addition to executing code, CLR provides services such as memory management, thread management, security management, code verification, compilation, Page 5

and other system services Q.11 Which of the following is the correct ways to set a value 3.14 in a variable pi such that it cannot be modified? A. float pi = 3.14F; B. #define pi 3.14F; C. const float pi = 3.14F; D. const float pi; pi = 3.14F; ANSWER : Option C const float pi = 3.14F; Const keyword is used for declaring a Constant variable, where Constant variable must be declare at the time of declaration only. Syntax for declaring Constant is : [const]< type><var><=value> Q.12 Arrange following datatype in order of increasing magnitude sbyte, short, long, int. A. long< short <int<sbyte B. sbyte< short <int< long C. short<sbyte<int< long D. short<int<sbyte< long ANSWER : Option B sbyte< short <int< long Holds signed 8-bit (1-byte) integers that range in value from -128 through 127. Use the SByte data type to contain integer values that do not require the full data width of Integer or even the half data width of Short. In some cases the common language runtime might be able to pack your SByte variables closely together and save memory consumption. The default value of SByte is 0. Holds signed 16-bit (2-byte) integers that range in value from -32,768 through 32,767. Use the Short data type to contain integer values that do not require the full data width of Integer. In some cases, the common language runtime can pack your Shortvariables closely together and save memory consumption.the default value of Short is 0. Holds signed 32-bit (4-byte) integers that range in value from -2,147,483,648 through 2,147,483,647. The Integer data type provides optimal performance on a 32-bit processor. The other integral types are slower to load and store from and to memory. The default value of Integer is 0. Holds signed 64-bit (8-byte) integers ranging in value from -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807 (9.2...E+18). Use the Long data type to contain integer numbers that are too large to fit in the Page 6

Integer data type.the default value of Long is 0. Q.13 Missing deceleration type of ^aeur~b^aeurtm. Static Void Main(String[] args) constint m = 100; int n = 10; constint k = n / 5 * 100 * n ; Console.WriteLine(m * k); Console.ReadLine(); A. ^aeur~k^aeurtm should not be declared constant B. Expression assigned to ^aeur~k^aeurtm should be constant in nature C. Expression (m * k) is invalid D. ^aeur~m ^aeur~ is declared in invalid format ANSWER : Option B Expression assigned to ^aeur~k^aeurtm should be constant in nature ^aeurtmk^aeurtm should be declared as constint k = 10/5 * 100*10 i.e only constant values should be assigned to a constant. Q.14 Default Type of number without decimal is? A. Long Int B. Unsigned Long C. Int D. Unsigned Int ANSWER : Option C Unsigned Int a decimal and an int are mixed in the same expression. The result evaluates to the decimal type. Q.15 The number of input methods defined by the stream method Console.In in C#.NET is? A. 4 B. 3 C. 2 D. 1 ANSWER : Option B 3 Two basic methods : read() and readline() and third method readkey() introduced in.net FrameWork 2.0. Page 7

Q.16 Which of the class provides the operation of reading from and writing to the console in C#.NET? A. System.Array B. System.Output C. System.ReadLine D. System.Console ANSWER : Option D System.Console The method for reading and writing to the console in C#.NET is provided by System.Console class. This class gives us access to the standard input,output and standard error streams. Q.17 Which of the following is the correct default value of a Boolean type? A. 0 B. 1 C. True D. False ANSWER : Option D False Boolean types return only true and false but default value of boolean type will be false. Q.18 Correct Declaration of Values to variables ^aeur~a^aeurtm and ^aeur~b^aeurtm? A. int a = 32, b = 40.6; B. int a = 42; b = 40; C. int a = 32; int b = 40; D. int a = b = 42; ANSWER : Option C int a = 32; int b = 40; a) Although,deceleration of ^aeur~b^aeurtm and ^aeur~a^aeurtm are correct but initialization of value to ^aeur~b^aeurtm should be ^aeur~int^aeurtm datatype not float. b) Missing deceleration type of ^aeur~b^aeurtm. c) correctly declared datatypes ^aeur~a^aeurtm and ^aeur~b^aeurtm. d) ^aeur~b^aeurtm can^aeurtmt be assigned values before declaration. Missing deceleration type of ^aeur~b^aeurtm. Page 8

Q.19 Which of the following statements are correct? I. We can assign values of any type to variables of type object. II. When a variable of a value type is converted to object, it is said to be unboxed. III. When a variable of type object is converted to a value type, it is said to be boxed. IV. Boolean variable cannot have a value of null. V. When a value type is boxed, an entirely new object must be allocated and constructed. A. 2,5 B. 1,5 C. 3, 4 D. 2, 3 ANSWER : Option B 1,5 We can assign the any type value to the variable of object data type. Boxing means suppose you have declared a variable as simple data type and we can change it into reference type. After task complete if we want to change the reference type into simple data type it is called unboxing. Q.20 Select the correct methods provided by Console.In? A. Read(), ReadLine() B. ReadKey(), ReadLine() C. Read(), ReadLine(), ReadKey() D. ReadKey(), ReadLine() ANSWER : Option C Read(), ReadLine(), ReadKey() The two method Read() and ReadLine() available in.net Framework 1.0 and Third method ReadKey() was added by.net Framework 2.0. Q.21 Which Conversion function of ^aeur~convert.toint32()^aeurtm and ^aeur~int32.parse()^aeurtm is efficient? I. Int32.Parse() only used for strings and throws arguement exception for null string II.Convert.Int32() used for datatypes and returns directly ^aeurtm0? for null string. A. 2 B. Both 1,2 C. 1 D. None of the mentioned ANSWER : Option A 2 Page 9

Convenient for every datatype so mostly preferred. Q.22 What would be the output of the following program? using System; namespaceifta class DataTypesScope3 static void Main(string[] args) for (inti=1;i<=3 ;i++ ) int y=1; Console.WriteLine("i="+i+" y="+y); y++; A. i=1 y=1i=2 y=2i=3 y=3 B. i=1 y=1i=2 y=1i=3 y=1 C. i=1 y=1i=1 y=1i=1 y=1 D. Compilation Error ANSWER : Option B i=1 y=1i=2 y=1i=3 y=1 The declaration of variable y is inside the for loop and is executed every time the control enters the loop thus, re-initializing it to 1 every time.so, Y remains 1 across all the 3 iterations. A variable declared inside a block is lost every time the control goes out of the scope thus the y declared here is created afresh and discarded at the end of every iteration. Q.23 Which datatype should be more preferred for storing a simple number like 35 to improve execution speed of a program? A. sbyte B. short C. int D. long ANSWER : Option A sbyte Wider datatype like int,long takes more Page 10

time for manipulation of a program. Q.24 Choose the output return when read() reads the character from the console? A. String B. Char C. Integer D. Boolean ANSWER : Option C Integer Read() returns the character read from the console. It returns the result. The character is returned as an int, which should be cast to char. Q.25 Choose ".NET class" name from which datatype ^aeuroeuint^aeur Page 11