Read - It Mt2 For 2-Sem
Read - It Mt2 For 2-Sem
Read - It Mt2 For 2-Sem
Option1
QNo
AY001 Which of the following process 1, Bytecode
converts Java programming verification m
language code to a set of
bytecodes? m
Option2
Option3
Option4
2, Compilation 3, Class
m
loading m
4, Execution m
2, "true" m
4, boolean m
3, true m
3, import
foo.bar.*; m
Statement A: String is a
primitive data type to
represent a sequence of
characters.
Statement B: You can declare
a String variable as:
String str="I am a
String";
Select the correct option for
the preceding statements: m
4, import foo.*; m
1, Both
2, Both
Statement A and Statement A
Statement B are and
Statement A: A constructor
true. m
Statement B
must have the same name as
are false. m
that of the class.
Statement B: The return type
of a constructor must be void.
2, 16 bits m
3, 32 bits m
4, 64 bits m
1, $const m
2, const m
3, long m
2, -source m 3, -g m
4, new m
4, -d m
1, The working
directory that
contains the
source files of
the program. m
2, The
3, The
4, The installation directory of 3
java_root/lib java_root/bin the Java technology software.
directory,
directory,
m
where
where
java_root is java_root is
the installation the installation
directory of directory of the
the Java
Java
technology
technology
software. m software. m
2, 0.0D m
3, 1.0D m
2, member m 3, local m
4, null m
4, instance m
2, Class m
3, String m
4, Object m
2,
Employee();
m
3,
4, Employee.super(); m
Manager.super
(); m
3, The code
will execute
and display
North as the
output. m
1, 0 m
3, 5 m
4, 6 m
System.out.println(direction[4])
;
}
}
What will be the outcome
when the preceding code is
executed?
m
2, 4 m
2, The code
will execute
with the
output Hello
world m
3, The code
will not
compile m
4, size() m
2, length() m 3, length m
2, && m
3, | m
4, ! m
1, The code will 2, The code 3, The code 4, The code will throw an
2
execute and
will execute will execute
exception as the num variable
display null. m and display 0. and display 1. is not initialized. m
m
m
1, public class
Example
{
1, Both
2, Statement 3, Statement A 4, Both Statement A and
Statement A and A is true while is false while Statement B are false. m
Statement B are Statement B Statement B is
true. m
is false. m
true. m
1, The Example
class is
accessible to all
classes m
2, The
Example
class is
accessible to
the classes
within the
same
package m
3, The
4, The Example class is
2
Example class accessible to its subclasses.
is not
m
accessible to
any classes m
1, Both
2, Statement 3, Statement A 4, Both Statement A and
Statement A and A is true while is false while Statement B are false m
Statement B are Statement B Statement B is
true. m
is false. m
true. m
AY027 Which of the following is NOT 1, switch (num) 2, int num = 3; 3, int num = 3; 4, switch (2)
a valid switch statement? m
{
switch
switch
{
case 1: (num)
(num)
System.out.printl
{
{
default:
n("Case 1");
System.out.println("Default
break;
case
case 3: Case");
case 2: 3:
System.out.pri
System.out.printl System.out.pri ntln("Case 3");
}
n("Case 2");
ntln("Case
m
break; 3");
continue;
case 3:
case
case 1:
System.out.printl 1:
System.out.pri
n("Case 3");
System.out.pri ntln("Case 1");
break; ntln("Case
default: 1");
continue;
System.out.printl
case
case 2:
n("Default
2:
System.out.pri
Case");
System.out.pri ntln("Case 2");
break; ntln("Case
}
2");
continue;
m
case
case 4:
4:
System.out.pri
System.out.pri ntln("Case 4");
ntln("Case
4");
}
m
}
m
1, The output
will display the
following:
1, Both
2, Statement 3, Statement A 4, Both Statement A and
Statement A and A is true while is false while Statement B are false. m
Statement B are Statement B Statement B is
true. m
is false. m
true. m
1, 4-11 m
2, 2 m
3, -11 m
4, -3 m
class Example
{
public static void
main(String[] args)
{
int b = -11; b = b >>
2;
System.out.println(b);
}
}
What will be the output of the
above program?
m
4, Ubiquitous Computing
should be used to show the
various ways of interacting
with the product m
2, Vertical
3, Sketching m 4, Wizard of Oz m
prototyping m
2, Vertical
prototyping
because it
covers a set
of features
with in-depth
functionality.
m
2, Wizard of 3, Sketching
Oz because it because it
is used to test explore the
an application design of the
without the
entire
existence of application
the
through visual
application. m brainstorming.
m
4, Horizontal prototyping
because it covers all the
features of the proposed
application. m
1, Usablity
2, Data
3, Functional 4, Non-functional
requirements m requirements requirements requirements m
m
m
2,
3, Social
4, Technical environment m
Organizationa environment m
l environment
m
2, Signature
graphics m
1, Resemblance 2, Simplicity
m
m
3, Relevance 4, Size m
m
3, Learnability 4, Utility m
m
3,
Memorability
m
4, Utility m
2,
3, Helpful m
Aesthetically
Pleasing m
4, Enjoyable m
2, Download 3, An
time should hourglass
be specified in should be
the help file of used to inform
the
the user about
application. m the download
time. m
1, A progress
bar should be
used to inform
the user about
the download
time. m
1, [1]
[2]
[3]
[4]
m
2, [1, 2, 3, 4] 3, [1][1][1][1]
m
[2][2][2][2]
[3][3][3][3]
[4][4][4][4]
m
4, [1, 2, 3, 4]
[1, 2, 3, 4]
[1, 2, 3, 4]
[1, 2, 3, 4]
m
1, import
2, import
3,
java.util.*;
java.util.*;
import
public class
public class java.util.*;
Example
Example
public class
{
{
Example
import java.util.*;
public static void public static {
public class Example
main(String
void
public static
{
args[])
main(String void
public static void main(String {
args[])
main(String
args[])
{
args[])
{
ArrayList<Intege
{
ArrayList list=new ArrayList(); r> list=new
ArrayList<Inte
Integer num=new
ArrayList<Intege ger> list=new ArrayList<Inte
Integer(10);
r>();
ArrayList<Inte ger> list=new
list.add(0,num);
Integer
ger>();
ArrayList<Inte
Integer
num=new
list.add(10); ger>();
numObj=(Integer)list.get(0); Integer(10);
int
list.add(10);
int num2=numObj.intValue(); list.add(num); numObj=list.g
System.out.println(num2);
int
et(0);
System.out.pri
numObj=list.get(
ntln(list);
}
num);
System.out.pri
}
ntln(numObj); }
System.out.printl
}
Which of the following code n(numObj);
}
m
will you use to replace the
}
preceding code for
}
m
optimization using generics
}
and autoboxing.
m
Ensure that the code you use
select performs the same
function and produces the
same result as that of the
given code.
m
4, import java.util.*;
2
public class Example
{
public static void main(String
args[])
{
ArrayList<Integer> list=new
ArrayList<Integer>();
list.add("10");
String
num=(String)list.get(0);
System.out.println(num);
}
}
m
1, Inside main
method.
Inside
constructor.
Inside static
block.
m
2, final m
4, private m
}
What will be the output on
executing the preceding code?
m
AY059 You must declare methods of 1, static m
an interface as
______________.
m
3, public m
2, Exception 3,
4, RuntimeException m
m
ArithmeticExce
ption m
4, abstract m
1, %g m
2, %s m
3, %x m
4, %n m
3, Both
4, Both Statement A and
Statement A Statement B are true. m
and Statement
B are false. m
1, Both
2, Statement 3, Statement A 4, Both Statement A and
Statement A and A is true while is false while Statement B are false. m
Statement B are Statement B Statement B is
true. m
is false. m
true. m
1, Both
2, Statement 3, Statement A 4, Both Statement A and
Statement A and A is true while is false while Statement B are false. m
Statement B are Statement B Statement B is
true. m
is false. m
true. m
1, The num1
variable. m
2, Both the
num1 and
num1
variables. m
3, The num2
variable. m
1, HashSet m
1, The code
executes with
the following
output:
James m
java.lang.Arith
meticExceptio
n: 1 at
Example.main
(Example.java
:7) m
System.out.println(name);
}
catch(Exception ex)
{}
}
}
Select the correct option on
executing the code with the
following command:
java Example James
m
AY071 Consider the following code:
public class Example
{
final int i;
public static void
main(String[] args)
{
System.out.println(new
Example().i);
}
}
Select the correct option for
the preceding code:
m
2, The code
will compile
and execute
with the
following
output:
1
2m
while(elements.hasNext()) {
System.out.println(elements.n
ext());
}
}
}
What will be the output of the
preceding code?
m
AY073 Consider the following code: 1, 1
3
public class Example
5m
{
public static void
main(String [] args)
{
try
{
System.out.println("1");
System.out.println(1/0);
System.out.println("2");
}
catch(ArithmeticException ex)
{
System.out.println("3");
}
catch(Exception ex)
{
System.out.println("4");
}
finally
{
2, 1
4
5m
3, 1
2
4
5m
4, 3
4
5m
System.out.println("5");
}
}
}
What will be the output on
executing the following code?
m
1, 0 m
2, 15 m
3, 5 m
4, 10 m
3, The class
will execute
without any
output. m
2, Unchecked 3, Runtime
exception m exception m
1, public m
2, abstract m 3, static m
4, protected m
1,
2,
3,
4, NumberFormatException m3
NullPointerExce SecurityExcep FileNotFoundE
ption m
tion m
xception m
2, throws m
3, try m
4, this m
2, private m
3, public m
4, final m
1, class
Example2
abstract class Example1
extends
{
Example1
abstract void display();
{
void displayAll()
public static
{
void main(String
System.out.println("Hello"); [] args)
}
{
}
Example1 e1
= new
Which of the following code on Example1();
execution will display the
following output?
e1.displayAll();
}
Hello
}m
m
2, class
3, class
4, class Example2 extends
Example2
Example2
Example1
extends
extends
{
Example1
Example1
public static void
{
{
main(String [] args)
public static void display() {
void
{
Example2.display();
main(String [] }
}
args)
public static }
{
void
m
Example1 main(String []
e2 = new
args)
Example2();
{
Example2
e2.displayAll() e2 = new
;
Example2();
}
}m
e2.displayAll();
}
}
m
3, The code
on execution
will display
var2. m
1, The
Example2 class
will execute
without any
output. m
2, The
Example2
class will
execute with
the following
output:
5m
3, The
4, The Example2 class will
Example2
not execute as it does not
class will not calls the constructor of the
compile as it Example 1 class. m
does not calls
the constructor
of the Example
1 class. m
1, 12Java m
2,
3, 12Java
4, The code will throw an
2
12Programmi Programming exception of type
ng m
Language m ArrayIndexOutOfBoundsExce
ption. m
System.out.println(str1+str2+st
r3);
}
What will be the output on
executing the preceding code
with the following command:
java Example 1 2 Java
Programming Language
}
m
AY086 To display a panel you must
add it to __________.
m
4, draw() m
2,
mouseExited(
MouseEvent)
m
3,
4,
1
mouseEntered mouseClicked(MouseEvent)
(MouseEvent) m
m
3, Both
4, Both Statement A and B
Statement A are false. m
and B are true.
m
frame.add(button, "Center");
Statement B: The code to add
a button object to the center
region of a frame using border
layout is:
frame.add(button,
BordeLayout.CENTER)
Select the correct option for
the preceding statements.
m
AY094 Which of the following method 1,
2,
3,
4, container.setLayout(null);
enables you to disable the
container.setLay container.layo container.layou m
layout manager for a
out(0); m
ut(null); m
t(0); m
container?
m
1,
2,
3, f.add(mb);
f.addMenubar(m f.setManubar( m
b); m
mb); m
4, f.set(mb); m
2, The output
will display a
window with
six buttons
arranged in
two rows and
three
columns. m
1, Both
2, Statement 3, Statement A 4, Both Statement A and
Statement A and A is true while is false while Statement B are true. m
Statement B are Statement B Statement B is
Statement A: You can create a false. m
is false. m
true. m
new thread by extending the
Thread class.
Statement B: You can create a
new thread by implementing
the Runnable interface.
Select the correct option for
the preceding statements
m
1,
2,
3,
4,
4
threadObj.getPri threadObj.set threadObj.setP threadObj.setPriority(THREA
ority(THREAD.M Priority(MAX_ riority(THREA D.MAX_PRIORITY); m
AX_PRIORITY); PRIORITY); D.PRIORITY);
m
m
m
3, The code
will execute
with the
following
output:
Hello
Hello
Hello m
1, The code will 2, The code 3, The code 4, The code will display the
display the
will display
will not display following output:
public class Example extends following output: the following any output. m
Thread
output:
Hello
{
Hello m
Hello
public static void
Hello
Hello
main(String argv[])
Hello
Hello m
{
Hello
Example obj
Hello
= new Example();
Hello m
obj.run();
}
public void start()
{
for (int i = 0; i
<5; i++)
{
System.out.println("Hello");
}
}
}
What will be the output of the
preceding code?
m
2,
3,
4, FilterInputStream and
PipedInputStr BufferedInputS FilterOutputStream m
eam and
tream and
PipedOutputS BufferedOutpu
tream m
tStream m
1, Both
2, Statement 3, Statement A 4, Both Statement A and
Statement A and A is true while is false while Statement B are false. m
Statement B are Statement B Statement B is
Statement A: To implement a true. m
is false. m
true. m
TCP/IP server, you can use
the ServerSocket class of the
java.net package.
Statement B: a TCP/IP client
uses the Socket class of the
java.net package.
2, write() m
3, flush() m
4, read() m
2, Writer m
3, InputStream 4, OutputStream m
m
1, Filter m
2, Output m
3, Input m
4, Print m
2, yield() m
3, run() m
4, start() m
2, 65535 m
3, 100000 m
4, -7070 m
1, Both
2, Statement 3, Statement A 4, Both Statement A and
Statement A and A is true while is false while Statement B are false. m
Statement B are Statement B Statement B is
true. m
is false. m
true. m
2, The code
will copy the
content of the
OutputFile.txt
file to the
InputFile.txt
file. m
}
}
}
}
What will be the output of the
above code?
m
1, import
java.io.*;
public class
Example
{
public static
void
main(String[]
args)
{
2, import
java.io.*;
public class
Example
{
public static
void
main(String[]
args)
{
String str;
try
{
Thread.sleep(4000);
System.out.println(info[i]);
}
}
}
Select the correct option.
m
AY124 Consider an example.txt file
saved in your working
directory that contains the
following content:
User Name = Admin
Password = Administrator
Host = localhost
3, import
4, import java.io.*;
2
java.io.*;
public class Example
public class
{
Example
public static void
{
main(String[] args)
public static {
void
try
main(String[]
{
Which of the following code
args)
FileReader fr = new
will you use to read the
{
FileReader("example.txt");
content of the example.txt file
String str;
BufferedReader br = new
and display it on console?
try
try
BufferedReader(fr);
m
{
{
FileReader fr
FileReader
while (br.readLine()!=null)
= new
FileReader fr fr = new
FileReader("exa = new
FileReader(ex System.out.println(br.readLine
mple.txt");
FileReader("e ample.txt);
());
xample.txt");
BufferedReader
BufferedReade } catch (IOException e)
br = new
BufferedRead r br = new
{
BufferedWriter(fr er br = new BufferedReade
);
BufferedRead r(fr);
System.out.println(e.getMess
er(fr);
age());
System.out.printl
while ((str
}
n(br.display());
while ((str =
}
} catch
=
br.readLine()) m
(IOException e) br.readLine()) !=null)
{
!=null)
System.out.pri
System.out.printl System.out.pri ntln(str);
n(e.getMessage(ntln(str);
));
} catch
}
}
}
m
} catch
(IOException
(IOException e)
e)
{
{
System.out.pri
System.out.pri ntln(e.getMess
ntln(e.getMes age());
sage());
}
}
}
}
}
}
m
m
1, DataAdapter 2, DataTable 3,
4, DataRelationCollection m 1
m
m
DataTableColl
ection m
1, DataTable m 2,
3,
4, DataColumnCollection m
DataTableColl DataRelationC
ection m
ollection m
4, DataReader m
3,
4, Modifiers m
RowStateFilter
m
1, Provider m
2, Initial
Catalog m
3, Integrated
Security m
4, User ID m
2, Library
refers to the
Server login
account m
3, Library
4, Library refers to the
1
specifies the provider for the connection m
name of the
server, which
is used in an
open
connection m
1,
2,
3,
4,
2
bindingNavigatorbindingNaviga BindingSource bindingNavigatorMoveLastIte
PositionItem text torCountItem m
m button m
box m
text box m
2, The code
will give an
error. The
parameters
mentioned in
the
constructor of
the
SqlParameter
class are in
an incorrect
sequence. m
String query =
"SELECT * FROM Employee
WHERE cemployeeCode =
employeecode";
SqlCommand cmd =
new SqlCommand(query,
con);
cmd.Parameters.Add(new
SqlParameter("employeecode
", searchemployeecode));
SqlDataReader dr =
cmd.ExecuteReader();
dr.Read();
MessageBox.Show(dr[1].ToStr
ing());
MessageBox.Show(dr[2].ToStr
ing());
Identify whether the preceding
code will give the desired
output or not. m
AY138 John is assigned a task to
1, The code will 2, The code
develop a window based
throw an
will give an
application in which the name exception. In the error. The
and department of an
term
parameters
employee is displayed on the employeecode, mentioned in
screen based on a particular '@' sign should the
employee id. The details of the be removed. m constructor of
employee are stored in the
the
Employee table present in the
SqlParameter
HR database. He has
class are in
developed a code to
an incorrect
implement the same. Refer to
sequence. m
the following partial code:
SqlConnection con =
new SqlConnection();
con.ConnectionString
= "Data Source=
SQLSERVER01; Initial
Catalog=HR; User ID=sa;
Password=niit#1234";
con.Open();
string
searchemployeecode;
searchemployeecode
= textbox1.Text;
String query =
"SELECT * FROM Employee
WHERE cemployeeCode =
@employeecode";
SqlCommand cmd =
new SqlCommand(query,
con);
cmd.Parameters.Add(new
SqlParameter("@employeeco
de", searchemployeecode));
SqlDataReader dr =
cmd.ExecuteReader();
dr.Read();
MessageBox.Show(dr[1].ToStr
ing());
MessageBox.Show(dr[2].ToStr
ing());
Identify whether the preceding
code will give the desired
output or not. m
con);
cmd.Parameters.Add(new
SqlParameter(searchemploye
ecode, "@employeecode"));
SqlDataReader dr =
cmd.ExecuteReader();
dr.Read();
MessageBox.Show(dr[1].ToStr
ing());
MessageBox.Show(dr[2].ToStr
ing());
Identify whether the preceding
code will give the desired
output or not. m
output or not. m
2, Find() m
3, Add() m
4, InsertAt() m
4, OriginalRows m
2, 4 m
3, 5 m
4, 24 m
2, InsertAt() m 3, Find() m
4, Select() m
1, It filters those
records where
the value of
Price is 100 m
2, It filters
those records
where the
value of Price
is other than
100 m
3, It filters
those records
where the
value of Price
is 100 and
sorts them in
an ascending
order m
cmd.ExecuteRe
ader();
while
(dr.Read())
{
textBox2.Text Convert.ToStri
=
ng((cmd.Execu
Convert.ToStri teScalar()));
ng(cmd.Execu
teNonQuery()) textBox3.Text
;
=
textBox2.Text =
Convert.ToStri
Convert.ToString textBox3.Text ng((cmd.Execu
((dr[1]));
=
teScalar())); m
Convert.ToStri
textBox3.Text = ng(cmd.Execu
Convert.ToString teNonQuery())
((dr[2]));
;m
}m
cmd.Execute
while
Scalar();
(dr.Read())
comboBox1.Item
while
{
s.Add(dr[0]);
(dr.Read())
}m
{
comboBox1.Ite
ms.Add(dr[0]);
comboBox1.It
}m
ems.Add(dr[0]
);
}m
((dr[1]));
ng((dr[1]));
{
textBox3.Text =
textBox2.Text
Convert.ToString textBox3.Text =
((dr[2]));
=
Convert.ToStri
}m
Convert.ToStri ng((dr[1]));
ng((dr[2]));
textBox3.Text
}m
=
Convert.ToStri
ng((dr[2]));
}m
textBox1.Text;
ds.Tables["Empl row["empId"]
oyees"].Rows.A =
row["empNam
dd(row);
textBox1.Text; e"] =
textBox2.Text;
adapter.Update( row["empNam
ds,
e"] =
row["empSal"]
"Employees"); m textBox2.Text; =
textBox3.Text;
row["empSal"]
=
ds.Tables["Em
textBox3.Text; ployees"].Row
s.Add(row); m
ds.Tables["Em
ployees"].Row
s.Add(row);
adapter.Updat
e(ds,
"Employees");
m
Catalog=HR;User
id=sa;Password=niit#1234";
SqlConnection cn =
new SqlConnection();
cn.ConnectionString =
connectionString;
cn.Open();
SqlCommand cmd =
cn.CreateCommand();
cmd.CommandType =
CommandType.Text;
cmd.CommandText =
"select * from Employees
where empId=@eCode";
=
textBox3.Text
Convert.ToStri =
ng((dr[1]));
Convert.ToStri
ng((dr[2]));
textBox3.Text
}
=
dr.Close(); m
Convert.ToStri
ng((dr[2]));
}
dr.Close(); m
cmd.Parameters.Add(new
SqlParameter("@eCode",empl
oyeeCode));
textBox2.Text =
Convert.ToString((cmd.Execut
eScalar()));
textBox3.Text =
Convert.ToString((cmd.Execut
eScalar()));
cn.Close();
However, the code does not
give the desired output.
Identify the problem in the
preceding code and provide a
solution for the same. m
AY157 MyCalInc. Ltd. is a
1, The code will
multinational call center
throw an
company whose branches are exception. It is
spread in different parts of the necessary to
world. It has got a centralized mention the
database system wherein the name of the
details of all the employees
provider in the
are stored. As a part of the
connection
development team, John is
string. m
assigned a task to develop a
windows based application in
which the details of an
employee are displayed on the
screen on entering the unique
id of the employee. He has
developed a partial code in
which the values of the first
two columns of an employee
are being displayed on
entering the employee id. The
details of the employees are
stored in an Employees table
of the HR database. Refer to
the following code snippet:
2, The code
will execute
but will not
give any
output. m
string employeeCode;
employeeCode =
textBox1.Text;
string connectionString =
"Data
Source=SQLSERVER01;Initial
Catalog=HR;User
id=sa;Password=password";
SqlConnection cn = new
SqlConnection();
cn.ConnectionString =
connectionString;
cn.Open();
SqlCommand cmd =
cn.CreateCommand();
cmd.CommandType =
CommandType.Text;
cmd.CommandText = "select *
from Employees where
empId=@eCode";
SqlDataReader dr =
cmd.ExecuteReader();
while (dr.Read())
{
textBox2.Text =
Convert.ToString((dr[1]));
textBox3.Text =
Convert.ToString((dr[2]));
}
dr.Close();
cn.Close();
Identify whether the preceding
code will give the desired
output or not. m
cn.CreateCommand();
cmd1.CommandType
= CommandType.Text;
cmd1.CommandText =
"delete from Products where
productId=@pCode";
cmd1.Parameters.Add(new
SqlParameter("@pCode",
productCode));
SqlDataReader dr1 =
cmd1.ExecuteReader();
cn.Close();
However, on execution, an
exception occurs. Identify the
problem in the preceding
code. m
2, You cannot
use a single
SqlDataRead
er object to
implement
more than
one operation
on a table m
new SqlConnection();
cn.ConnectionString =
connectionString;
cn.Open();
SqlCommand cmd =
cn.CreateCommand();
cmd.CommandType =
CommandType.Text;
cmd.CommandText =
"select * from Products where
ProductId=@pCode";
cmd.Parameters.Add(new
SqlParameter("@pCode",
productCode));
SqlDataReader dr =
cmd.ExecuteReader();
while (dr.Read())
{
textBox2.Text =
Convert.ToString((dr[1]));
textBox3.Text =
Convert.ToString((dr[2]));
}
SqlCommand cmd1 =
cn.CreateCommand();
cmd1.CommandType
= CommandType.Text;
cmd1.CommandText =
"delete from Product where
productId=@pCode";
SqlDataReader dr1 =
cmd1.ExecuteReader();
cn.Close();
However, on execution, an
exception occurs. Identify the
problem in the preceding
code. m
1, ALTER
DATABASE HR
ENABLE
SERVICE_BRO
KER; m
2, ALTER
DATABASE
HR SET
ENABLE_BR
OKER; m
3, ALTER
4, ALTER DATABASE HR
2
DATABASE
ENABLE SERVICEBROKER;
HR SET
m
ENABLE_SER
VICEBROKER
;m
1, SqlBulkCopy 2,
3,
4, SqlCommand m
m
SqlDataRead SqlConnection
er m
m
2, 5 m
3, 0 m
4, 1 m
2, By
specifying the
length of data
to be deleted
as null. m
3, By
4, By specifying the length of 1
specifying the data to be deleted as None.
length of data m
to be deleted
as an empty
string. m
2, String m
3, Binary m
4, Image m
2, Int m
3, Image m
4, Binary m
2, int, int,
3, byte, byte, 4, int, byte, int, respectively m 1
byte,
int,
respectively m respectively m
2, Binary m
3, Image m
4, String m
ds.Tables["Im ges"].Rows.Ad
ages"].Rows. d(row);
Add(row);
adapter.Updat
adapter.Updat e(ds,
e(ds,
"Images"); m
"Images"); m
{ bw.Write(outbyt tBytes();
outbyte, 0,
} // Code for
e);
while bufferSize);
displaying image in the
(retval ==
while picture box
}m
bw.Flush();
bufferSize)
(retval ==
{
bufferSize)
startIndex +=
{
bufferSize;
bw.Write(outb
yte);
bw.Write(outby
retval =
te);
myReader.GetB bw.Flush();
ytes(startIndex,
bw.Flush();
outbyte,
startIndex +=
bufferSize);
bufferSize;
startIndex +=
}
bufferSize;
retval =
..
myReader.Ge retval =
} // Code tBytes();
myReader.Get
for displaying
} Bytes(0,
image in the
} startIndex,
picture box
outbyte, 0,
}m
..
bufferSize);
} //
}
Code for
}
displaying
image in the ..
picture box
} //
}m
Code for
displaying
image in the
picture box
}m
AY174 You have been asked to
1,
2,
3,
4, TransactionOptions options 4
create an application that will TransactionOpti TransactionO TransactionOp = new TransactionOptions();
insert a record each into the ons options =
ptions options tions options =
Departments table and the
new
= new
new
options.IsolationLevel =
HRUsers table of the HR
TransactionOpti TransactionO TransactionOp
database. You need to ensure ons();
ptions();
tions();
System.Transactions.Isolation
that dirty reads, nonLevel.Serializable; m
repeatable reads, and
options.Isolation options.Isolati options.Isolatio
phantom reads are avoided Level =
onLevel =
nLevel =
during the transaction. Which
System.Trans
of the following code snippet System.Transact actions.Isolati System.Transa
correctly does the required
ions.IsolationLev onLevel.Read ctions.Isolation
task? m
el.ReadCommitt Uncommitted; Level.Read; m
ed; m
m
command.CommandText =
"Select Photo from Employee
where
employeeCode='E009'";
photoPtr =
(byte[])command.ExecuteScal
ar();
}
using
(SqlCommand command =
connection.CreateCommand()
)
{
command.CommandText =
"UPDATETEXT
Employee.Photo @Pointer
@Offset null @Data";
..
..
}
However, when Peter
executes the code, he is
getting the exception "Invalid
text, ntext, or image value".
What might be causing this
problem? m
AY177 The records stored in the
1, using
2, using
3, using
4, using (SqlConnection sc = 1
Stores table of
(SqlConnection (SqlConnectio (SqlConnectio new
AdventureWorks database
sc = new
n sc = new
n sc = new
SqlConnection(connectionStri
have accidentally got deleted. SqlConnection(c SqlConnectio SqlConnection ng))
However, there is a backup
onnectionString) n(connectionS (connectionStri
{ sc.Open();
copy of this table called
)
tring))
ng))
SqlCommand
StoresBackup. You have
commandSourceData = new
written the following code in { sc.Open();
{ sc.Open(); { sc.Open(); SqlCommand("SELECT *
the click event of a button to
FROM StoresBackup;", sc);
copy the records from
SqlCommand SqlCommand SqlCommand
SqlDataReader
StoresBackup to Stores:
commandSourc commandSou commandSour reader =
using (SqlConnection eData = new
rceData =
ceData = new commandSourceData.Execut
sc = new
SqlCommand("S new
SqlCommand( eReader();
SqlConnection(connectionStri ELECT * FROM SqlCommand( "SELECT *
using
ng))
StoresBackup;", "SELECT *
FROM
(SqlConnection dc = new
{ sc.Open();
sc);
FROM
StoresBackup; SqlConnection(connectionStri
SqlCommand
StoresBackup ", sc);
ng))
commandSourceData = new SqlDataReader ;", sc);
{ dc.Open();
SqlCommand("SELECT *
reader =
SqlDataReade
using
FROM StoresBackup;", sc); commandSourc SqlDataRead r reader =
(SqlBulkCopy bulkCopy =
SqlDataReader
eData.ExecuteR er reader =
commandSour new SqlBulkCopy(dc))
reader =
eader();
commandSou ceData.Execut
commandSourceData.Execute
using rceData.Exec eReader();
{ bulkCopy.DestinationTable =
Reader();
(SqlConnection uteReader();
"Stores";
using
dc = new
using
(SqlConnection dc = new
SqlConnection(c using
(SqlConnectio bulkCopy.WriteToServer(read
SqlConnection(connectionStri onnectionString) (SqlConnectio n dc = new
er); } m
ng))
)
n dc = new
SqlConnection
{ dc.Open();
SqlConnectio (connectionStri
using
{ dc.Open();
n(connectionS ng))
(SqlBulkCopy bulkCopy = new
tring))
SqlBulkCopy())
using
{ dc.Open();
{
(SqlBulkCopy { dc.Open();
bulkCopy = new
using
bulkCopy.DestinationTableNa SqlBulkCopy(dc) using
(SqlBulkCopy
me = "Stores";
)
(SqlBulkCopy bulkCopy =
bulkCopy = new
bulkCopy.WriteToServer();
{ bulkCopy.Desti new
SqlBulkCopy())
}}
nationTableNam SqlBulkCopy(
e = "Stores";
dc))
{ bulkCopy.De
However, the preceding code
stinationTable
is not working. Analyze the
bulkCopy.WriteT { bulkCopy.De Name =
problem and identify which of oServer(reader); stinationTable "Stores";
the following code snippets
}m
Name =
will perform the required task?
"Stores";
bulkCopy.Write
m
ToServer(read
bulkCopy.Writ er); } m
eToServer(); }
m
AY178 Samuel needs to update the 1,
2,
3,
4, TransactionOptions
2
HRUsers table and the
TransactionOpti TransactionO TransactionOp options = new
Department table of the HR ons options;
ptions options tions options = TransactionOptions();
database using distributed
= new
new
transaction. The transaction options.Isolation TransactionO TransactionOp options.IsolationLevel =
should be such that volatile
Level =
ptions();
tions();
System.Transactions.Isolation
data cannot be read during theSystem.Transact
Level.ReadUncommitted;
transaction but can be
ions.IsolationLev options.Isolati options.Isolatio
using
modified. To perform this task, el.ReadCommitt onLevel =
nLevel =
(TransactionScope ts = new
Samuel writes the following
ed;
System.Trans System.Transa TransactionScope())
code:
using actions.Isolati ctions.Isolation
{ using
TransactionOptions
(TransactionSco onLevel.Read Level.ReadCo (SqlCommand cmd = new
options; options.IsolationLevel pe ts = new
Committed; mmitted;
SqlCommand("INSERT INTO
=
TransactionScop
using Department(cDepartmentCod
System.Transactions.Isolation e())
using
(options)
e) VALUES(2013)", cn))
Level.ReadUncommitted;
{ using (TransactionS
{ int
using (options)
(SqlCommand cope ts = new { using
rowsUpdated =
{ .
cmd = new
TransactionSc (SqlCommand cmd.ExecuteNonQuery();
using
SqlCommand("I ope())
cmd = new
if
(SqlCommand cmd = new
NSERT INTO
SqlCommand( (rowsUpdated > 0)
SqlCommand("INSERT INTO Department(cDe { using
"INSERT INTO
{using
Department(cDepartmentCod partmentCode) (SqlCommand Department(c (SqlCommand cmd1 = new
e) VALUES(2013)", cn))
VALUES(2013')" cmd = new
DepartmentCo SqlCommand("INSERT INTO
{ int
, cn))
SqlCommand( de)
HRusers(cUserName)
rowsUpdated =
"INSERT
VALUES(2013 VALUES('Hansel')", cn1))
cmd.ExecuteNonQuery();
{ int
INTO
)", cn))
{ int
if
rowsUpdated = Department(c
rowsUpdated1 =
(rowsUpdated > 0)
cmd.ExecuteNo DepartmentC { int
cmd1.ExecuteNonQuery();
{ using
nQuery();
ode)
rowsUpdated
if
(SqlCommand cmd1 = new
VALUES(201 =
(rowsUpdated1 > 0)
SqlCommand("INSERT INTO if (rowsUpdated 3)", cn))
cmd.ExecuteN
HRusers(cUserName)
> 0)
onQuery();
{ts.Complete();
VALUES('Hansel')", cn1))
{ int
{ int
{ using
rowsUpdated if
..}}}}} m
rowsUpdated1 =
(SqlCommand =
(rowsUpdated
cmd1.ExecuteNonQuery(); if cmd1 = new
cmd.Execute > 0)
(rowsUpdated1 >0)
SqlCommand("I NonQuery();
ts.Complete();
NSERT INTO
{ using
..}}}}
HRusers(cUser if
(SqlCommand
However, the code is not
Name)
(rowsUpdated cmd1 = new
serving the required purpose. VALUES('Hansel> 0)
SqlCommand(
Identify the problem and
'')", cn1))
"INSERT INTO
suggest a solution. Assume
{ { using
HRusers(cUse
that two connection objects cn int
(SqlCommand rName)
and cn1 have been created. m rowsUpdated1 = cmd1 = new VALUES('Hans
cmd1.ExecuteN SqlCommand( el')", cn1))
onQuery();
"INSERT
INTO
{int
if
HRusers(cUs rowsUpdated1
(rowsUpdated1 erName,cPas =
> 0)
sword)
cmd1.Execute
VALUES('Han NonQuery();
{ ts.Complete(); sel','Lord')",
cn1))
if
..}}}}} m
(rowsUpdated
{ int
1 > 0)
rowsUpdated
1=
{ ts.Complete()
cmd1.Execute ;
NonQuery();
}}}}}
if
m
(rowsUpdated
1 > 0)
{ ts.Complete
();
}}}} m
AY181 Which of the following is not a 1, Durability is 2, Any change 3, Durability 4, Durability ensures that any 3
property of durability? m
ensured by
in data due to ensures that change in data by a
taking back ups a completed data is in a
completed transaction
of data and
transaction
reliable state remains permanently in effect
restoring
persists even after a
in the database. m
transaction logs. in the event of transaction is
m
a system
completed
failure. m
successfully to
maintain
integrity of the
data. m
1, By setting the
value of
Permissionstate
to None m
2,
3, Rollback() m4, EndTransaction() m
BeginTransact
ion() m
2,
3,
4, CloseOutput m
NewLineChar ConformanceL
sm
evel m
1, string
2, string
3, string
4, string
str=dataset1.Co str=dataset1. str=GetXml(da str=dataset1.GetXml(); m
nvert.GetXml; m GetXml; m
taset1); m
1, Schemas m
2,
3,
4, DiffGram m
IgnoreSchem WriteSchema
am
m
1, Read() m
2,
3,
4, ReadString() m
MoveToNextA ReadNextElem
ttribute() m
ent() m
2, The
3, The
4, The contents of
2
contents of
contents of
dsIntCandidate, which
dsIntCandidat dsIntCandidate contains the
e, which
, which
InternalCandidate.xml file, will
contains the contains the be appended to
InternalCandi InternalCandid dsExtCandidate, which
date.xml file, ate.xml file, will contains the
will be
be appended ExternalCandidate.xml file. A
appended to to
new file CandidateDetails.xml
dsExtCandida dsExtCandidat file be created that will
te, which
e, which
contain the merged data. The
contains the contains the contents of dsIntCandidate
ExternalCandi ExternalCandi will be displayed in a
date.xml file. date.xml file. A DataGridView control. m
A new file
new file
CandidateDet CandidateDeta
ails.xml file be ils.xml file be
created that created that
will contain
will contain the
the merged merged data.
data. The
The
contents of
DataGridView
dsExtCandida control will not
te will be
display
displayed in a anything. m
DataGridView
control. m
CandidateDetails.xml");
DataSet dsDisplay =
new DataSet();
dsDisplay.ReadXml("C:\\Candi
dateDetails.xml",
XmlReadMode.InferSchema);
dataGridView1.DataSource =
dsDisplay.Tables[0].DefaultVie
w;
What will happen when the
Operate button is clicked? m
1, It examines 2, It ignores
the XML data
any inline
and selects the schema m
appropriate
option m
AY195 Consider the following XML 1, The XSD file 2, The XML 3, The PRICE 4, The statement
4
file, products.xml:
is not incorrect. file is not well- element
xmlns="urn:product-schema"
<?xml version="1.0"?>
m
formed. m
cannot have a is missing in the XML file. m
<PRODUCTDATA>
negative value.
<PRODUCT>
m
<PRODUCTNAME>Barbie
Doll</PRODUCTNAME>
<PRICE>-200</PRICE>
<DESCRIPTION>Toy</DESC
RIPTION>
<QUANTITY>0</QUANTITY>
</PRODUCT>
</PRODUCTDATA>
Consider the schema file,
products.xsd:
<xsd:schema
xmlns:xsd="http://www.w3.org/
2001/XMLSchema"
xmlns="urn:product-schema"
elementFormDefault="qualifie
d"
targetNamespace="urn:produc
t-schema">
<xsd:element
name="PRODUCTDATA"
type="prdata"/>
<xsd:complexType
name="prdata">
<xsd:sequence>
<xsd:element
name="PRODUCT"
type="prdt"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType
name="prdt">
<xsd:sequence>
<xsd:element
name="PRODUCTNAME"
type="xsd:string"/>
<xsd:element
name="DESCRIPTION"
type="xsd:string"/>
<xsd:element
name="PRICE"
type="xsd:positiveInteger"/>
<xsd:element
name="QUANTITY"
type="xsd:nonNegativeInteger
"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
When you are validating the
XML file against the schema
using XmlReader, you are not
getting any output. What is the
possible cause? m
AY196 The employee details of
1, using
2, using
3, using
4, using (SqlConnection conn 2
QuickSolutions Software Ltd. (SqlConnection (SqlConnectio (SqlConnectio = new SqlConnection())
are stored in an XML format in conn = new
n conn = new n conn = new
{
an EMP table of an HR
SqlConnection())SqlConnectio SqlConnection
string
database. You are working as
{
n())
())
connectionString = "Data
a .NET developer in
string
{
{
Source=SQLSERVER01;Initia
QuickSolutions Software Ltd. connectionString
l Catalog=HR;User
You have been asked to
= "Data
string
string
ID=sa;Password=niit#1234";
create an application that will Source=SQLSE connectionStri connectionStri
retrieve these details and
RVER01;Initial ng = "Data
ng = "Data
conn.ConnectionString =
display them in a DataGrid
Catalog=HR;Us Source=SQLSSource=SQLS connectionString;
control. Which of the following er
ERVER01;Initi ERVER01;Initi
conn.Open();
code snippets will allow you to ID=sa;Password al
al
using
perform the required task? m =niit#1234";
Catalog=HR; Catalog=HR;U (SqlCommand cmd =
User
ser
conn.CreateCommand())
conn.Connection ID=sa;PasswoID=sa;Passwo
{
String =
rd=niit#1234"; rd=niit#1234";
connectionString
cmd.CommandText =
;
conn.Connecti conn.Connecti "SELECT * FROM EMP";
onString =
onString =
using
conn.Open();
connectionStri connectionStri (SqlDataReader rdr =
using ng;
ng;
cmd.ExecuteReader())
(SqlCommand
{
cmd =
conn.Open(); conn.Open();
while
conn.CreateCo
(rdr.Read())
mmand())
using
using
{
(SqlCommand (SqlCommand
cmd =
cmd =
SqlXml e =
cmd.CommandT conn.CreateC conn.CreateCo rdr.GetSqlXml(0);
ext = "SELECT * ommand())
mmand())
if (!e.IsNull)
FROM EMP";
{
{
{
// ds is the
using
cmd.Comman cmd.Comman object of DataSet
(SqlDataReader dText =
dText =
rdr =
"SELECT *
"SELECT *
ds.ReadXml(CreateReader());
cmd.ExecuteRe FROM EMP"; FROM EMP";
}
ader())
}
{
using
using
}
(SqlDataRead (SqlDataRead
}
while
er rdr =
er rdr =
(rdr.Read())
cmd.Execute cmd.ExecuteR dataGrid1.DataSource = ds;
{ Reader())
eader())
}m
{
{
SqlXml e =
while
rdr.GetSqlXml(0) (rdr.Read())
;
{
if (e.IsNull)
while
(rdr.Read())
{
SqlXml e =
SqlXml e =
rdr.GetSqlXml rdr.GetSqlXml(
// ds is the object (0);
);
of DataSet
if (!e.IsNull) if (!e.IsNull)
ds.ReadXml(e.C
reateReader()); {
{
}
// ds is the
} object of
}
DataSet
// ds is the
object of
DataSet
}
ds.ReadXml(e ds.ReadXml(e.
dataGrid1.DataS .CreateReade CreateReader(
ource = ds;
r());
));
}m
}
}
}
}
}
}
}
}
dataGrid1.Dat dataGrid1.Dat
aSource = ds; aSource = ds;
}m
}m
1, using
2, using
3, using
(XmlWriter writer (XmlWriter
(XmlWriter
=
writer =
writer =
XmlWriter.Creat XmlWriter.Cre XmlWriter.Cre
e("C:\\OrderDeta ate("C:\\Order ate("C:\\Order
ils.xml"));
Details.xml")) Details.xml"))
{
{
{
writer.WriteEn writer.WriteEn
dElement(); dElement();
writer.Flush(); writer.Flush();
}m
}m
1,public static
void Main()
{
XmlSchemaSet
schemaSet =
new
XmlSchemaSet(
);
1, static void
Main(string[]
args)
{
Console.Write
Console.Write Line("\tMessag
Line("\tMessa e :{0}",
ge :{0}",
args.Message)
args.Message ;
);
}
}
m
m
<AUTHOR>Robert Louis
Stevenson</AUTHOR>
</BOOK>
<PRICE>20</PRICE>
</BOOKDETAILS>
m