You are on page 1of 83

The __________ principle states that while designing an interactive product, the SM interfaces should have similar operations

B20 and should use similar elements for similar 01 tasks. 1, Visibility Which of the following principles of SM interactive design states that it is important B20 to keep the users informed about their 02 actions?

2, Consistency

3, Feedback

4, Constraints

1, Visibility

2, Feedback

3, Constraints

4, Affordances

Which of the following options is a lifecycle SM model that is selected by designers when 1, Usability B20 the project is small and they want to use a engineering 03 flexible lifecycle model? model _________ requirements capture the system goals with respect to effectiveness, efficiency, safety, utility, learnability, and memorability of a product. Which of the following data gathering techniques involves having a conversation with the participants where the researcher orally solicits responses? NewTech Book Store has launched its website to sell books to its customers around the world. The website displays thumbnails of books being sold instead of displaying the names of books in text. Which of the following cognition elements has been applied by NewTech in their website?

2, Star model

3, Conceptual Model

4, User's Mental Model

SM B20 04 SM B20 05

1, Data

2, Environmental 3, Usability

4, User

1, Questionnaires 2, Focus groups 3, Interviews

4, Naturalistic observation

SM B20 06

1, Perception

2, Attention

3, Language

4, Memory

NewTech Book Store has launched its website to sell books to its registered users all over the world. The website provides a link to register new users. When a new user clicks the link to register himself/herself, the New User Registration page opens in a separate window. This page is then used to enter and submit the essential user details. After the site was launched, it was observed that the feature worked fine in Windows XP Operating System (OS). However, when the same link is clicked in Mac OS or Linux OS, the page is not displayed as the new window does not get opened. In the preceding scenario, analyze and SM provide the requirements that have not B20 been considered by NewTech while 07 developing its website?

1, Functional requirements

2, User requirements

3, Data requirements

4, Non-functional requirements

A team of engineers at MobiDick, Inc. has developed a mobile phone. Before launching it in the market, they decided to test the usability and acceptance of the phone on a sample population. As per the feedback received, the team got to know that the phone is difficult to use and its features cannot be easily apprehended. Also, the user interface of the phone is very 1, The team complicated. Because of this, the team will should have now have to redesign the mobile phone. designed the physical model SM Analyze the situation and suggest which of before the B20 the following implementations could have conceptual 08 avoided this rework by the team? model.

2, The team should have developed the users' mental model before physical model.

3, The team should have developed the conceptual model before physical model.

4, The team should have developed the star model before users' mental model. 3

SM Which of the following options is NOT a B20 factor that is to be considered for selecting 09 the appropriate prototyping technique?

1, Budget and 2, Navigation time constraints and flow 1, For better visual clarity, you should divide the screen into various functional areas.

SM Which of the following is NOT a correct B20 guideline to be followed while designing a 10 GUI for touch screens?

2, Menu items should be at least 3 mm in size.

4, Location and 3, Look-and-feel of accessibility of the application stakeholders 3, The size of the push button in a touch screen should be less than 2x2 cm and they should be spread out on the screen 4, 3x3 layout with a spacing of should be used to 10 mm. enter numbers.

SM B20 11

SM B20 12

Jim is creating a website for an organization. He needs to ensure that the links for Site Map, Contact Us, and Home should be displayed on top of all the pages of the website. Provide the strategy that Jim should adopt to display the links. Jim has been working upon a website of his organization to make sure that it gets displayed on handheld devices as well. After the launch it was observed that maximum percentage of users accessing the website over their mobile phones had to scroll down a number of screens before reaching the links pointing to relevant content. Jim's manager has now asked him to modify this new version of the website such that the users are able to find relevant

1, Jim should create mirror links.

2, Jim should create global links.

3, Jim should create local links.

4, Jim should create the links as a marquee.

1, Jim can use the linear 2, Jim can use migration the original display display

3, Jim can use the filtered display

4, Jim can use the splash screen display

1, The correct sequence of the working procedure for WoZ is: 1. A user sits in front of a screen that contains the rough design of the application. A developer sits behind the screen. A human typist sits in another room. 2. The user Bryan needs to develop an intelligent interacts with software-based application. Before starting the screen by with the development, he wants to first asking identify the users' expectations from the questions about application. His manager has asked him to the working of implement the Wizard of Oz (WoZ) the SM prototyping technique to accomplish the application. B20 same. Provide the correct sequence of 3. The 13 steps for implementing the same to Bryan. developer

2, The correct sequence of the working procedure for WoZ is: 1. A user interacts with the screen by asking questions about the working of the application. 2. The human typist types the conversation. 3. This conversation is analyzed to gather feedback. 4. The feedback is shared with the designer, who then incorporates the changes in the design.

3, The correct sequence of the working procedure for WoZ is: 1. A user sits in front of a screen that contains the rough design of the application. A developer sits behind the screen. A human typist sits in another room. 2. The user interacts with the screen by asking questions about the working of the application. 3. The developer answers the user. 4. The human typist types the conversation. 5. The designer incorporates the

4, The correct sequence of the working procedure for WoZ is: 1. A developer sits in front of a screen that contains the rough design of the application. A user sits behind the screen. 2. The developer interacts with the screen by asking questions about the working of the application. 3. The user answers the developer. 4. The human typist types the conversation. 5. This conversation is analyzed to gather feedback. 1

1, Stage 1: In the first stage, the experts are briefed about what they are expected to do. Stage 2: In the second stage, experts may evaluate a product in two Morrison needs to get the website phases, look developed by his team to be tested for and feel of the usability. Morrison has certain predefined product in the parameters for the evaluation. Therefore, first phase and he wants to get the heuristic evaluation specific SM performed for the website. Provide him with usability B20 the sequence of stages for implementing features in the 14 the same. second phase. A team of software engineers at NewTech Labs needs to develop a console-based operating system. The operating system should respond to the commands typed by the users in the console window. Before starting with the development, the manager wants a conceptual model to be developed by the team. You need to identify, from the SM following options, the type of conceptual B20 model that should be developed for the 15 operating system being developed.

2, Stage 1: In the first stage, experts may evaluate a product in two phases, look and feel of the product in the first phase and specific usability features in the second phase.

3, Stage 1: In the first stage, the experts are briefed about what they are expected to do. Stage 2: In the second stage, experts come together to share their findings, which includes analyzing the problems encountered and Stage 2: In the suggesting second stage, appropriate the experts are solutions. then briefed Stage 3: In the third about what they stage, experts may are expected to evaluate a product do. in two phases, look

4, Stage 1: In the first stage, experts come together to share their findings, which includes analyzing the problems encountered and suggesting appropriate solutions. Stage 2: In the second stage, experts may evaluate a product in two phases, look and feel of the product in the first phase and specific usability features in 1

1, The conceptual model should be instructionbased.

2, The conceptual model should be conversationbased.

3, The conceptual model should be based on direct manipulation.

4, The conceptual model should be exploring and browsing-based.

SM B20 16

SM B20 17

Alice needs to develop a conceptual model for a car game being developed by her team. The game requires the players to select race tracks, cars, and car specifications. The players can also select whether the gear mode for their selected car should be automatic or manual. In addition, the players can also change the color of their cars. Identify the model that best suits the game. In addition, provide the reason because of which Alice should develop that model. While giving a lecture on principles of interactive design, John informed the participants that they could reduce the number of errors in an application by making the administrator-related features as inactive when a normal user works on the application. He further informed the participants that this is an implementation of the visibility principle of interactive design. Analyze whether the knowledge imparted by John regarding the design principle is correct. If not, provide the correct information that John should have given to the participants?

1, Alice should develop an exploring and browsing-based model for the game because the game involves exploring and browsing for the car models.

3, Alice should 2, Alice should develop a develop an manipulating and instructionnavigating-based based model for model for the game the game because the game because the requires users to user will be select, move, and giving drag elements of commands and the game just as controlling the they would do in game. the physical world.

4, Alice should develop a conversationbased model for the game because the users are required to search for particular information while using the game.

1, Yes, the principle specified by John correctly identifies the knowledge imparted to the participants.

2, No. The principle that reflects the knowledge imparted by John is the Consistency principle.

3, No. The principle that reflects the knowledge imparted by John is the Affordances principle.

4, No. The principle that reflects the knowledge imparted by John is the Constraints principle.

Joanna is creating an application that displays the current time to the users. In addition to displaying the time, she wants to give the users the flexibility of viewing either an analog clock or a digital clock. However, she needs to ensure that the time displayed in either of the interface is always correct. She has decided to use Vector graphics to implement this functionality in the application. Analyze if Joanna will be able to SM accomplish the requirement. If not, provide B20 from the following options, the feature that 18 will enable her to implement the same.

1, Yes. The required functionality can be implemented by using Vector graphics.

2, No. The required functionality can be implemented by using Lookless controls in the application.

3, No. The required functionality can be implemented by using the Grid layout control in the application.

4, No. The required functionality can be implemented by using Canvas layout in the application. 2

You are creating a Web application that displays various wildlife images to the users. One page may display 4 to 5 images to the users. To avoid overlapping of the images on the page, you have decided to SM place them by specifying x and y B20 coordinates. Which of the following layouts 19 will you use to accomplish the same? 1, Grid layout Jenny is required to conduct an interview for a number of participants. She needs to gather data regarding personal details and academic qualifications of each of the participants. She has a set of questions which she will be asking in a particular SM sequence from each participant. Identify the B20 type of interview that Jenny is implementing 1, Structured 20 in the current scenario. interview SM Which of the following model is used when B20 the user wants to search for particular 21 information or wants to discuss an issue?

2, Dock panel

3, Stack panel

4, Canvas layout

2, Unstructured interview

3, Semi-structured interview

4, Group interview

1, Instructionbased model

3, Manipulating and 4, Exploring and 2, Conversation- navigating-based browsing-based based model model model

SM B20 The _________ prototyping technique 22 describes each action sequentially.

1, storyboard

2, sketching

3, Wizard of Oz

4, computer-based simulation 1

SM B20 _________ screen controls can be used to 23 set attributes, properties, or values. 1, Selection SM B20 In _______ layout, controls are placed in 24 the form of x and y coordinates. SM B20 Which of the following options is NOT a 25 direct observation technique? Which of the following keywords is used to resolve ambiguity between instance SM variables and parameters? In addition, it is B20 also used to pass the current object as a 26 parameter to another method? SM B20 Which of the following files contains the 27 code for the Java Virtual Machine (JVM)? SM Which of the following keyword declares B20 that the attribute is accessible only to the 28 methods within the same class? SM B20 Which of the following options is used to 29 declare and initialize a character variable?

2, Text entry

3, Operable

4, Canvas

1, grid

2, canvas

3, dock panel

4, stack panel

2, Audio 1, Notes and a recording and a still camera still camera 3, Video camera

4, Interaction logging

1, super

2, this

3, abstract

4, static

1, .java file

2, .class file

3, .jar file

4, .mf file

1, public

2, private

3, default

4, protected

1, Char ch = "S";

2, char ch = "S"; 3, Char ch = 'S';

4, char ch = 'S';

You have written the following code to create a java program: class Hi { public void japp() { System.out.println("Java Application"); } } class Hello { public void disp() { System.out.println("Display"); } } public class MyApp { public static void main(String[] args) { Hello obj = new Hello(); Hi obj1 = new Hi(); obj.disp(); obj1.japp(); SM } B20 30 }

1, Hi.java

2, Hello.java

3, MyApp.java

4, Welcome.java

Which of the following refers to the SM methodology of hiding certain elements of B20 the implementation of a class but providing 1, 31 a public interface for the client software? Polymorphism A constructor is defined with in a java class SM which takes int as an argument. What will B20 be the output, if you instantiate the class 32 object without passing any parameter? 1, It will invoke the construct defined within the class.

2, Inheritance 2, It will generate compile time error.

3, Encapsulation 3, It will automatically invoke the default constructor.

4, Abstraction

4, It will generate runtime error.

SM You need to declare a variable in a java B20 class. Which of the following identifiers will 33 you use to accomplish the desired task? While compiling a java program, you need to reroute the class files to another SM directory. Which of the following options of B20 the javac command will you use to 34 accomplish the desired task? Identify the reference variable in the MyApp class in the following code snippet: class Hello { private int d=1; private int m=1; public Hello(int day, int month) { System.out.println("day:"+day); System.out.println("Month:"+month); } } public class MyApp { public static void main(String[] args) { int i,j; Hello obj = new Hello(5,10); }

1, thisOne

2, this

3, -One

4, 5One

1, -classpath

2, -sourcepath

3, -extdirs

4, -d

SM B20 35 }

1, The variable obj is a reference variable in the MyApp class.

2, The variable i is a reference variable in the MyApp class.

3, The variable d is a reference variable in the MyApp class.

4, There is no reference variable in the MyApp class.

Consider the following code: class Example { public void display() { System.out.println("Display in base class."); } } public class example1 extends Example{ public void display() { super.display(); System.out.println("Display in derived class."); } public static void main(String[] args) { example1 s = new example1(); s.display(); } SM } B20 36 Identify the output of the preceding code.

2, The output of the given code 3, The output of the 1, The output of is: given code is: the given code is: Display in base Display in derived class. class. Display in Display in Display in base derived class. derived class. class.

4, The output of the given code is: Display in base class.

While writing a Java code you need to SM declare an integer array that can hold 10 B20 elements. Which of the following options will 1, int[] a = new 2, int[10] a = 37 you use to accomplish the desired task? int[10]; new int[];

3, int[] a = new int[9];

4, int[9] a = new int[];

SM B20 Which of the following options refers to 38 method overloading in Java?

1, 1. The functions should have same name. 2. The functions can have different return type. 3. The functions should have different argument list. 4. The functions should be defined in the same class.

2, 1. The functions should have same name. 2. The functions can have different return type. 3. The functions should have different argument list. 4. The functions can be defined in the different class.

3, 1. The functions should have same name. 2. The functions can have same return type. 3. The functions can have same argument list. 4. The functions should be defined in the same class.

4, 1. The functions should have same name. 2. The functions can have different return type. 3. The functions can have same argument list. 4. The functions can be defined in the different class.

You have created a base class STUDENT, and a derived class STUD_DETAILS in a java program. Now, you want to use the STUD_DETAILS class to invoke the SM constructor of the STUDENT class. Identify B20 the correct keyword that you should use to 39 accomplish the desired task? 1, super Consider the following code snippet that contains two string s1 and s2, which contains the value NIIT and Niit respectively: String s1="NIIT"; String s2="Niit";

2, abstract

3, static

4, virtual

SM Identify the correct statement to compare 1, 2, 3, 4, B20 the two given string values in the preceding System.out.prin System.out.printl System.out.println(s System.out.println( 40 statements. tln(s1=s2); n(s1.equals(s2)); 1==s2); s1.equal(s2)); 2

1, public class poly_demo { public static void main(String[] args) { Object [] obj=new Object[3]; obj[0]=new Double(1.1d); obj[1]=new Sam has been assigned a task to create a Integer(1); Java application to create a heterogeneous obj[2]=new collection, in which all the items have a Float(1.0f); SM common ancestor class. B20 Identify the correct code that Sam should } 41 use to accomplish the desired task. } 2, public class poly_demo { public static void main(String[] args) { Date[] obj = new Date[2]; obj[0] = new Date(23,4,2009); 3, public class poly_demo { 4, public class poly_demo {

public static void public static void main(String[] main(String[] args) args) { { Object [] obj=new Date[] obj = new Object[3]; Date[2]; obj[0]=new obj[0] = new Object(1.1d); Object(23,4,2009); obj[1]=new Object(1); obj[1] = new obj[1] = new obj[2]=new Date(23,5,2009); Date(23,5,2009); Object(1.0f); } } } } } }

Consider the following code snippet: public class enh_demo { int sum(int[] a) { *** } public static void main(String args[]) { int[] i={1,2,3}; enh_demo obj= new enh_demo(); obj.sum(i); } } Sam has been assigned a task to write the method definition of the sum method. The sum method should use enhance for loop such that it displays SM the sum of the values given in the array. B20 Identify the correct code that Sam should 42 use to accomplish the desired task.

1, int sum(int[] a) { int res = 0; for (int i : a) res += i;

2, int sum(int[] a) { int res = 0; for (int i : res) res += i;

3, int sum(int[] a) { int res = 0; for (int i : a) res += a;

4, int sum(int[] a) { int res = 0; for (int i : res) res += a;

System.out.prin System.out.printl System.out.println(r System.out.println( tln(res); n(res); es); res); return res; return res; return res; return res; } } } } 1

1, public class Loop_demo { public static void main(String [] args){ int sum=0; int i; for(i=0; i<10; i++){

2, public class Loop_demo { public static void main(String [] args){ int sum=0; int i; for(i=0; i<10; i++){ 3, public class Loop_demo { 4, public class Loop_demo {

public static void public static void main(String [] main(String [] args){ args){ int sum=0; int sum=0; int i; int i; for(i=0; i<10; if(i%2!=0) for(i=0; i<=10; i++){ if(i%2==0) { i++){ if(i%2!=0) { System.out.printl if(i%2==0) { System.out.prin n(i); { System.out.println(i tln(i); System.out.println(i ); sum=sum+i; ); } }} } sum=sum+i; sum=sum+i; sum=sum+i; }} } } System.out.printl n("Sum of all Sam has been assigned a task to write a System.out.prin even System.out.println(" System.out.println( java program to print the even numbers tln("Sum of all numbers:"+sum) Sum of all even "Sum of all even SM between 0 to 10 and their sum. Identify the even ; numbers:"+sum); numbers:"+sum); B20 correct code that Sam should use to numbers:"+sum } } } 43 accomplish the desired task. ); } } } 3

Consider the following code: public class mdim_demo { public static void main(String [] args){ int arr[][] = new int[4][]; arr[0] = new int[1]; arr[1] = new int[2]; arr[2] = new int[3]; arr[4] = new int[4]; int i,j,k = 0; for(i=0; i<4; i++) for(j=0; j<i+1; j++) { arr[i][j] = k; k++; } for(i=0; i<3; i++) { for(j=0; j<i+1; j++) System.out.print(arr[i][j]); System.out.println(); } }

2, It will generate the following output: 1, It will generate a runtime error. 0 12 345

3, It will generate the following output: 0 12 34

SM B20 } 44

4,It will generate a compile time error. 1

Consider the following code: class acc{ int a; private int b; void setvalue(int i){ b=i; } int getvalue(){ return b; } } public class acc_demo { public static void main(String [] args){ acc obj = new acc(); obj.a =11; obj.setvalue(33); System.out.println("Value of a:" + obj.a); System.out.println("Value of b using:"+obj.getvalue()); SM } B20 } 45 Identify the output of the preceding code. SM Which of the following options is used to B20 compare an object to a specified class 46 type? SM After creating an array, how can you use B20 the same reference variable to refer to an 47 entirely new array?

1, It will generate a compile time error as b has private access.

2, It will display the values assigned to a and b.

4, It will display 3, It will generate a only the value runtime error. assigned to a.

1, instanceof operator 1, int[] myArray = new int[6]; myArray = new int[10];

2, new operator 2, int myArray = new int[6]; myArray = new int[10];

3, Comparison operators 3, int[] myArray = new int(6); myArray = new int(10);

4, Bitwise operators 4, int myArray = new int(6); myArray = new int(10);

Consider the following java program: public class branching { public static void main(String[] args) { int i=0; int j=0; int k=0; if(i<3) { if(j<3) { if(k<3) { System.out.println("BRANCHING STATEMENT"); } } } } } SM B20 Identify the correct output of the preceding 48 program. 1, It will generate a runtime exception. 2, The code will compile and will print BRANCHING STATEMENT. 3, The code will compile but will not generate any 4, It will generate a output. compile time error. 2

Consider the following code snippet: public class op_demo { public static void main (String args []) { String str="Hi"; *** System.out.println(str); } } Sam has been assigned a task to modify the preceding code such that the given value of str is concatenated with "HOW ARE YOU?", and gives the following output: Hi How Are You? SM Identify the correct operator and statement B20 that Sam should use to accomplish the 49 desired task. SM Which of the following options gives the B20 default value for a variable of a char data 50 type? 1, str = str +" "+'How are you?'; 2, str = str +" "+"How are you?";

3, str = str +" "+ How are you?;

4, str = str + How are you?;

1, 0L

2, null

3, '\u0000'

4, 0

The two operands a and b are assigned the SM values 128 and 1 respectively. What will be B20 the result if left shift operation is performed 51 on the given operands a and b? 1, 256 You have created a method add() with in a class STUDENT. You want that the add() should only be accessible to the classes that belongs to the same package as that of SM a STUDENT class. Which of the following B20 access modifiers will you use to accomplish 52 the desired task? 1, private

2, -256

3, 64

4, -64

2, protected

3, default

4, public

SM B20 Which of the following options cannot have 1, Access 53 a polymorphic behavior? Modifiers Consider the following code: class demo { private int x=1; public void setValue() { int x=4, y=5; this.x = x+y; setNewValue(10); } public void setNewValue(int x) { int y=8; this.x = x+y; System.out.println(x); System.out.println(y); } } public class var_sc_demo { public static void main(String[] args) { demo obj = new demo(); SM obj.setValue(); B20 54 }

2, Method

3, Object

4, Variable

1, The output of 2, The output of the given code the given code is: is: 3, It will generate a compile time error 10 12 as x is a private 4, It will generate a 8 8 variable. runtime error. 1

Consider the following code: import java.lang.*; class copy { char[] a={'N','I','I','T'}; char[] b = {'C','o','u','r','s','e'}; public void copyArr() { *** }} public class arr_cpy { public static void main(String[] args) { copy obj = new copy(); obj.copyArr(); } }

1, System.arrayco Sam has been assigned a task to update py(a,0,b,0,a.len the preceding code such that it copies the gth); value of the array a to array b using the for(int arraycopy function. In addition, he has to i=0;i<b.length;i+ SM print the resultant. Identify the correct code +) B20 snippet that Sam should use to accomplish System.out.prin 55 the desired result. tln(b[i]);

2, System.arraycop y(a,0,b,0,b.lengt h); for(int i=0;i<b.length;i+ +) System.out.printl n(b[i]);

4, 3, System.arraycopy( System.arraycopy( 0,a,0,b,a.length); 0,a,0,b,b.length); for(int for(int i=0;i<b.length;i++) i=0;i<b.length;i++) System.out.println( System.out.println( b[i]); b[i]); 1

SM B20 Which of the following options is correct in 56 reference to the final keyword?

1, The main() method in java is a final method because JVM does not create an instance of the class when 2, The final executing the method can be main method. overridden.

4, The blank final instance variable 3, The final class must be assigned can be subclassed. in a constructor.

2,public static void main(String [] args) ArrayList<Integ { int er> list = new sum=0; ArrayList<Integ ArrayList er>(); list = new int ArrayList<Intege val[]={1,2,3,4,5} r>(); ; int for(int val[]={1,2,3,4,5}; i=0;i<val.length; i++) for(int { i=0;i<val.length;i list.add(i,val[i]); ++) { Sam has been assigned a task to create a list.add(i,val[i]); Java application that allows him to add the sum=sum+list.g elements in an array list and display the et(i); sum=sum+list.g sum of the values in the elements provided } et(i); SM in the list. Identify the correct code snippet System.out.prin } B20 that Sam should use to accomplish the tln(sum); System.out.printl 57 desired task. } n(sum);}

1,public static void main(String [] args) { int sum=0;

3,public static void main(String [] args) { int total=0; List list = new List(); int val[]={1,2,3,4,5}; for(int i=0;i<val.length;i++) { list.add(i,val[i]); sum=sum+list.get(i) ; } System.out.println(s um);}

4,public static void main(String [] args) { int total=0; ArrayList list = new List(); int val[]={1,2,3,4,5}; for(int i=0;i<val.length;i++ ) { list.add(i,val[i]); sum=sum+list.get(i ); } System.out.println( sum);} 1

Consider the following code: public class ex_demo { public static void main(String args[]) { int sum = 0; for ( int i = 0; i < args.length; i++ ) { sum += Integer.parseInt(args[i]); } System.out.println("Sum = " + sum); } } The preceding code displays the sum of the values passed through a command line and fails if any of the argument is not integer. SM Identify the correct code to handle the B20 exception generated if any of the argument 58 passed is not an integer.

1, public class ex_demo { public static void main(String args[]) { try { int sum = 0; for ( int i = 0; i < args.length; i++ ){ sum += Integer.parseInt (args[i]); } System.out.prin tln("Sum = " + sum); } catch (NumberFormat Exception n) {

2, public class ex_demo { public static void main(String args[]) { try { int sum = 0; for ( int i = 0; i < args.length; i++ ) { sum += Integer.parseInt( args[i]); } System.out.printl n("Sum = " + sum); } catch (NullPointerExce ption n) {

3, public class ex_demo { public static void main(String args[]) { try { int sum = 0; for ( int i = 0; i < args.length; i++ ) { sum += Integer.parseInt(arg s[i]); } System.out.println(" Sum = " + sum); } catch (ArithmeticExceptio n n) { System.err.println(" One of the command-line " + "arguments is not an integer."); } }}

4, public class ex_demo { public static void main(String args[]) { try { int sum = 0; for ( int i = 0; i < args.length; i++ ) { sum += Integer.parseInt(ar gs[i]); } System.out.println( "Sum = " + sum); } catch (EOFException n) { System.err.println(" One of the command-line " + "arguments is not an integer."); } }} 1

System.err.printl System.err.print n("One of the ln("One of the command-line " command-line " + "arguments is + "arguments is not an not an integer.");

Consider the following code snippet: public class a { static int i=0; public static void main(String[] a) {} } SM How many copies of the variable i would be B20 created, if you have created four objects of 59 class a? 1, One SM B20 If you apply ____ keyword to a class, the 60 class cannot be subclassed. SM B20 Which of the following formatting codes in 61 java uses scientific notations?

2, Two

3, Three

4, Four

1, final

2, static

3, abstract

4, protected

1, %g

2, %x

3, %s

4, %%

4, class intrf_demo implements Color{ public void Red(){ System.out.println( "Stop"); } public void Green(){ Consider the following code: System.out.println(" System.out.println( PAUSE"); "GO"); interface Color { public static void } } public void Red(); main(String[] public static void public static void public void Green(); System.out.prin args) { main(String[] args) main(String[] args) public void Yellow(); tln("PAUSE"); intrf_demo a= { { } } new intrf_demo a= new intrf_demo a= public static intrf_demo(); intrf_demo(); new intrf_demo(); Sam has created the preceding interface. void a.Red(); a.Red(); a.Red(); Now he has to create a class that main(String[] a.Green(); a.Green(); a.Green(); SM implements the preceding interface. Identify args) { a.Yellow(); a.Yellow(); a.Yellow(); B20 the correct code that Sam should use to intrf_demo } } } 62 accomplish the desired task. a= new } } } 1

1, public class intrf_demo implements Color{ public void Red(){ System.out.prin tln("Stop"); } public void Green(){ System.out.prin tln("GO"); } public void Yellow() {

2, public class intrf_demo implements Color{ public void Red(){ System.out.printl n("Stop"); } public void Green(){ System.out.printl n("GO"); }

3, class intrf_demo implements Color{ public void Red(){ System.out.println(" Stop"); } public void Yellow() {

Consider the following code: import java.util.*; public class itr_demo { public static void main(String[] args) { HashSet s=getValue(); Iterator iter=s.iterator(); while (iter.hasNext()) { iter.next(); System.out.println(s); } } static HashSet getValue() { HashSet<String> arrList=new HashSet<String>(); arrList.add("1"); arrList.add("2"); arrList.add("3"); SM arrList.add("4"); B20 return arrList; 63 }

1, [3, 2, 4, 1] [3, 2, 4, 1] [3, 2, 4, 1] [3, 2, 4, 1]

2, [1, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]

3, [1] [2] [3] [4]

4, [4] [3] [2] [1]

Consider the following code snippet: abstract class a { public abstract double sum(); public abstract double mul(); } public class b extends a { double a =40; double b=20; double c=0; public double mul() { c=b*a; System.out.println(c); return c; } SM } B20 Identify the correct output of the preceding 64 code snippet. Consider the following code: public class demo { public static void main(String args[]) { assert args.length-1==0; } } Sam has been assigned a task to turn on SM the assertion for the preceding code. B20 Identify which of the following commands 65 will Sam use to achieve this task.

1, It will generate a compile time error stating b is not an abstract class and does not override the sum method.

2, It will throw a runtime exception.

3, It will generate a compile time error 4, It will compile stating b class and execute inherit class a. successfully.

1, java demo

2, java demo file 3, java -ea demo

4, java -ea test file1

Consider the following code: enum Days { SUNDAY(1), MONDAY(2), TUESDAY(3); Days(int d) { this.d = d; } private int d; public int getdays() { return d; } } class demo1 { *** } Sam has been assigned a task to create a class that will print the values for the preceding enum and gives the following output: SUNDAY 1 MONDAY 2 SM TUESDAY 3 B20 Identify the correct code that Sam should 66 use to accomplish the desired task. SM Which of the following class is the base B20 class used for the unchecked exceptions 67 that arise as a result of program bugs?

3, class demo1 { Days num; public static void main(String[] args) { demo1 obj = new demo1(); 2, class demo1 obj.num = { Days.SUNDAY; Days num; System.out.println( 1, class demo1 public static void obj.num.getdays()); { main(String[] Days num; args) { demo1 obj1 = new public static demo1 obj = demo1(); void new demo1(); obj.num = main(String[] obj.num = Days.MONDAY; args) { Days.SUNDAY; System.out.println( demo1 obj = obj1.num.getdays() new demo1(); demo1 obj1 = ); for(Days dy: new demo1(); demo1 obj2 = new Days.values()) for(Days dy: demo1(); Days.values()) obj.num = System.out.prin System.out.printl Days.TUESDAY; tln(dy + " " + n(obj1.num.getd System.out.println( dy.getdays()); ays()); obj.num.getdays()); } } } } } 1, 2, RuntimeExcepti VirtualMachineE on rror 3, IOException

4, class demo1 { Days num; public static void main(String[] args) { demo1 obj = new demo1(); obj.num = Days.SUNDAY; demo1 obj1 = new demo1(); obj.num = Days.MONDAY; demo1 obj2 = new demo1(); obj.num = Days.TUESDAY; System.out.println( obj.num.getdays()); } }

4, AssertionError

SM Which of the following keywords makes a B20 variable accessible from any instance of the 68 class? 1, static

2, final

3, abstract

4, protected

SM B20 Which of the following keywords enable the 69 class to use the methods of an interface? 1, static Sam is creating a Java application. He wants to create a method that should be invoked without creating an instance of the object at the runtime. SM Identify the keyword to be used to satisfy B20 the preceding scenario needed in main 70 method? 1, final SM The __________ clause defines a block of B20 code that always executes, regardless of 71 whether an exception was caught.

2, extends

3, implements

4, abstract

2, abstract

3, static

4, public

1, finally

2, final

3, throws

4, throw

SM B20 Which of the following methods returns the 1, 72 system property object? setProperties() Which of the following keywords is used to SM test the programmer's assumptions during B20 development without writing exception 73 handlers for an exception? 1, assert 1, It will not If the superclass method throws an throw an IOException, then which of the following exception of its SM statement is correct in reference to the own super B20 exceptions that can be thrown by the class, such as 74 overriding method? Exception.

2, getProperties()

3, getProperty()

4, setProperty()

2, finally 2, It will not allow you to declare any other exception in the throws clause.

3, throw

4, throws

4, It will not throw 3, It will not throw an FileNotFoundExcep IllegalArgumentExc tion exception. eption exception. 1

Consider the following code snippet: public class ServerTimedOutException extends Exception { private int port; public ServerTimedOutException(String message, int port) { super(message); this.port; } public int getport() { return port; } } Sam has written a client-server Java program. In the client code, he tries to connect to the server and expect the server to respond within five seconds. Now he wants that if the server does not respond within the specified time, the code should throw a user defined exception SM ServerTimedOutException. Identify the B20 correct code snippet that Sam should use to 75 accomplish the desired task. SM Which of the following exceptions is the B20 result of a divide-by-zero operation for 76 integers?

1, public void MyException(St ring servname) throws ServerTimedOu tException { boolean success; int p = 80; success = open(servname ,p); if(! success) { throw new ServerTimedOu tException("Not able to connect",p); } }

2, public void MyException(Stri ng servname) throw ServerTimedOut Exception { boolean success; int p = 80; success = open(servname, p); if(! success) { throws new ServerTimedOut Exception("Not able to connect",p); } }

3, public void MyException(String servname) throws ServerTimedOutEx ception { boolean success; int p = 80; success = open(servname,p); if(! success) { throw ServerTimedOutEx ception("Not able to connect",p); } }

4, public void MyException(String servname) throw ServerTimedOutEx ception { boolean success; int p = 80; success = open(servname,p); if(! success) { throws ServerTimedOutEx ception("Not able to connect",p); } } 1

1, 2, 3, 4, NumberFormat ArithmeticExcept IllegalArgumentExc NullPointerExcepti Exception ion eption on

Consider the following statements: Statement A: Set is an unordered collection which allows duplicate values. Statement B: List is an ordered collection that does not allow duplicate values. SM B20 Which of the following is correct in 77 reference to the preceding statements? 1, Both 2, Both 3, Statement A is statement A statement A and true, and statement and B are true. B are false. B is false. 3, public class command { public static void main(String[] args) { for(int i=0;i<args.length;i+ +) 4, Statement A is false, and statement B is true. 2 4, public class command { public static void main(String[] args) {

1, public class command { public static void main(String[] args) { for(int i=0;i<args.lengt h;i++) Anthony has been assigned a task to create a Java application that accepts the command-line argument either as a standalone tokens or as quoted strings. SM Identify the correct code that Anthony B20 should use to accept and print the 78 command-line arguments.

2, public class command { public static void main(String[] args) {

InputStreamReade r i = new InputStreamReade InputStreamReader r(args); i = new while((args=in.re InputStreamReader while((args=in.read adLine())!=null) (args); Line())!=null)

System.out.prin System.out.printl System.out.println(" System.out.println( tln("args["+i+"] n("args["+i+"] is " args["+i+"] is " "args["+i+"] is " is " +args[i]); +args[i]); +args[i]); +args[i]); } } } }

Consider the following code: import java.util.Properties; import java.util.Enumeration; public class prop_demo { public static void main(String[] args) { Properties props = System.getProperties(); Enumeration propNames = props.propertyNames(); while(propNames.hasMoreElements()) { String pName = (String) propNames.nextElement(); String prop = props.getProperty(pName); System.out.println(propNames+" "+prop); } SM } B20 } 79 Identify the output of the preceding code. 2, It generates a 1, It generates compile time 3, It retrieves the a runtime error. error. property value. 4, It retrieves the property name and value pair. 4

Consider the following code: class EMP { String empName; public void display() { System.out.println(empName); } } public class err_cat { EMP e[]; public err_cat() { for(int i=0;i!= 2;i++) { e[i] = new EMP(); } e[0].empName="Hello"; } public static void main(String args[]) { err_cat empObj; empObj = new err_cat(); SM } B20 } 80 Identify the output of the preceding code. Consider the following statements: Statement A: The Error class is the base class for unchecked errors. Statement B: The RuntimeException class is the base class that is used for unchecked exceptions that might arise as a result of program bug. SM B20 Which of the following is correct in 81 reference to the preceding statements? 1, Both 2, Both 3, Statement A is 4, Statement A is statement A statement A and true, and statement false, and and B are true. B are false. B is false. statement B is true. 1

1, It will generate a NullPointer Exception.

2, It will generate 3, It will generate a 4, It will generate StackOverFlowE IllegalArgumentExc OutOfMemoryError rror. eption. . 1

Consider the following code: public class asser_demo { static int n = 1; static int getnum() { return n--; } public static void main(String [] args) { int x; for (int i =0; i>5; i++) { x = getnum(); assert x == 0; System.out.println(x); } SM } B20 } 82 Identify the output of the preceding code.

1, It will give the following output: 1 2 3 4 5

3, It will generate the following output: 5 4 3 2 1 3, It is a PrintStream object that refers (initially) to the terminal window that launched the Java technology application.

2, It will execute successfully but no output will be generated.

SM Which of the following options is correct in B20 reference to the System.err variable of the 83 java.lang.System class?

1, It is an InputStream object that refers (initially) to the user's keyboard.

2, It is a PrintStream object that refers (initially) to the user's keyboard.

4, It will generate a runtime error. 2 4, It is an InputStream object that refers (initially) to the terminal window that launched the Java technology application. 3

Consider the following code: import java.io.*; public class demo { public static void main(String[] args) { String s; *** } } Sam has been assigned a task to read String information from the console SM standard input. Identify the correct code B20 snippet that Sam should use to accomplish 84 the desired task. Consider the following code snippet: import java.util.*; public class demo { public static void main(String[] args) { *** System.out.println(l); } } Sam has been assigned a task to create a Java application to create an ordered collection in which duplicate values are SM permitted. Identify the correct code snippet B20 that Sam should use to accomplish the 85 desired task.

1, InputStreamRe ader i = new InputStreamRe ader(System.in) ; BufferedReade r in = new BufferedReade r(i);

2, InputReader i = new InputReader(Sys tem.in); BufferedReader in = new BufferedReader( i);

3, BufferedReader in = new BufferedReader(Sy stem.in); InputStreamReader i = new InputStreamReader (in);

4, BufferedReader in = new BufferedReader(Sy stem.in); InputReader i = new InputReader(Syste m.i); 1

1, List l = new ArrayList(); l.add("ONE"); l.add(new Integer(4)); l.add("ONE");

2, Set l = new HashSet(); l.add("ONE"); l.add(new Integer(4)); l.add("ONE");

3, List l = new List(); l.add("ONE"); l.add(new Integer(4)); l.add("ONE");

4, Set l = new Set(); l.add("ONE"); l.add(new Integer(4)); l.add("ONE");

While building a Java GUI application, you need to create an item within a menu. SM Which of the following listener will you B20 implement that can be associated with the 86 MenuItem component? SM Which of the following layout managers is B20 the default layout manager for the Frame 87 and Dialog classes?

1, ActionListener

2, AdjustmentLister 3, ner ComponentListener 4, ItemListener

1, FlowLayout

2, BorderLayout 3, CardLayout

4, GridLayout

SM The _______ method tells the frame to set B20 a size that neatly encloses the components 88 that it contains. 1, setlayout() SM B20 Which of the following AWT components is 89 a top-level window with a title and a border? 1, Dialog SM B20 Which of the following methods belongs to 90 the ContainerListener interface?

2, pack()

3, add()

4, setVisible()

2, Frame

3, Panel

4, Canvas

1, 2, 4, componentAdd componentMove 3, componentShown( ed() d() componentHidden() ) 1 2, MenuComponen t 3, Insets

SM B20 The Container class is an abstract subclass 91 of ____________. 1, Component

4, Event

Consider the following code: import java.awt.*; public class jfc_demo { private Frame f; private Button b; public jfc_demo() { f = new Frame("GUI"); b = new Button("Add"); } public void disp() { f.setSize(200,200); f.setLayout(null); b.setSize(50,50); f.add(b); f.setVisible(true); }

SM public static void main(String args[]) B20 { 92 jfc_demo obj = new jfc_demo();

1, Step 1: Use the right imports: import javax.swing.*; Step 2: Use the right component names JFrame and JButton. Step 3: Address content pane issues: JFrame.getCon tentPane().add( Component)

2, Step 1: Use the right imports: import java.swing.*; Step 2: Use the right comonent names Jframe and Jbutton. Step 3: Address content pane issues: JFrame.getCont entPane().add(C omponent)

3, Step 1: Use the right imports: import javax.swing.*; Step 2: Use the right comonent names Jframe and Jbutton. Step 3: Address content pane issues: JFrame.add(Comp onent).getContentP ane()

4, Step 1: Use the right imports: import java.swing.*; Step 2: Use the right comonent names JFrame and JButton. Step 3: Address content pane issues: JFrame.add(Comp onent).getContent Pane() 1

1, import java.awt.*; public class MyFrame extends Frame { Panel p; public MyFrame() {

2, import javax.awt.*; public class MyFrame extends Frame { Panel p; public MyFrame() {

3, import java.Awt.*; public class MyFrame extends Frame { Panel p; public MyFrame() { super("Login"); p=new Panel(); add(p); setSize(100,100);

4, import javax.Awt.*; public class MyFrame extends Frame { Panel p; public MyFrame() { super("Login"); p=new Panel(); add(p); setSize(100,100);

super("Login"); super("Login"); p=new Panel(); p=new add(p); Panel(); add(p); setSize(100,100 ); setSize(100,10 0); setVisible(true); Sam has been assigned a task to create a frame of size 100, 100 which has a background of blue color. In addition, the SM frame should display "Login" as a title. B20 Identify the correct code that Sam should 93 use to accomplish the desired task.

setVisible(true); setVisible(true); } } public static void public static void setVisible(true); } main(String s[]) main(String s[]) public static { { } void main(String new new public static s[]) MyFrame(); MyFrame(); void { } } 1

Sam has been assigned a task to create a Java GUI application that create a frame having following properties: Width = 50 Height = 60 Back ground Color = Red Title = "WELCOME"

SM B20 Identify the correct code snippet that Sam 94 should use to accomplish the desired task. While creating a Java GUI application, you want to obtain the reference of the object SM that has generated the event. Which of the B20 following methods will you use to 95 accomplish this task? 1, getSource()

2, public class 1, public class frm_demo { frm_demo { private Frame private f; Frame f; public public frm_demo(String frm_demo(Strin title) g title) { f=new { f=new Frame("Welcom Frame("Welco e"); me"); } } public void public void launch() launch() { { f.setSize(60,50); f.setSize(50,60) ; f.setBackground f.setBackgroun (Color.red); d(Color.red); f.setVisible(true); f.setVisible(true ); } } } } }

4, public class 3, public class frm_demo { frm_demo { private Frame private Frame f; f; public public frm_demo(String frm_demo(String title) title) { f=new { f=new Frame("Welcome") Frame("Welcome"); ; } } public void public void launch() launch() { { f.setSize(60,50); f.setSize(50,60); f.setBackground.C f.setBackground.Co olor(RED); lor(RED); f.setVisible(true); f.setVisible(true); } } } } } 1

2, getActioncomma nd() 3, getModifiers()

4, getAnnotation()

Consider the following values, used to align the components within a container: LEFT, RIGHT, and CENTER. SM Which of the following layout manager uses B20 the preceding values to set the alignment of 96 the components? You need to implement a grid layout containing 5 rows and 2 columns. In addition, you need to ensure that the gaps between each column is 10 and the gap SM between each row is 15. Which of the B20 following code snippet will you use to 97 accomplish the desired task? Consider the following code snippet: import java.awt.*; import java.awt.event.*; public class demo implements MouseListener { private Frame f; private TextField t; 2, mousePressed( MouseEvent) } mouseReleased *** (MouseEvent) } mouseEntered( 1, MouseEvent) Sam has created a class which implements mouseDragged mouseExited(Mo SM MouseListener interface. Identify the (MouseEvent) useEvent) B20 methods that should be defined within the mouseMoved( mouseClicked(M 98 preceding class. MouseEvent) ouseEvent) public demo() { f = new Frame("WELCOME"); t = new TextField(20); 2, GridBagLayout Manager

1, FlowLayout Manager

3, GridLayout Manager

4, CardLayout

1,GridLayout gl=new GridLayout(5, 2,10,15);

2, GridLayout gl=new GridLayout(2, 5,10,15);

3, GridLayout gl=new GridLayout(2, 5,15,10);

4, GridLayout gl=new GridLayout(5, 2,15,10);

3, mousePressed(Mo useEvent) mouseReleased(M ouseEvent) mouseEntered(Mou seEvent) mouseExited(Mous eEvent) mouseClicked(Mou seEvent) mouseDragged(Mo useEvent) mouseMoved(Mous eEvent)

4, mouseExited(Mous eEvent) mouseClicked(Mou seEvent) mouseDragged(Mo useEvent) mouseMoved(Mou seEvent) 2

Consider the following code snippet: import java.awt.*; public class LayoutExample { private Frame f; private Button b1; private Button b2; public LayoutExample() { f = new Frame("GUI example"); b1 = new Button("Press Me"); b2 = new Button("Don't press Me"); } public void launchFrame() { f.setLayout(new FlowLayout()); f.add(b1); f.add(b2); f.setVisible(true); } public static void main(String args[]) { LayoutExample guiWindow = new LayoutExample(); guiWindow.launchFrame(); }} SM Sam has been assigned a task to modify B20 the preceding code such that it tells the 99 frame to set a size that neatly encloses the 1, f.pack();

SM B21 Which of the following is correct in 00 reference to a panel in Java?

4, f.setSize(); 1 4, A panel is a free1, A Frame is a standing native type of panel window on the with a title and 2, A panel must display that is corners that be placed into a 3, A panel is a type independent of can be resized. window. of component. other containers. 2

2, f.add();

3, f.setLayout();

SM B21 Which of the following is correct in 01 reference to the FileOutputStream class?

SM Sam has been assigned a task to create a B21 TCP/IP client. Identify the correct code 02 snippet to accomplish the desired task.

1, The FileOutputStrea m constructor, overwrites the already existing output file. 1, public class MyClient { public static void main(String args[]) { Socket s = null; try { s = new Socket("127.0. 0.1",5432); } catch (IOException e) { e.printStackTra ce(); } }

2, The FileOutputStrea m constructor, appends the already existing output file. 2, public class MyClient { public static void main(String args[]) { Socket s = null; try { s = new Socket(5432); } catch (IOException e) { e.printStackTrac e(); } }

3, The FileOutputStream constructor, prompts an error if the output file already exists. 3, public class MyClient { public static void main(String args[]) { ServerSocket s = null; try { s = new ServerSocket("127. 0.0.1",5432); } catch (IOException e) { e.printStackTrace(); } }

4, The FileOutputStream constructor, creates a new file with any name if the output file already exists.

4, public class MyClient { public static void main(String args[]) { ServerSocket s = null; try { s = new ServerSocket(5432 ); } catch (IOException e) { e.printStackTrace() ; } } 1

Consider the following code snippet: import java.io.*; public class strm_demo { public static void main(String[] args) throws IOException { try { FileInputStream in = new FileInputStream("C:\\a.txt"); System.out.println("File found at the given location."); } catch(Exception ex) { ex.printStackTrace(); } } } 2, It will SM Identify the output of the preceding code, 1, It will generate a B21 assuming that the a.txt file already exists at generate a run compile time 03 the given location. time error. error.

4, It will display the following output: 3, It will not display File found at the any result. given location.

Consider the following code: import java.io.*; public class strm_demo { public static void main(String[] args) throws IOException { try { FileReader obj = new FileReader("C:\\a.txt"); char [] buffer = new char[128]; int c; c = obj.read(buffer); c = obj.read(buffer); System.out.println(c); } catch(Exception ex) { ex.printStackTrace(); }

SM B21 } 04 }

1, It will display the following 2, It will output: generate a compile time -1 error.

3, It will throw a runtime exception.

4, It will compile successfully and will not display any output. 3

Consider the following code snippet: System.out.println("Enter the Designation:"); *** ReadString = bufferStream.readLine(); Sam has been assigned a task to modify the given code snippet such that it forces the write operation to clear any accumilated SM data on the output stream. Identify the 1, B21 correct method that Sam should use to System.out.flus 05 accomplish the desired task. h(); Sam is creating a Java application. He has created an object of the Connection interface to establish a connection of the Java application with a database using the getConnection() method with a single parameter. 1, SM Identify the correct syntax for a JDBC URL <protocol>:<su B21 that Sam should pass as a parameter to the bprotocol>:<su 06 getConnection(). bname>

2, 4, System.out.reset 3, System.out.markS (); System.out.mark(); upported();

2, 3, 4, <protocol>:<sub <protocol>:<subna <protocol>:<subna protocol> me> me>:<subprotocol> 1

1, String str=" "; PreparedState Sam has created a Java application that ment ps = allows to access information stored in a con.prepareSta database "AUTH_DETAILS". Now, Sam tement(str); has been assigned a task to create a code ps.setString(1, that modifies the state to CA where city is "CA"); Oakland in the Authors table in the ps.setString(2, AUTH_DETAILS database using the "Oakland"); SM PreparedStatement object. Identify the int B21 correct code snippet that Sam should use to rt=ps.executeU 07 accomplish the desire task. pdate();

2, String str = "UPDATE Authors SET state= ? WHERE city= ? "; PreparedStatem ent ps = con.prepareStat ement(str); ps.setString(1, "CA"); ps.setString(2, "Oakland"); int rt=ps.executeUp date();

3, String str = " "; PreparedStatement ps = con.prepareStatem ent(UPDATE Authors SET state= ? WHERE city= ?); ps.setString(1, "CA"); ps.setString(2, "Oakland"); int rt=ps.Update();

4, String str = "UPDATE Authors SET state= ? WHERE city= ? "; PreparedStatemen t ps = con.prepareStatem ent(str); ps.setString(1, "CA"); ps.setString(2, "Oakland"); int rt=ps.Update(); 2

1, public synchronized char pop() { char ch; while(buffer.siz e()==0) { try { Sam is creating a java program that this.wait(); implements stacks. He has to create a }catch(Interrupt method having following features: edException 1) The method should protect the shared e) buffer so that no two users are able to { access the method simultaneously. } 2) If the stack is empty in the method, the ch = executing thread must wait. buffer.remove( buffer.size()SM Identify the correct code snippet for the 1); B21 method that Sam should use to accomplish return c; 08 the desired task. }

2, public char pop() { char ch; while(buffer.size ()==0) { try { this.wait(); }catch(Interrupte dException e) { } ch = buffer.remove(b uffer.size()-1); return c; }

3, public final char pop() { char ch; while(buffer.size()= =0) { try { this.wait(); }catch(InterruptedE xception e) { } ch = buffer.remove(buffe r.size()-1); return c; }

4, public static char pop() { char ch; while(buffer.size()= =0) { try { this.wait(); }catch(InterruptedE xception e) { } ch = buffer.remove(buff er.size()-1); return c; } 1

Consider the following code: public class th_demo extends Thread { int i=0; public static run() { while(i<10) { System.out.println("i="+i); } i++; } public static void main(String[] args) { Thread t = new th_demo(); t.start(); } } 1, It will generate a compile time error as the th_demo class is not implementing the Runnable interface.

SM B21 Identify the correct output of the preceding 09 code snippet. While creating a Java application, you need to reflect the changes made by the SM transactions in a database. Which of the B21 following method will you use to accomplish 10 the desired task? 1, commit() 1, While creating a TCP/IP server application, ServerSocket s SM you need to register your service on port = new B21 5232. Which of the following code snippet ServerSocket(5 11 will you use to accomplish the desired task? 432); SM B21 Which of the following packages is used to 12 access Thread class?

2, It will compile successfully and on calling start, it will print the value of i from 0 to 9.

3, It will not compile because the method run cannot have static keyword as a return type.

4, It will compile successfully and on calling start, it will print the value of i=0 infinitely.

2, rollback()

4, PrepareStatement( 3, executeUpdate() ) 1 4, ServerSocket s = new ServerSocket("127. 0.0.1",5432); 1

2, Socket s = new Socket("127.0.0. 3, Socket s = new 1",5432); Socket(5432);

1, java.lang

2, java.util

3, java.awt

4, java.io

Consider the following code: public class thread_demo extends Thread{ public static void main(String args[]) { for(int i=0;i<5;i++) new thread_demo().start(); } public void run() { System.out.println("Hello"); } } SM B21 Analyze the preceding code and identify the 13 correct output for the given code. While creating a thread in a Java application, you want to use a method that allows you to give other runnable threads a chance to execute. If other threads are runnable, the calling thread should be placed into the runnable pool and allows another runnable thread to run. Which of SM the following methods of the Thread class B21 will help you in accomplishing the desired 14 task? 2, It will 1, It will print generate a Hello five times. runtime error.

4, It will compile, and execute successfully but 3, It will generate a will not generate compile time error. any output.

1, Thread.yield()

2, Thread.join()

3, Thread.sleep();

4, Thread.wait()

Consider the following code: import java.sql.*; public class AuthorsInfo { public static void main(String args[]) { try { String str="SELECT * FROM Authors WHERE city LIKE 'S%'"; Class.forName("com.microsoft.sqlserver.jdb c.SQLServerDriver"); Connection con = DriverManager.getConnection("jdbc:sqlserv er://sqlserver01; databaseName=Library;user=user1;passwo rd=password#1234"); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery(str); System.out.println("Author ID\tAuthor Name\tCity"); while (rs.next()) SM { B21 String id=rs.getString("au_id"); 15 String name=rs.getString("au_name"); SM B21 Which of the following methods is used to 16 load the JDBC driver and registers it? SM The _______ object allows you to pass B21 runtime parameters to the SQL statements 17 using the placeholders.

1, It retrieve information (author id, name, address, city, and state) about the authors who are living in the city where the city name begins with the letter "S".

2, It retrieve information (author id, name, address, city, and state) about all the authors.

4, It will generate a 3, It will generate a compile time error runtime exception as the user needs due to database to import javax.sql access error. package. 1

1, forName()

2, getConnection() 3, absolute()

4, createStatement()

1, PreparedState ment 2, ResultSet

3, Connection

4, Statement

SM B21 18

SM B21 19

Which of the following methods of ResultSetMetaData interface retrieves the title of a table column corresponding to the index passed as a parameter to the method? Which of the following fields of the ResultSet interface specifies that the cursor of the ResultSet object is scrollable and it does not reflect changes in the data made by other users?

1, 2, getColumnLabe getColumnName 3, l() () getColumnCount()

4, getColumnType()

1, TYPE_SCROL 2, 3, 4, L_INSENSITIV TYPE_SCROLL CONCUR_READ_ CONCUR_UPDAT E _SENSITIVE ONLY ABLE 1 2, Native-API 1, JDBC-ODBC Partly-Java Bridge driver driver

SM B21 Which of the following drivers is called the 20 Type 1 driver?

3, JDBC-Net Pure- 4, Native Protocol Java driver Pure-Java driver

SM When the client requests a connection, the B21 server opens the socket connection with the 21 ________ method. 1, accept() SM B21 The PipedReader class is a type of 22 _______ stream. SM B21 Which of the following streams performs 23 conversion on another stream?

2, Socket()

3, readUTF()

4, getInputStream() 1

1, Byte

2, Processing

3, Node

4, Character

1, Byte stream 2, Node stream

3, Filter stream

4, Character stream

SM 1, B21 Which of the following classes contains the java.lang.Objec 2, 3, 24 wait and notify methods? t java.lang.Thread java.lang.Exception 3, It loads the 2, It returns the JDBC driver and SM Which of the following is correct in 1, It returns next exception in registers the driver B21 reference to the getSQLState() method of X/Open error the chain of with the 25 the SQLException class? code. exceptions. DriverManager.

4, java.lang.Error

4, It is used to create a Connection object. 1

SM B21 26 W3C stands for ___________________. You want to retrieve data from a data SM source in a read-only and forward-only B21 mode. Which of the following components 27 of a data provider will you use? SM Which of the following parameters of the B21 connection string is used to specify the 28 name of a database? SM Which of the following namespaces would B21 you include in your program to use the 29 functionality of the SqlConnection class? You are creating an application to retrieve data from a database in a read-only and forward-only mode. For this, you have written the following code snippet: SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Data Source= SQLSERVER01; Initial Catalog=HR; User ID=sa; Password=niit#1234"; connection.Open(); SqlCommand cmd = new SqlCommand("select * from monthlysalary"); SqlDataReader myReader = cmd.ExecuteReader();

1, World Wide Consortium

2, World Web Consortium

3, World Wide Web 4, World Web Consortium Wide Consortium

1, Connection

2, DataReader

3, Command

4, DataAdapter

1, Provider

2, Integrated Security

3, Data Source

4, Initial Catalog

1, System.Data.S qlClient 2, System.Data

4, System.Data.SqlTy 3, System.Data.Sql pes 1

3, The SqlCommand constructor should have the query and 2, The the connection myReader object as the object should be parameter. It initialized, as should be written shown in the as: 1, Instead of following code ExecuteReader snippet: SqlCommand cmd (), the SqlDataReader = new ExecuteNonQu myReader = SqlCommand("sele SM However, on execution, the code snippet is ery() method new ct * from B21 throwing a compilation error. Analyze the should be SqlDataReader() monthlysalary", 30 code snippet and identify the error. used. ; connection);

4, The connection string should also include the Integrated Security parameter and it should be set to true. 3

SM B21 31 SM B21 32

2, connection.State Change += new StateChangeEv entHandler(OnSt Sam has written the following code snippet protected static ateChange); to illustrate how the StateChange event is void protected static initialized during a connection: OnStateChang void e(object OnStateChange( connection.StateChange += new sender, object sender, StateChangeEventHandler(OnStateChange StateChangeEv StateChangeEv ); entArgs args) entArgs args) protected static void OnStateChange(object { { sender, StateChangeEventArgs args) { Console.WriteL Console.WriteLi Console.WriteLine("The current ine("The ne("The current Connection state current Connection state has changed from {0} to {1}.", Connection has changed OriginalState, CurrentState); state has from {0} to {1}.", } changed from sender.OriginalS {0} to {1}.", tate, However, when he compiled the code args.OriginalSt sender.CurrentS snippet, it threw an error. Analyze the code ate, tate); snippet and identify the correct code. args.CurrentSta } Which of the following parameters indicates that the database connection will be reset when the connection is removed from the 1, Connection pool? reset 2, Enlist

1, connection.Stat eChange += new StateChangeEv entHandler(On StateChange);

3, connection.StateCh ange += new StateChangeEvent Handler(OnStateCh ange); protected static void OnStateChange(ob ject sender, StateChangeEvent Args args) { Console.WriteLine( "The current Connection state has changed from {0} to {1}.", args.OriginalState, sender.CurrentStat e); }

4, connection.StateC hange += new StateChangeEvent Handler(OnStateC hange); protected static void OnStateChange(ob ject sender, StateChangeEvent Args args) { Console.WriteLine( "The current Connection state has changed from {0} to {1}.", sender.OriginalStat e, args.CurrentState); } 1

3, Pooling

4, Connection timeout

SM What would be the value of the Max pool B21 size parameter if you have not explicitly 33 specified any value?

1, 1000

2, 100

3, 50

4, 200

Sam is implementing connection pooling. He wants that the pooler opens a new connection instead of attempting to acquire a connection from the pool. For this, he has written the following code: SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Data Source=SQLSERVER01;user ID=sa; password=niit#1234;Initial Catalog=HR;Connection Timeout = 20; Pooling = true"; connection.Open();

1, The timeout should be increased so SM However, he found that the code does not that the pooler B21 fulfill the requirement. Analyze the code and can open a new 34 provide a solution. connection. SM Which of the following properties of a B21 TextBox control is used to bind the value of 35 a column in the dataset? 1, Locked SM You want to bind a ComboBox control to a B21 specific data element. Which of the 36 following properties will you use? SM B21 Which of the following benefits is NOT 37 provided by stored procedures?

2, The Max pool size parameter should be included in the connection string.

3, The Min pool size parameter should be included 4, The pooling in the connection parameter should string. be set to false.

2, Name

3, Tag

4, Text

1, The 2, The DisplayMember DataSource property property

3, The Items property

4, The Text property

1, precompiled 2, reduced execution network traffic

3, efficient reuse of 4, reduced code bandwidth

John has to develop an application that enables the users to retrieve the details of an employee from a database based on a employee code. He has written the following code snippet: 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 monthlySalary WHERE cemployeeCode = @employeecode"; SqlCommand cmd = new SqlCommand(query, con); SqlDataReader dr = cmd.ExecuteReader();

SM However, when he executed the code, it B21 threw an error. Analyze the code and 38 provide the solution. Which of the following properties of the SM DataView control enables you to specify an B21 expression/condition in a string format for 1, 39 filtering the records? RowStateFilter 2, RowFilter

1, After creating the command object, the parameters need to be added, as shown in the code snippet: cmd.Parameter s.Add(new SqlParameter(" @employeecod e", searchemploye ecode));

2, After creating the command object, the parameters need to be added, as shown in the code snippet: cmd.Parameters .Add("@employ eecode", searchemployee code);

3, After creating the command object, the parameters need to be added, as shown in the code snippet: cmd.AddParameter s(new SqlParameter("@e mployeecode", searchemployeeco de));

4, After creating the command object, the parameters need to be added, as shown in the code snippet: cmd.AddParameter s("@employeecod e", searchemployeeco de); 1

3, Sort

4, Modifiers

Sam wants to execute TableAdapter queries on the Click event of the ToolStripButton control. He wants to populate the data from the Sales datatable of the adventureWorks dataset. For this, he has written the following code snippet: private void ToolStripButton_Click(object sender, EventArgs e) { try {

1, private void ToolStripButton _Click(object sender, EventArgs e) { try {

2, private void ToolStripButton_ Click(object sender, EventArgs e) { try { this.internalCand idateTableAdapt er.Sales(this.adv entureWorksDat aSet.Fill); } catch (System.Excepti on ex) { System.Window s.Forms.Messag eBox.Show(ex.M essage); } }

3, private void ToolStripButton_Cli ck(object sender, EventArgs e) { try { this.internalCandid ateTableAdapter.Fil lBy(this.adventure WorksDataSet.Sale s); } catch (System.Exception ex) {

4, private void ToolStripButton_Cli ck(object sender, EventArgs e) { try { this.internalCandid ateTableAdapter.Fi lledBy(this.adventu reWorksDataSet.S ales); } catch (System.Exception ex) {

this.internalCan didateTableAda pter.Fill(this.adv this.internalCandidateTableAdapter.FillBy(th entureWorksDa is.adventureWorksDataSet.Sales); taSet.Sales); } } catch (System.Exception ex) catch { (System.Except ion ex) System.Windows.Forms.MessageBox.Sho { w(ex.Message); } System.Windo } ws.Forms.Mess ageBox.Show(e SM However, the code snippet is throwing an x.Message); B21 error. Analyze the code snippet and provide } 40 the solution. } SM B21 Which of the following objects is NOT 41 contained in the Connected classes? Which of the following properties of the SM DbCommand object indicates or specifies B21 how the CommandText property is 42 interpreted?

System.Windows.F System.Windows.F orms.MessageBox. orms.MessageBox. Show(ex.Message); Show(ex.Message) ; } } } } 3

1, DataAdapter 2, DataReader

3, Connection

4, Dataset

1, CommandType 2, Parameters

3, Transaction

4, Site

SM B21 43

SM B21 44 SM B21 45

Which of the following properties of a DataAdapter object refers to a DML statement or a stored procedure to retrieve data from a dataset? Which of the following Rule enumeration values deletes or updates the child DataRow object when the Parent DataRow object is deleted or its unique key is changed? Which of the following enumeration values of the DataViewRowState enumeration retrieves the current row version of all modified rows?

1, InsertComman 2, 3, d SelectCommand UpdateCommand

4, DeleteCommand 2

1, Cascade

2, None

3, SetDefault

4, SetNull

1, ModifiedOrigina l 2, CurrentRows 3, OriginalRows

4, ModifiedCurrent

Consider the following statements: Statement A: In the connected environment the data is always current and updated. Statement B: Connected environment leads to network congestion. 1, Both, SM Statement A B21 Which of the following options are correct in and Statement 46 context of the preceding statements? B, are true.

SM B21 47

SM B21 48

2, Both, Statement A and Statement B, are false. 2, By using the 1, By using the RefereneceEqua Equals() ls() method of method of the the How will you check whether the specified DbParameter DbParameter DbParameter object instances are same? object object 1, By adding a 2, By adding a RowUpdated RowUpdated() event to the method to the How will you determine the number of rows SqlDataAdapter SqlDataAdapter affected in the last batch? object. object. 1, ds.Merge(dsMi ssingSchemaA ction.Add); 2, ds.Merge(ds1, 0, MissingSchema Action.Add);

3, Statement A is 4, Statement B is true and Statement true and Statement B is false. A is false. 1 4, By using the GetHashCode() method of the DbParameter object 4, By adding a 3, By adding a Updated() method Updated event to to the the SqlDataAdapter SqlDataAdapter object. object. 3, By using the GetType() method of the DbParameter object 3, ds.Merge(ds1, false, MissingSchemaActi on.Add);

Sam wants to merge dataset ds1 with SM dataset ds. Which of the following code B21 snippet will he use to perform the desired 49 task?

4, ds.Merge(ds1, true, MissingSchemaAct ion.Add); 4

SM B21 How will you specify a sorting order on a 50 particular column of a DataView object?

1, By using the Sort() method of the DataView object 1, string connectionStrin g = "Data Source=SQLS ERVER01;Initia l Catalog=Emplo yee;User id=sa;Password =niit#1234";

2, By using the ApplyDefaultSort property of the DataView object 2, string connectionString = "Data Source=SQLSE RVER01;Initial Catalog=Employ ee;User id=sa;Password =niit#1234";

3, By using the Sort property of the DataView object 3, string connectionString = "Data Source=SQLSERV ER01;Initial Catalog=Employee; User id=sa;Password=nii t#1234";

4, By using the ApplyDefaultSort() method of the DataView object 3 4, string connectionString = "Data Source=SQLSERV ER01;Initial Catalog=Employee ;User id=sa;Password=ni it#1234"; SqlConnection cn = new SqlConnection(); cn.ConnectionStrin g= connectionString; cn.Open(); SqlCommand cmd = new SQLCommand(); cmd.CommandTyp e= CommandType.Te xt; cmd.CommandTex 2

SqlConnection SqlConnection cn = SqlConnection cn = new new cn = new SqlConnection(); SqlConnection(); SqlConnection( cn.ConnectionStrin ); cn.ConnectionSt g = cn.ConnectionS ring = connectionString; tring = connectionString connectionStrin ; SqlCommand cmd g; cn.Open(); = cn.Open(); cn.CreateComman You want to create a Windows form to SqlCommand d(); display the details of an employee with SqlCommand cmd = cmd.CommandTyp Employee ID 3150. You want to fetch the cmd = cn.CreateComm e = data by sending SQL command to the cn.CreateCom and(); CommandType.Tex SM database with the help of the DbCommand mand(); cmd.CommandT t; B21 object. Which of the following code snippets ype = 51 will you write to achieve the desired task? cmd.Command CommandType. cmd.CommandText

1, SqlConnection cn = new SqlConnection( ); cn.ConnectionS tring = "Data Source=SQLS ERVER01;Initia l Catalog=HR;Us er id=sa;Password =niit#1234";

You want to retrieve all details from the SM Departments database by using the B21 SqlDataAdapter object. Which of the 52 following code snippets will you use?

3, SqlConnection cn = new SqlConnection(); cn.ConnectionStrin g = "Data cn.ConnectionSt Source=SQLSERV ring = "Data ER01;Initial Source=SQLSE Catalog=HR;User RVER01;Initial id=sa;Password=nii Catalog=HR;Use t#1234"; r id=sa;Password DataSet DataSet1 =niit#1234"; = new DataSet(); SqlDataAdapter da DataSet = DataSet DataSet1 = new da.CreateSqlDataA DataSet1 = DataSet(); dapter(); new SqlDataAdapter DataSet(); da = new SqlCommand SqlDataAdapter SqlDataAdapter( cmd=new da = new ); SqlCommand("Sele SqlDataAdapter ct * from (); SqlCommand Departments", cmd=new cn); SqlCommand SqlCommand("S da.SelectCommand cmd=new elect * from = cmd; SqlCommand(" Departments",

2, SqlConnection cn = new SqlConnection();

4, SqlConnection cn = new SqlConnection(); cn.ConnectionStrin g = "Data Source=SQLSERV ER01;Initial Catalog=HR;User id=sa;Password=ni it#1234"; DataSet DataSet1 = new DataSet(); SqlDataAdapter da = new SqlDataAdapter();

SqlCommand cmd=new SqlCommand("Sel ect * from Departments"); da.Fill(DataSet1); 1

1, DataSet ds = 2, DataSet ds = new new DataSet(); DataSet(); DataTable dt = DataTable dt = ds.Tables.Add(" ds.Tables.Add( Department"); "Department"); dt.Columns.Add( "Department ID", dt.Columns.Ad typeof(string)); d("Department dt.Columns.Add( ID", "Department typeof(string)); Name", typeof(string)); dt.Columns.Ad dt.Columns.Add( d("Department "Region", Name", typeof(string)); typeof(string)); DataTable dt1 = dt.Columns.Ad ds.Tables.Add(" Sam wants to add two tables, Department d("Region", Employee"); and Employee, in a single dataset. He also typeof(string)); dt1.Columns.Ad wants to create a relation between the d("Department tables on a common field that is ID", Department ID. In addition, he wants to add DataTable dt1 typeof(string)); SM the tables' relation information in the = dt1.Columns.Ad B21 dataset. Which of the following code ds.Tables.Add( d("Employee 53 snippets will allow him to do so? "Employee"); ID", 1, DataView dv = new DataView(); dv.RowFilter = "Year > 1995"; dv.RowStateFilt er = DataViewRowS tate.Deleted; 2, DataView dv = dv.CreateDataVi ew(); dv.RowFilter = "Year > 1995"; dv.RowStateFilt er = DataViewRowSt ate.Deleted;

3, DataSet ds = new DataSet(); DataTable dt = ds.Tables.Add("De partment"); dt.Columns.Add("D epartment ID", typeof(string)); dt.Columns.Add("D epartment Name", typeof(string)); dt.Columns.Add("R egion", typeof(string)); DataTable dt1 = ds.Tables.Add("Em ployee"); dt1.Columns.Add(" Employee ID", typeof(string)); dt1.Columns.Add(" Employee Name", typeof(string)); dt.PrimaryKey =

4, DataSet ds = new DataSet(); DataTable dt = ds.Tables.Add("De partment"); dt.Columns.Add("D epartment ID", typeof(string)); dt.Columns.Add("D epartment Name", typeof(string)); dt.Columns.Add("R egion", typeof(string)); DataTable dt1 = ds.Tables.Add("Em ployee"); dt1.Columns.Add(" Department ID", typeof(string)); dt1.Columns.Add(" Employee ID", typeof(string)); dt1.Columns.Add(" Employee Name", 4

Sam wants to filter and delete the records SM from a DataView where the year is greater B21 than 1995. Which of the following code 54 snippets will he use to achieve the same?

4, DataView dv = dv.CreateDataView 3, DataView dv = (); new DataView(); dv.RowFilter = dv.RowFilter = "Year > 1995"; "Year > 1995"; dv.RowStateFilter dv.RowStateFilter = = DataViewRowState DataViewRowState .Delete; .Delete; 1

SM B21 55

SM B21 56

2, DataView dv John wants to sort two columns, Salary and 1, DataView dv = Year. He wants to sort the Salary column in = new dv.CreateDataVi the ascending order and the Year column in DataView(); ew(); the descending order. Which of the dv.Sort = dv.Sort = "Salary following code snippets allows him to do "Salary ASC, ASC, Year so? Year DESC"; DESC"; Peter has created an application in which 1, string val = 2, string val = he wants that a user should select an comboBox1.Te comboBox1.Text employee code from a combo box and the xt.ToString(); .ToString(); details of the selected employee are retrieved from the database. He has written string constr = string constr = the following code snippet in the "Data "Data application: Source=SQLS Source=SQLSE ERVER01;User RVER01;User string val = comboBox1.Text.ToString(); ID=sa;passwor ID=sa;password d=niit#1234;Initi =niit#1234;Initial string constr = "Data al Catalog=HR"; Source=SQLSERVER01;User Catalog=HR"; SqlConnection ID=sa;password=niit#1234;Initial SqlConnection con = new Catalog=HR"; con = new SqlConnection(); SqlConnection con = new SqlConnection( SqlConnection(); ); con.Connection con.ConnectionString = constr; con.Connection String = constr; con.Open(); String = con.Open(); constr; string str = "select * from employees where con.Open(); string str = ccode=@val"; "select * from SqlCommand cmd = new SqlCommand(str, string str = employees con); "select * from where cmd.CommandType = employees ccode=@val"; CommandType.Text; where SqlCommand ccode=@val"; cmd = new SqlParameter sql; SqlCommand SqlCommand(str

3, DataView dv = new DataView(); dv.Sort = "Salary Ascending, Year Descending"; 3, string val = comboBox1.Text.T oString(); string constr = "Data Source=SQLSERV ER01;User ID=sa;password=nii t#1234;Initial Catalog=HR"; SqlConnection con = new SqlConnection(); con.ConnectionStri ng = constr; con.Open(); string str = "select * from employees where ccode=@val"; SqlCommand cmd = new SqlCommand(str);

4, DataView dv = dv.CreateDataView (); dv.Sort = "Salary Ascending, Year Descending"; 1 4, string val = comboBox1.Text.T oString(); string constr = "Data Source=SQLSERV ER01;User ID=sa;password=ni it#1234;Initial Catalog=HR"; SqlConnection con = new SqlConnection(); con.ConnectionStri ng = constr; con.Open();

string str = "select * from employees where ccode=@val"; SqlCommand cmd = new SqlCommand(str, con); cmd.CommandTyp cmd.CommandTyp 1

Peter has created a console application in which he is retrieving data in read-only forward-only mode from the Employee table of the AdventureWorks database. For this, he has written the following code snippet: string connectionString = "Data Source=SQLSERVER01;Initial Catalog=AdventureWorks;User id=sa;Password=niit#1234"; string sSQL = "SELECT * FROM HumanResources.Employee"; SqlConnection cn = new SqlConnection(connectionString); cn.Open(); SqlCommand cmd = new SqlCommand(sSQL, cn); SqlDataReader dr; while (dr.Read()) { Console.WriteLine(dr[0] + "" + dr[1]); } cn.Close(); SM B21 However, when Peter executed the 57 application, it threw an error. Analyze the

1, string connectionStrin g = "Data Source=SQLS ERVER01;Initia l Catalog=Adven tureWorks;User id=sa;Password =niit#1234"; string sSQL = "SELECT * FROM HumanResourc es.Employee";

2, string connectionString = "Data Source=SQLSE RVER01;Initial Catalog=Advent ureWorks;User id=sa;Password =niit#1234"; string sSQL = "SELECT * FROM HumanResource s.Employee"; SqlConnection cn = new SqlConnection SqlConnection(c cn = new onnectionString) SqlConnection( ; connectionStrin cn.Open(); g); cn.Open(); SqlCommand cmd = new SqlCommand SqlCommand(s cmd = new SQL, cn); SqlCommand(s SqlDataReader SQL, cn); dr =

3, string connectionString = "Data Source=SQLSERV ER01;Initial Catalog=Adventure Works;User id=sa;Password=nii t#1234"; string sSQL = "SELECT * FROM HumanResources. Employee"; SqlConnection cn = new SqlConnection(con nectionString); cn.Open(); SqlCommand cmd = new SqlCommand(sSQ L, cn); SqlDataReader dr = cmd.ExecuteReade r();

4, string connectionString = "Data Source=SQLSERV ER01;Initial Catalog=Adventure Works;User id=sa;Password=ni it#1234"; string sSQL = "SELECT * FROM HumanResources. Employee"; SqlConnection cn = new SqlConnection(con nectionString); cn.Open(); SqlCommand cmd = new SqlCommand(sSQ L, cn); SqlDataReader dr = cmd.ExecuteRead er(); 4

1, SqlConnection connection = new SqlConnection( SqlConnection connection = new ); SqlConnection(); connection.Con connection.ConnectionString = "Data nectionString = Source=SQLSERVER01;Initial "Data Catalog=HR;User Source=SQLS id=sa;Password=niit#1234"; ERVER01;Initia connection.Open(); l Catalog=HR;Us SqlDataAdapter adapter = new er SqlDataAdapter("Select * from Employees", id=sa;Password connection); =niit#1234"; SqlCommandBuilder cmdBuilder = new connection.Ope SqlCommandBuilder(connection); n(); DataSet ds = new DataSet("Employees"); adapter.Fill(ds, "Employees"); SqlDataAdapter adapter = new DataRow row = SqlDataAdapter ds.Tables["Employees"].NewRow(); ("Select * from row["cEmployeeCode"] = "000018"; Employees", SM row["vFirstName"] = "Peter"; connection); B21 row["vLastName"] = "Martin"; SqlCommandB 58 uilder

Peter has created an application to add records in a table and update the database. For this, he has written the following code snippet:

2, SqlConnection connection = new SqlConnection();

3, SqlConnection connection = new SqlConnection(); connection.Connec tionString = "Data Source=SQLSERV connection.Conn ER01;Initial ectionString = Catalog=HR;User "Data id=sa;Password=nii Source=SQLSE t#1234"; RVER01;Initial connection.Open(); Catalog=HR;Use r id=sa;Password SqlDataAdapter =niit#1234"; adapter = new connection.Ope SqlDataAdapter("S n(); elect * from Employees", SqlDataAdapter connection); adapter = new SqlCommandBuild SqlDataAdapter( er cmdBuilder = "Select * from new Employees", SqlCommandBuild connection); er(adapter); SqlCommandBui DataSet ds = new lder cmdBuilder DataSet("Employee = new s");

4, SqlConnection connection = new SqlConnection(); connection.Connec tionString = "Data Source=SQLSERV ER01;Initial Catalog=HR;User id=sa;Password=ni it#1234"; connection.Open();

SqlDataAdapter adapter = new SqlDataAdapter("S elect * from Employees", connection); SqlCommandBuild er cmdBuilder = new SqlCommandBuild er(adapter); DataSet ds = new DataSet("Employe es"); 2

Sam is creating an application in which he needs to merge the data available in one DataSet with another DataSet. For this, he has written the following code snippet in the application: SqlConnection cn = new SqlConnection("Data Source=SQLSERVER01;Initial Catalog=HR;User id=sa;Password=niit#1234"); SqlCommand cmd = cn.CreateCommand(); cmd.CommandText = "SELECT * FROM Department"; SqlDataAdapter da = cn.CreateDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); cn.Open(); da.Fill(ds, "Department"); cmd.CommandText = "SELECT * FROM Country"; SM B21 DataSet ds1 = new DataSet(); 59 da.Fill(ds1, "Country");

1, SqlConnection cn = new SqlConnection( "Data Source=SQLS ERVER01;Initia l Catalog=HR;Us er id=sa;Password =niit#1234"); SqlCommand cmd = cn.CreateCom mand(); cmd.Command Text = "SELECT * FROM Department"; SqlDataAdapter da = new SqlDataAdapter (); da.SelectCom mand = cmd;

2, SqlConnection cn = new SqlConnection(" Data Source=SQLSE RVER01;Initial Catalog=HR;Use r id=sa;Password =niit#1234"); SqlCommand cmd = cn.CreateComm and(); cmd.CommandT ext = "SELECT * FROM Department"; SqlDataAdapter da = new SqlDataAdapter( ); da.SelectComm and = cmd; DataSet ds =

3, SqlConnection cn = new SqlConnection("Dat a Source=SQLSERV ER01;Initial Catalog=HR;User id=sa;Password=nii t#1234"); SqlCommand cmd = cn.CreateComman d(); cmd.CommandText = "SELECT * FROM Department"; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); cn.Open(); da.Fill(ds,

4, SqlConnection cn = new SqlConnection("Da ta Source=SQLSERV ER01;Initial Catalog=HR;User id=sa;Password=ni it#1234"); SqlCommand cmd = cn.CreateComman d(); cmd.CommandTex t = "SELECT * FROM Department"; SqlDataAdapter da = new SqlDataAdapter(); da.SelectComman d = cmd; DataSet ds = new DataSet(); cn.Open();

You are creating an application in which you want to view the employee codes of the employees who are married. For this, you need to filter the data based on the marital status of employees. You have written the following code snippet to filter the data: string connectionString = "Data Source=SQLSERVER01;Initial Catalog=AdventureWorks;User id=sa;Password=niit#1234"; string sSQL = "Select * From HumanResources.Employee"; SqlConnection conn = new SqlConnection(connectionString); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(sSQL,conn); DataSet ds = new DataSet(); da.Fill(ds, "HumanResources.Employee"); DataTable dt = SM ds.Tables["HumanResources.Employee"]; B21 60 DataView dv = ds.CreateDataView(dt,

1, string connectionStrin g = "Data Source=SQLS ERVER01;Initia l Catalog=Adven tureWorks;User id=sa;Password =niit#1234"; string sSQL = "Select * From HumanResourc es.Employee";

2, string connectionString = "Data Source=SQLSE RVER01;Initial Catalog=Advent ureWorks;User id=sa;Password =niit#1234"; string sSQL = "Select * From HumanResource s.Employee"; SqlConnection conn = new SqlConnection SqlConnection(c conn = new onnectionString) SqlConnection( ; connectionStrin g); SqlDataAdapter da = new SqlDataAdapter SqlDataAdapter( da = new ); SqlDataAdapter da.SelectComm (); and = new da.SelectCom SqlCommand(s mand = new SQL);

3, string connectionString = "Data Source=SQLSERV ER01;Initial Catalog=Adventure Works;User id=sa;Password=nii t#1234"; string sSQL = "Select * From HumanResources. Employee"; SqlConnection conn = new SqlConnection(con nectionString); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(sSQ L,conn); DataSet ds = da. CreateNewDataSet

4, string connectionString = "Data Source=SQLSERV ER01;Initial Catalog=Adventure Works;User id=sa;Password=ni it#1234"; string sSQL = "Select * From HumanResources. Employee"; SqlConnection conn = new SqlConnection(con nectionString); SqlDataAdapter da = new SqlDataAdapter(); da.SelectComman d = new SqlCommand(sSQ L,conn); DataSet ds = 1

SM Which of the following options allows the 1, The 2, The B21 DataReader class to handle columns, which SequentialAcce ExecuteReader( 3, The GetBytes() 61 store large binary data? ss property ) method method SM Which of the following options is the starting B21 position of the update in the syntax of the 62 UPDATETEXT function? 1, Pointer

4, The SingleRow property

2, Offset

3, Delete_Length

4, Data

SM Which of the following WriteToServer() B21 method copies all rows from the DataRow 63 array to a destination table?

4, 1, 2, 3, SqlBulkCopy.Write SqlBulkCopy.W SqlBulkCopy.Wri SqlBulkCopy.Write ToServer riteToServer teToServer ToServer (DataTable, (DataTable) (IDataReader) (DataRow[]) DataRowState) 3

SM B21 The __________ class is used for bulk copy 64 of records. 1, SqlCopyBulk 2, SqlCommand 3, SqlConnection

4, SqlBulkCopy

SM Which of the following namespaces will you 1, 2, 3, 4, B21 include to use the PermissionState System.Securit System.Security. System.Security.Ac System.Security.A 65 enumeration? y.Permissions Policy cessControl uthentication SM B21 Which of the following classes will you use 66 to execute SQL notifications? 1, The 2, The SqlClientPermi SqlDependency 3, The SqlBulkCopy 4, The ssion class class class DataAdapter class

Which of the following properties of a transaction states that any data modification SM made by one transaction must be B21 independent from the modifications made 67 by the other transaction? 1, Durability

2, Consistency

3, Atomicity

4, Isolation

SM 1, B21 A local transaction is created and managed System.Transa 68 within the ____________ namespace. ctions 2, System.Data SM Which of the following methods is called B21 when a transaction is successfully 69 completed? 1, Rollback() Which of the following isolation levels is used when accuracy is required on longSM running queries and multi-statement B21 transactions, but no updates are performed 70 on the data? 1, Snapshot

4, System.Data.SqlCli 3, System.Data.Sql ent 1 4, 3, ExecuteNonQuery( BeginTransaction() ) 2

2, Commit()

2, Repeatable Read

3, Read Committed 4, Read Committed with Snapshots with Locks 1

You are using a DbCommand object, command, in your application. You want to change the behavior of the command object SM to a sequential stream when you execute B21 the ExecuteReader() method. Which of the 71 following code snippet allows you to do so?

1, command.Exec uteReader(Co mmandBehavio r.SequentialAcc ess); 1, UPDATETEXT <Table_Name> .<Column_Nam e> <Data> <Pointer> <Offset> <Delete_Lengt h> 1, ALTER DATABASE DATABASE_N AME SET ENABLE.BROK ER;

2, command.Execu teReader(Behavi or.SequentialAc cess);

3, command.Execute Reader(Command Behavior(Sequentia lAccess));

4, command.Execute Reader(Command Behavior.Sequenti alAccess(comman d)); 1

SM B21 Identify the correct syntax of the 72 UPDATETEXT function.

SM You need to enable a Service Broker for a B21 SQL Server database. Which of the 73 following SQL statements will you use? You want to create and perform local SM transactions against a single data source. B21 Which of the following options provide you 74 with the methods for doing so?

2, UPDATETEXT <Table_Name>. <Column_Name > <Offset> <Pointer> <Delete_Length > <Data> 2, ALTER DATABASE DATABASE_NA ME SET ENABLE_BROK ER;

3, UPDATETEXT <Table_Name>.<C olumn_Name> <Pointer> <Offset> <Delete_Length> <Data>

4, UPDATETEXT <Table_Name>.<C olumn_Name> <Offset> <Delete_Length> <Pointer> <Data> 3 4, ALTER 3, ALTER DATABASE DATABASE DATABASE_NAM DATABASE_NAME E SET SET BROKER_ENABL BROKER.ENABLE; E; 2 4, The 3, The IDbTransaction SqlCommand class interface

1, The 2, The SqlConnection IDataReader Class interface

You are creating an application that implements transactions. In the application, you want that the queries running inside one transaction are affected by the SM committed changes in another transaction. B21 Which of the following types of transaction 1, Read 75 isolation levels will you use? Uncommitted

2, Read Committed with 3, Read Committed 4, Repeatable Locks with Snapshots Read

1,private void store_Click(obj ect sender, EventArgs e){ //connection is the valid connection object and command is the valid command object FileStream fs; BinaryWriter bw; int bufferSize = 100; You are creating an application for a byte[] outbyte hospital. The application should enable the = new management of the hospital to view the byte[bufferSize] photographs of all the patients and store ; them in a file. The details of all the patients long retval; including the photographs are stored in a long startIndex SM database. Which of the following code = 0; B21 snippet will you write to achieve the required string 76 functionality? patientID = "";

2,private void store_Click(obje ct sender, EventArgs e){ //connection is the valid connection object and command is the valid command object FileStream fs; BinaryWriter bw; int bufferSize = 100; byte[] outbyte = new byte[bufferSize];

3,private void store_Click(object sender, EventArgs e){ //connection is the valid connection object and command is the valid command object FileStream fs; BinaryWriter bw; int bufferSize = 100; byte[] outbyte = new byte[bufferSize]; long retval; long startIndex = 0; long retval; string patientID = long startIndex ""; = 0; string connection.Open(); patientID = "";

4,private void store_Click(object sender, EventArgs e){ //connection is the valid connection object and command is the valid command object FileStream fs; BinaryWriter bw; int bufferSize = 100; byte[] outbyte = new byte[bufferSize]; long retval; long startIndex = 0; string patientID = ""; connection.Open(); SqlDataReader myReader =

1, FileStream file = new FileStream(cur FileName, FileMode.Open OrCreate, FileAccess.Rea d); byte[] rawdata = new byte[file.Length] ; file.Read(rawda ta, 0, System.Conver t.ToInt32(file.Le ngth)); file.Close(); string sql = "SELECT * You are creating an application in which you FROM have to write BLOB value to the database. PATIENTS"; To optimize the usage of system resources, you are writing the BLOB to the database in SqlConnection SM chunks. Which of the following code connection = B21 snippets will you write to achieve the new 77 required functionality? SqlConnection(

2, FileStream file = new FileStream(curFi leName, FileMode.Open OrCreate, FileAccess.Read ); byte[] rawdata = new byte[file.Length];

3, FileStream file = new FileStream(curFile Name, FileMode.OpenOrC reate); byte[] rawdata = new byte[file.Length]; file.Read(rawdata, 0, System.Convert.ToI file.Read(rawdat nt32(file.Length)); a, 0, file.Close(); System.Convert. string sql = ToInt32(file.Leng "SELECT * FROM th)); PATIENTS"; file.Close(); string sql = SqlConnection "SELECT * connection = new FROM SqlConnection(); PATIENTS"; connection.Connec tionString = SqlConnection connectionString; connection = connection.Open(); new SqlConnection();

4, FileStream file = new FileStream(curFile Name, FileMode.OpenOr Create, FileAccess.Read); byte[] rawdata = new byte[file.Length]; file.Read(rawdata, 0, System.Convert.To Int32(file.Length)); file.Close(); string sql = "SELECT * FROM PATIENTS"; SqlConnection connection = new SqlConnection(); connection.Connec tionString = connectionString; 2

SM You have to perform the bulk copy B21 operation. Identify the correct sequence of 78 steps to perform the bulk copy operation.

1, 1. Connect to the source server to get the data to be copied. 2. Create a SqlBulkCopy object. 3. Connect to the destination server. 4. Set the DestinationTabl eName property to the name of the target table. 5. Call the WriteToServer( ) method.

2, 1. Connect to the source server to get the data to be copied. 2. Call the WriteToServer() method. 3. Connect to the destination server. 4. Create a SqlBulkCopy object. 5. Set the DestinationTable Name property to the name of the target table.

3, 1. Connect to the source server to get the data to be copied. 2. Connect to the destination server. 3. Create a SqlBulkCopy object. 4. Set the DestinationTableNa me property to the name of the target table. 5. Call the WriteToServer() method.

4, 1. Create a SqlBulkCopy object. 2. Connect to the source server to get the data to be copied. 3. Call the WriteToServer() method. 4. Connect to the destination server. 5. Set the DestinationTableN ame property to the name of the target table.

Sam is creating an application in which a transaction has been created by passing a connection to the HR database. The BeginTransaction() method is called and a SQL command is passed that will insert one record in the empdetails table. If the transaction successfully executes the command, the Commit() method will be called otherwise the Rollback() method will be called. Sam could not complete the code as he has to take leave due to health problems. He has written the following code snippet: static void Main(string[] args) { string connectString = "Initial Catalog=HR;Data Source=SQLSERVER01;User id=sa;Password=niit#1234"; SqlConnection cn = new SqlConnection(); cn.ConnectionString = connectString; SM cn.Open(); B21 SqlTransaction tran = null; 79

1,try {

2,try

3,try

4,try

{ { { tran = tran = tran = tran = cn.BeginTransa cn.BeginTransac cn.BeginTransactio cn.BeginTransactio ction(); tion(); n(); n(); SqlCommand cmd = new SqlCommand("I NSERT INTO empdetails(cco de,cname,cadd ress,cstate,cco untry, cDesignation,c Department)VA LUES(1101,'Lin da Taylor','Oxfords hire','London','U K','Manager', SqlCommand cmd = tran.CreateSqlC ommand("INSE RT INTO empdetails(ccod e,cname,caddre ss,cstate,ccountr y, cDesignation,cD epartment)VALU ES(1101,'Linda Taylor','Oxfordsh ire','London','UK' ,'Manager', SqlCommand cmd = new SqlCommand("INS ERT INTO empdetails(ccode,c name,caddress,cst ate,ccountry, cDesignation,cDep artment)VALUES(1 101,'Linda Taylor','Oxfordshire' ,'London','UK','Man ager', 'Finance')", cn, tran); SqlCommand cmd = new SqlCommand("INS ERT INTO empdetails(ccode,c name,caddress,cst ate,ccountry, cDesignation,cDep artment)VALUES(1 101,'Linda Taylor','Oxfordshire ','London','UK','Ma nager', 'Finance')", cn, tran);

'Finance')", cn, 'Finance')", cn, tran); tran);

cmd.ExecuteNonQ cmd.ExecuteNonQ uery(); uery(); tran.Commit(); 4

cmd.ExecuteQ cmd.ExecuteNo tran.Commit(); uery(); nQuery();

You are creating an application in which you are performing a bulk copy operation where the details of the Employee table are to be copied into the EmployeeBackUp table. For this,You have got the following partial code that has to be completed: static void Main(string[] args) { using (TransactionScope ts = new TransactionScope()) { string connectionString = GetConnectionString(); using (SqlConnection cn = new SqlConnection(connectionString)) { cn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandText = "DELETE dbo.EmployeeBackUp"; cmd.ExecuteNonQuery(); SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = cn; cmd1.CommandText = "INSERT SM INTO EmployeeBackUp B21 (cEmployeeCode,vFirstName,vLastName)V 80 ALUES(000005,'David','Cooper')";

1,SqlCommand rowCount = new SqlCommand(" SELECT COUNT(*) FROM dbo.EmployeeB ackUp",cn); long countStart = System.Conver t.ToInt32(rowC ount.Execute()) ;

Console.WriteLine( "Starting row count Console.WriteLi = {0}", Console.WriteL ne("Starting row countStart); ine("Starting count = {0}", row count = countStart); SqlCommand {0}", commandSourceD countStart); SqlCommand ata = new commandSourc SqlCommand("SEL SqlCommand eData = new ECT commandSourc SqlCommand("S cEmployeeCode,vF eData = new ELECT irstName,vLastNam SqlCommand(" cEmployeeCode e FROM SELECT ,vFirstName,vLa Employees", cn);

2,SqlCommand rowCount = new SqlCommand("S ELECT COUNT(*) FROM dbo.EmployeeB ackUp",cn); long countStart = System.Convert. ToInt32(rowCou nt.ExecuteScala r());

3,SqlCommand rowCount = new SqlCommand("SEL ECT COUNT(*) FROM dbo.EmployeeBack Up",cn); long countStart = System.Convert.ToI nt32(rowCount.Exe cuteScalar());

4,SqlCommand rowCount = new SqlCommand("SE LECT COUNT(*) FROM dbo.EmployeeBack Up",cn); long countStart = System.Convert.To Int32(rowCount.Ex ecuteScalar()); Console.WriteLine( "Starting row count = {0}", countStart); SqlCommand commandSourceD ata = new SqlCommand("SE LECT cEmployeeCode,v FirstName,vLastNa me FROM Employees", cn); 3

Sam is creating an application for a hospital. The application should create a backup copy of the Patients table. He has written the following code snippet to copy data from the Patients table to the Patients_backUp table: Line 1: using (SqlConnection sourceConnection = new SqlConnection(connectionString)) Line 2:{ sourceConnection.Open(); Line 3: SqlCommand commandSourceData = new SqlCommand("SELECT * FROM Patients;", sourceConnection); Line 4: SqlDataReader reader = commandSourceData.ExecuteReader(); Line 5: using (SqlConnection destinationConnection = new SqlConnection(connectionString)) Line 6: { destinationConnection.Open(); Line 7: using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnection)) Line 8: { bulkCopy.DestinationTableName = SM "Patients_backUp"; B21 try 81 Line 9:

1,Line 7: using (SqlBulkCopy bulkCopy = new SqlBulkCopy(s qlConnection)) has error. It should be: using (SqlBulkCopy bulkCopy = new SqlBulkCopy(d estinationConn ection))

4,Line 7: using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlCo nnection)) has 2,Line 9: 3,Line 9: error. It should {bulkCopy.Write {bulkCopy.WriteTo be: ToServer(reader Server(reader);} using );} has error. It has error. It should (SqlBulkCopy should be: be: bulkCopy = new {bulkCopy.Write( {bulkCopy.WriteTo( SqlBulkCopy(sourc reader);} reader);} eConnection)) 1

Sam wants a client-side code to execute SQL notification. For this, the client-side code requires necessary permissions. To provide the required permissions to the client-side code, Sam has written the following code snippet: private bool CanRequestNotifications() { Permissions permission = new

1, private bool CanRequestNo tifications() {

2, private bool CanRequestNoti 3, private bool fications() CanRequestNotific { ations() { ClientPermissio SqlClientPermis ns permission = sion permission SqlClientPermissio new = new n permission = new

4, private bool CanRequestNotific ations() { ClientPermission permission = new

ClientPermissio SqlClientPermis ns(PermissionS sion(Permission SqlClientPermissio ClientPermission(P Permissions(PermissionState.Unrestricted); tate.Unrestricte s.Unrestricted); n(PermissionState. ermissions.Unrestri d); try Unrestricted); cted); try try { try try { { { { permission.Demand(); permission.Dem return true; permission.De and(); permission.Deman permission.Deman } mand(); return true; d(); d(); catch (System.Exception) return } return true; return true; { true; catch } } return false; } (System.Excepti catch catch } catch on) (System.Exception) (System.Exception } (System.Except { ) However, when he executed the preceding ion) return { { SM code snippet, he found that it is throwing an { false; return false; return false; B21 error. Analyze the code snippet and provide return } } } 82 the correct code. false; } } } 3

Peter wants to execute SQL notifications in his application. For this, he has written the following code snippet in the application: public partial class Form1 : Form { 1. private string connectionString = "Data Source=SQLSERVER01;Initial Catalog=BomSaudeHospital;Pooling=False; User id=sa;Password=niit#1234"; 2. private delegate void GridDelegate(DataTable table); 3. private SqlDependency dep; public Form1() { 4. InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { 5. SqlDependency.StartDependency(connecti onString); SM 6. UpdateGrid(); B21 } 83

1, Line 3 has an error. The code should be:

2, Line 5 has an error. The code 3, Line 2 has an should be: error. The code should be: Line 5: Line 3: private SqlDependency. Line 2: private void SqlDependency Start(connection GridDelegate(Data ; String); Table table);

4, Line 5 has an error. The code should be: Line 5: dep.Start(connecti onString);

Robert is creating an application in which the BeginTransaction() method is called and a SQL command is passed that will insert one record in the empdetails table. If the particular transaction successfully executes the changes should be committed otherwise the changes should be rolled back. He has written the following code snippet in the application: Line 1: string connectString = "Initial Catalog=HR;Data Source=SQLSERVER01;User id=sa;Password=niit#1234"; Line 2: SqlConnection cn = CreateSqlConnection(); Line 3: cn.ConnectionString = connectString; Line 4: cn.Open(); Line 5: SqlTransaction tran = null; try{ Line 6: tran = cn.BeginTransactions(); Line 7: SqlCommand cmd = new SM SqlCommand("INSERT INTO B21 empdetails(ccode,cname,caddress)VALUE 84 S(1101,'Linda Taylor','Oxfordshire')", cn,

1,Line 2: SqlConnection cn = CreateSqlConn ection(); has error. It should be: SqlConnection cn = new SqlConnection( );

4,Line 2: SqlConnection cn = CreateSqlConnecti on(); and Line 6: tran = cn.BeginTransactio ns(); have errors. These should be: 2, Line 8: 3,Line 6: tran = SqlConnection cn cmd.ExecuteNo cn.BeginTransactio = new nQuery(); has ns(); have errors. It SqlConnection(); errors. It should should be: and be: tran = tran = cmd.ExecuteQu cn.BeginTransactio cn.BeginTransactio ery(); n(); n(); 4

SM B21 85 SM B21 86 SM B21 87

Rebecca has written the following code snippet to demonstrate the use of managing distributed transactions: class Program { static void Main(string[] args) { 1. using (TransactionScope ts = new TransactionScope()) { 2. using(SqlConnection cn = new SqlConnection("Initial Catalog=HR;Data Source=SQLSERVER01;User id=sa;Password=niit#1234")) { 3. cn.Open(); 4. using (SqlCommand cmd = new SqlCommand("INSERT INTO HRusers(cUserName,cPassword)VALUES(' Darren', 'Cooper')", cn)) { 5. int rowsUpdated = cmd.Execute(); 6. if (rowsUpdated > 0) { 7. using(SqlConnection cn1 = new SqlConnection("Initial Which of the following properties of the XmlWriterSettings class gets or sets the level of compliance with which the System.Xml.XmlWriter complies? Which of the following properties of the XmlReaderSettings class gets or sets a value indicating whether to do character checking or not?

1, Line 5 and Line 12 are causing the error. The correct code should be: Line 5: int rowsUpdated = cmd.ExecuteNo nQuery(); Line 12: ts.Complete();

2, Line 5 is causing the error. The correct code should be: Line 5: int rowsUpdated = cmd.ExecuteQu ery();

3, Line 1 is causing the error. The correct code should be: Line 1: using (TransactionScope ts = new TransactionScope. CreateTransaction( ))

4, Line 5 and Line 10 are causing the error. The correct code should be: Line 5: int rowsUpdated = cmd.ExecuteQuery (); Line 10: int rowsUpdated1 = cmd1.Execute(); 1

1, ConformanceL evel 2, CloseOutput

3, CheckCharacters 4, Encoding

1, 2, ConformanceL CheckCharacter evel s 3, ValidationType

4, Schemas

SM The ____________ class uses the B21 ValidationEventHandler() callback method 88 that is called when a validation error occurs. 1, XmlWriter

2, 3, XmlWriterSetting XmlValidatingRead s er 4, XmlConvert 4, XmlNamedNodeM ap

SM In the .NET Framework, NamedNodeMap is B21 implemented by the ______________ 1, 89 class. XmlTextReader 2, XmlDocument 3, XmlNodeList SM B21 Which of the following namespaces 90 contains the SqlXml class? You want to provide non-cached, forwardSM only, and write-only access to XML data. B21 Which of the following classes enables you 91 to achieve this? You want to determine whether the SM XmlReader instance imposes validation or B21 not. Which of the following classes enables 92 you to do this? You want to identify a row in the SM <DataInstance> block as modified. Which B21 of the following attributes enables you to do 93 this? You are writing a code in which you need to SM put all the attributes of an element node into B21 a collection. Which of the following options 94 enables you to achieve this? You want to ignore inline schemas and load the XML data into the existing dataset SM schema. Which of the following B21 XmlReadMode Options enables you to do 95 so? 1, 2, System.Xml.XP System.Xml.Sch ath ema 3, System.Xml 2, XmlWriterSetting s 3, XmlConvert

4, System.Data.SqlTy pes 4

1, XmlWriter

4, XmlTextWriter

1, XmlWriter

2, XmlWriterSetting 3, s XmlReaderSettings 4, XmlConvert

1, hasErrors 1, The NextSibling property

2, parentID

3, hasChanges

4, id

2, The 3, The XmlElement.Attri GetAttribute() butes property method

4, The GetAttributeNode() method 2

1, IgnoreSchema 2, InferSchema

3, Auto

4, DiffGram

1, static void Main(string[] args) { XmlWriterSettin gs settings = new XmlWriterSettin gs(); settings.Indent = true; settings.Indent Chars = " "; settings.NewLin eOnAttributes = true; using (XmlWriter writer = XmlWriter.Crea te("C:\\OrderDe tails.xml", settings))

2, static void Main(string[] args) {

3, static void Main(string[] args) {

4, static void Main(string[] args) { XmlWriterSettings settings = new XmlWriterSettings( ); settings.Indent = true; settings.IndentCha rs = " "; settings.NewAttribu tes = true; using (XmlWriter writer = XmlWriter.Create( @"C:\\OrderDetails .xml", settings)) { writer.WriteComme nt("Order Details of 1

You need to create a program that creates an XML file, OrderDetails.xml, by using the SM XmlWriter class in .NET. Which of the B21 following code snippets enables you to 96 perform the task?

XmlWriterSettings XmlWriterSetting settings = new s settings = new XmlWriterSettings() XmlWriterSetting ; s(); settings.Indent = settings.Indent = true; true; settings.IndentChar settings.IndentC s = " "; hars = "*"; settings.NewLineO settings.NewLin nAttributes = true; eOnAttributes = using true; (XmlWriter writer = using XmlWriter.Create(" (XmlWriter writer C:\OrderDetails.xml = ", settings)) XmlWriter.Creat { e("C:\\OrderDeta ils.xml")) writer.WriteComme { nt("Order Details of Velocidade Inc.");

1, static void Main(string[] args) { XmlReader reader = null; try { XmlReaderSetti ngs settings = new XmlReaderSetti ngs(); settings.Ignore Whitespace = true; reader = You are creating an application in which you XmlReader.Cre need to read an XML document, ate("C:\\books. books.xml, and display the content of the xml", SM document to the reader. Which of the settings); B21 following code snippets will you use to read while 97 the document? (reader.Read())

2, static void 3, static void Main(string[] Main(string[] args) args) { { XmlReader XmlReader reader = null; reader = null; try try { { XmlReaderSettings XmlReaderSetti settings = new ngs settings = XmlReaderSettings new (); XmlReaderSetti ngs(); settings.IgnoreWhit espace = true; settings.Ignore reader = Whitespace = XmlReader.Create( true; "C:\\books.xml", reader = settings); XmlReader.Crea while te("C:\\books.xm (reader.Read()) l", settings); { while (reader.Read()) reader.MoveToEle ment(); { Console.WriteLine(

4, static void Main(string[] args) { XmlReader reader = null; try { XmlReaderSettings settings = new XmlReaderSettings (); settings.IgnoreWhit espace = true; reader = XmlReader.Create Document("C:\\boo ks.xml", settings); while (reader.Read()) { reader.MoveToEle ment(); 1

2, namespace validatingXmlDo cument { class Program { static void Main(string[] args) { XmlTextReader reader = new XmlTextReader( XmlTextReader "C:\products.xml ("C:\\products.x "); ml"); XmlValidatingRe XmlValidatingR ader eader validatingReader validatingRead = new er = new XmlValidatingRe XmlValidatingR ader(reader); eader(reader); You need to create a program that validates validatingReader SM the products.xml file against the .ValidationType B21 products.xsd file. Which of the following validatingRead = 98 code snippets enables you to do so? er.ValidationTy ValidationType.

1, namespace validatingXmlD ocument { class Program { static void Main(string[] args) { XmlTextReader reader = new

3, namespace validatingXmlDocu ment { class Program { static void Main(string[] args) { XmlTextReader reader = new

4, namespace validatingXmlDocu ment { class Program { static void Main(string[] args) { XmlTextReader reader = new

XmlTextReader("C: \\products.xml"); XmlTextReader("C: \\products.xml"); XmlValidatingRead er validatingReader XmlValidatingRead = new er XmlValidatingRead validatingReader = er(reader); new XmlValidatingRead validatingReader.V er(reader); alidationType = ValidationType.Sch validatingReader.V ema; alidationType = ValidationType.Sch validatingReader.V ema; alidationEventHand ler +=new validatingReader.V 3

Predict the output of the following code snippet: XmlDocument doc = new XmlDocument(); doc.LoadXml(("<BOOKDETAILS><BOOK BOOKID='B001'><BOOKNAME>Angels and Demons</BOOKNAME><AUTHOR>Dan Brown</AUTHOR></BOOK><BOOK BOOKID='B002'><BOOKNAME>Dr. Jekyll and Mr. Hyde</BOOKNAME><AUTHOR>Robert Louis Stevenson</AUTHOR></BOOK></BOOKD ETAILS>")); SM XmlNode node = B21 doc.DocumentElement.FirstChild; 99

3, The 1, The first BOOKNAME BOOK BOOKID 2, The code will element of the first element is not delete any BOOK element is 4, The code will removed. element. removed. give an error.

1,private void cmdRetrieve_C lick(object sender, EventArgs e) { DataSet ds = new DataSet();

2,private void cmdRetrieve_Cli ck(object sender, EventArgs e) { DataSet ds = new DataSet();

3, private void cmdRetrieve_Click( object sender, EventArgs e) { DataSet ds = new DataSet();

//connectionStrin //connectionStri g is the You have created a table named Students, ng is the connection by using the following SQL queries: connection string CREATE TABLE Students(Marks xml) string using INSERT Students using (SqlConnection VALUES('<Marks><English>85</English>< (SqlConnection conn = new Math>100</Math></Marks>') conn = new SqlConnection()) INSERT Students SqlConnection( VALUES('<Marks><English>83</English>< )) { Math>96</Math></Marks>') { conn.Connection conn.Connectio String = Now, you need to create a program that nString = connectionString retrieves the records stored in Students connectionStrin ; table and display them in a DataGrid g; SM control. Which of the following code conn.Open(); B22 snippets enables you to perform the desired conn.Open(); using 00 task. using (SqlCommand

4, private void cmdRetrieve_Click (object sender, EventArgs e) { DataSet ds = new DataSet(); //connectionString is the connection //connectionString string is the connection using string (SqlConnection using conn = new (SqlConnection SqlConnection()) conn = new { SqlConnection()) conn.ConnectionSt { ring = conn.ConnectionStr connectionString; ing = connectionString; conn.Open(); using conn.Open(); (SqlCommand cmd using = (SqlCommand cmd conn.CreateComm = and()) conn.CreateComm { and()) cmd.CommandTex { t = "SELECT * 2

You might also like