You are on page 1of 93

Question --> The __________ principle states that while designing an interactive product, the interfaces should have

similar operations and should use similar e lements for similar tasks. Option 1 --> 1, Visibility Option 2 --> 2, Consistency Option 3 --> 3, Feedback Option 4 --> 4, Constraints Solution --> 2 Question --> Which of the following principles of interactive design states that it is important to keep the users informed about their actions? Option 1 --> 1, Visibility Option 2 --> 2, Feedback Option 3 --> 3, Constraints Option 4 --> 4, Affordances Solution --> 2 Question --> Which of the following options is a lifecycle model that is selecte d by designers when the project is small and they want to use a flexible lifecyc le model? Option 1 --> 1, Usability engineering model Option 2 --> 2, Star model Option 3 --> 3, Conceptual Model Option 4 --> 4, User's Mental Model Solution --> 2 Question --> _________ requirements capture the system goals with respect to eff ectiveness, efficiency, safety, utility, learnability, and memorability of a pro duct. Option 1 --> 1, Data Option 2 --> 2, Environmental Option 3 --> 3, Usability Option 4 --> 4, User Solution --> 3

Question --> Which of the following data gathering techniques involves having a conversation with the participants where the researcher orally solicits response s? Option 1 --> 1, Questionnaires Option 2 --> 2, Focus groups Option 3 --> 3, Interviews Option 4 --> 4, Naturalistic observation Solution --> 3 Question --> NewTech Book Store has launched its website to sell books to its cu stomers around the world. The website displays thumbnails of books being sold in stead of displaying the names of books in text. Which of the following cognition elements has been applied by NewTech in their website? Option 1 --> 1, Perception Option 2 --> 2, Attention Option 3 --> 3, Language Option 4 --> 4, Memory Solution --> 2 Question --> NewTech Book Store has launched its website to sell books to its re gistered users all over the world. The website provides a link to register new u sers. 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 an d submit the essential user details. After the site was launched, it was observe d that the feature worked fine in Windows XP Operating System (OS). However, whe n the same link is clicked in Mac OS or Linux OS, the page is not displayed as t he new window does not get opened. In the preceding scenario, analyze and provide the requirements that have not be en considered by NewTech while developing its website? Option 1 --> 1, Functional requirements Option 2 --> 2, User requirements Option 3 --> 3, Data requirements Option 4 --> 4, Non-functional requirements Solution --> 4 Question --> 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 accep tance of the phone on a sample population. As per the feedback received, the tea m got to know that the phone is difficult to use and its features cannot be easi

ly apprehended. Also, the user interface of the phone is very complicated. Becau se of this, the team will now have to redesign the mobile phone. Analyze the situation and suggest which of the following implementations could h ave avoided this rework by the team? Option 1 --> 1, The team should have designed the physical model before the con ceptual model. Option 2 --> 2, The team should have developed the users' mental model before p hysical model. Option 3 --> 3, The team should have developed the conceptual model before phys ical model. Option 4 --> 4, The team should have developed the star model before users' men tal model. Solution --> 3 Question --> Which of the following options is NOT a factor that is to be consid ered for selecting the appropriate prototyping technique? Option 1 --> 1, Budget and time constraints Option 2 --> 2, Navigation and flow Option 3 --> 3, Look-and-feel of the application Option 4 --> 4, Location and accessibility of stakeholders Solution --> 4 Question --> Which of the following is NOT a correct guideline to be followed wh ile designing a GUI for touch screens? Option 1 --> 1, For better visual clarity, you should divide the screen into va rious functional areas. Option 2 --> 2, Menu items should be at least 3 mm in size. Option 3 --> 3, The size of the push button in a touch screen should be less th an 2x2 cm and they should be spread out on the screen with a spacing of 10 mm. Option 4 --> 4, 3x3 layout should be used to enter numbers. Solution --> 3 Question --> Jim is creating a website for an organization. He needs to ensure t hat the links for Site Map, Contact Us, and Home should be displayed on top of a ll the pages of the website. Provide the strategy that Jim should adopt to displ ay the links. Option 1 --> 1, Jim should create mirror links. Option 2 --> 2, Jim should create global links.

Option 3 --> 3, Jim should create local links. Option 4 --> 4, Jim should create the links as a marquee. Solution --> 2 Question --> Jim has been working upon a website of his organization to make sur e that it gets displayed on handheld devices as well. After the launch it was ob served 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 content easily. Pr ovide the correct Web viewing method that Jim should implement in the current sc enario. Option 1 --> 1, Jim can use the linear migration display Option 2 --> 2, Jim can use the original display Option 3 --> 3, Jim can use the filtered display Option 4 --> 4, Jim can use the splash screen display Solution --> 3 Question --> Bryan needs to develop an intelligent software-based application. B efore starting with the development, he wants to first identify the users' expec tations from the application. His manager has asked him to implement the Wizard of Oz (WoZ) prototyping technique to accomplish the same. Provide the correct se quence of steps for implementing the same to Bryan. Option 1 --> 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 appli cation. 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. This conversation is analyzed to gather feedback. 6. The feedback is shared with the designer, who then incorporates the changes in the design. Option 2 --> 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 th e 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. Option 3 --> 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 appli cation. 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 3. 4. 5.

application. The developer answers the user. The human typist types the conversation. The designer incorporates the conversation in the design.

Option 4 --> 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 workin g of the application. 3. The user answers the developer. 4. The human typist types the conversation. 5. This conversation is analyzed to gather feedback. 6. The feedback is shared with the designer, who then incorporates the changes in the design. Solution --> 1 Question --> Morrison needs to get the website developed by his team to be teste d for usability. Morrison has certain predefined parameters for the evaluation. Therefore, he wants to get the heuristic evaluation performed for the website. P rovide him with the sequence of stages for implementing the same. Option 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 phases, look and feel of the product in the first phase and specific usability features in t he second phase. Stage 3: In the third stage, experts come together to share their findings, whic h includes analyzing the problems encountered and suggesting appropriate solutio ns. Option 2 --> 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 usabili ty features in the second phase. Stage 2: In the second stage, the experts are then briefed about what they are e xpected to do. Stage 3: In the third stage, experts come together to share their findings, whic h includes analyzing the problems encountered and suggesting appropriate solutio ns. Option 3 --> 3, Stage 1: In the first stage, the experts are briefed about what they are expecte d to do. Stage 2: In the second stage, experts come together to share their findings, whi ch includes analyzing the problems encountered and suggesting appropriate soluti ons. Stage 3: In the third stage, experts may evaluate a product in two phases, look and feel of the product in the first phase and specific usability features in th e second phase. Option 4 --> 4, Stage 1: In the first stage, experts come together to share the ir findings, which includes analyzing the problems encountered and suggesting ap propriate 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 t he second phase. Stage 3: In the third stage, the experts are briefed about what they are expecte d to do. Solution --> 1 Question --> A team of software engineers at NewTech Labs needs to develop a con sole-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 i dentify, from the following options, the type of conceptual model that should be developed for the operating system being developed. Option 1 --> 1, The conceptual model should be instruction-based. Option 2 --> 2, The conceptual model should be conversation-based. Option 3 --> 3, The conceptual model should be based on direct manipulation. Option 4 --> 4, The conceptual model should be exploring and browsing-based. Solution --> 1 Question --> Alice needs to develop a conceptual model for a car game being deve loped by her team. The game requires the players to select race tracks, cars, an d car specifications. The players can also select whether the gear mode for thei r 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. Option 1 --> 1, Alice should develop an exploring and browsing-based model for the game because the game involves exploring and browsing for the car models. Option 2 --> 2, Alice should develop an instruction-based model for the game be cause the user will be giving commands and controlling the game. Option 3 --> 3, Alice should develop a manipulating and navigating-based model for the game because the game requires users to select, move, and drag elements of the game just as they would do in the physical world. Option 4 --> 4, Alice should develop a conversation-based model for the game be cause the users are required to search for particular information while using th e game. Solution --> 3 Question --> While giving a lecture on principles of interactive design, John in formed the participants that they could reduce the number of errors in an applic ation by making the administrator-related features as inactive when a normal use r works on the application. He further informed the participants that this is an implementation of the visibility principle of interactive design. Analyze wheth er the knowledge imparted by John regarding the design principle is correct. If not, provide the correct information that John should have given to the particip ants?

Option 1 --> 1, Yes, the principle specified by John correctly identifies the k nowledge imparted to the participants. Option 2 --> 2, No. The principle that reflects the knowledge imparted by John is the Consistency principle. Option 3 --> 3, No. The principle that reflects the knowledge imparted by John is the Affordances principle. Option 4 --> 4, No. The principle that reflects the knowledge imparted by John is the Constraints principle. Solution --> 4 Question --> 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 n eeds to ensure that the time displayed in either of the interface is always corr ect. She has decided to use Vector graphics to implement this functionality in t he application. Analyze if Joanna will be able to accomplish the requirement. If not, provide from the following options, the feature that will enable her to im plement the same. Option 1 --> 1, Yes. The required functionality can be implemented by using Vec tor graphics. Option 2 --> 2, No. The required functionality can be implemented by using Look less controls in the application. Option 3 --> 3, No. The required functionality can be implemented by using the Grid layout control in the application. Option 4 --> 4, No. The required functionality can be implemented by using Canv as layout in the application. Solution --> 2 Question --> You are creating a Web application that displays various wildlife i mages to the users. One page may display 4 to 5 images to the users. To avoid ov erlapping of the images on the page, you have decided to place them by specifyin g x and y coordinates. Which of the following layouts will you use to accomplish the same? Option 1 --> 1, Grid layout Option 2 --> 2, Dock panel Option 3 --> 3, Stack panel Option 4 --> 4, Canvas layout Solution --> 4 Question --> Jenny is required to conduct an interview for a number of participa nts. She needs to gather data regarding personal details and academic qualificat ions of each of the participants. She has a set of questions which she will be a

sking in a particular sequence from each participant. Identify the type of inter view that Jenny is implementing in the current scenario. Option 1 --> 1, Structured interview Option 2 --> 2, Unstructured interview Option 3 --> 3, Semi-structured interview Option 4 --> 4, Group interview Solution --> 1 Question --> Which of the following model is used when the user wants to search for particular information or wants to discuss an issue? Option 1 --> 1, Instruction-based model Option 2 --> 2, Conversation-based model Option 3 --> 3, Manipulating and navigating-based model Option 4 --> 4, Exploring and browsing-based model Solution --> 2 Question --> The _________ prototyping technique describes each action sequentia lly. Option 1 --> 1, storyboard Option 2 --> 2, sketching Option 3 --> 3, Wizard of Oz Option 4 --> 4, computer-based simulation Solution --> 1 Question --> _________ screen controls can be used to set attributes, properties , or values. Option 1 --> 1, Selection Option 2 --> 2, Text entry Option 3 --> 3, Operable Option 4 --> 4, Canvas Solution --> 1 Question --> In _______ layout, controls are placed in the form of x and y coord inates. Option 1 --> 1, grid

Option 2 --> 2, canvas Option 3 --> 3, dock panel Option 4 --> 4, stack panel Solution --> 2 Question --> Which of the following options is NOT a direct observation techniqu e? Option 1 --> 1, Notes and a still camera Option 2 --> 2, Audio recording and a still camera Option 3 --> 3, Video camera Option 4 --> 4, Interaction logging Solution --> 4 Question --> Which of the following keywords is used to resolve ambiguity betwee n instance variables and parameters? In addition, it is also used to pass the cu rrent object as a parameter to another method? Option 1 --> 1, super Option 2 --> 2, this Option 3 --> 3, abstract Option 4 --> 4, static Solution --> 2 Question --> Which of the following files contains the code for the Java Virtual Machine (JVM)? Option 1 --> 1, .java file Option 2 --> 2, .class file Option 3 --> 3, .jar file Option 4 --> 4, .mf file Solution --> 2 Question --> Which of the following keyword declares that the attribute is acces sible only to the methods within the same class? Option 1 --> 1, public Option 2 --> 2, private

Option 3 --> 3, default Option 4 --> 4, protected Solution --> 2 Question --> Which of the following options is used to declare and initialize a character variable? Option 1 --> 1, Char ch = "S"; Option 2 --> 2, char ch = "S"; Option 3 --> 3, Char ch = 'S'; Option 4 --> 4, char ch = 'S'; Solution --> 4 Question --> 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(); } } Now, you need to save the preceding code. Which of the following name will you u se to save the preceding code as a java file? Option 1 --> 1, Hi.java Option 2 --> 2, Hello.java Option 3 --> 3, MyApp.java Option 4 --> 4, Welcome.java Solution --> 3

Question --> Which of the following refers to the methodology of hiding certain elements of the implementation of a class but providing a public interface for t he client software? Option 1 --> 1, Polymorphism Option 2 --> 2, Inheritance Option 3 --> 3, Encapsulation Option 4 --> 4, Abstraction Solution --> 3 Question --> A constructor is defined with in a java class which takes int as an argument. What will be the output, if you instantiate the class object without passing any parameter? Option 1 --> 1, It will invoke the construct defined within the class. Option 2 --> 2, It will generate compile time error. Option 3 --> 3, It will automatically invoke the default constructor. Option 4 --> 4, It will generate runtime error. Solution --> 2 Question --> You need to declare a variable in a java class. Which of the follow ing identifiers will you use to accomplish the desired task? Option 1 --> 1, thisOne Option 2 --> 2, this Option 3 --> 3, -One Option 4 --> 4, 5One Solution --> 1 Question --> While compiling a java program, you need to reroute the class files to another directory. Which of the following options of the javac command will you use to accomplish the desired task? Option 1 --> 1, -classpath Option 2 --> 2, -sourcepath Option 3 --> 3, -extdirs Option 4 --> 4, -d Solution --> 4

Question --> 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); } } Option 1 --> 1, The variable obj is a reference variable in the MyApp class. Option 2 --> 2, The variable i is a reference variable in the MyApp class. Option 3 --> 3, The variable d is a reference variable in the MyApp class. Option 4 --> 4, There is no reference variable in the MyApp class. Solution --> 1 Question --> Sam has been assigned a task to create a frame of size 100, 100 whi ch has a background of blue color. In addition, the frame should display "Login" as a title. Identify the correct code that Sam should use to accomplish the des ired task. Option 1 --> 1, import java.awt.*; public class MyFrame extends Frame { Panel p; public MyFrame() { super("Login"); p=new Panel(); add(p); setSize(100,100); setVisible(true); } public static void main(String s[]) { new MyFrame(); } }

Option 2 --> 2, import javax.awt.*; public class MyFrame extends Frame { Panel p; public MyFrame() { super("Login"); p=new Panel(); add(p); setSize(100,100); setVisible(true); } public static void main(String s[]) { new MyFrame(); } } Option 3 --> 3, import java.Awt.*; public class MyFrame extends Frame { Panel p; public MyFrame() { super("Login"); p=new Panel(); add(p); setSize(100,100); setVisible(true); } public static void main(String s[]) { new MyFrame(); } } Option 4 --> 4, import javax.Awt.*;

public class MyFrame extends Frame { Panel p; public MyFrame() { super("Login"); p=new Panel(); add(p); setSize(100,100); setVisible(true); } public static void main(String s[]) { new MyFrame(); } } Solution --> 1

Question --> 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" Identify the correct code snippet that Sam should use to accomplish the desired task. Option 1 --> 1, public class frm_demo { private Frame f; public frm_demo(String title) { f=new Frame("Welcome"); } public void launch() { f.setSize(50,60); f.setBackground(Color.red); f.setVisible(true); } } Option 2 --> 2, public class frm_demo { private Frame f; public frm_demo(String title) { f=new Frame("Welcome"); } public void launch() { f.setSize(60,50); f.setBackground(Color.red); f.setVisible(true); } } } Option 3 --> 3, public class frm_demo { private Frame f; public frm_demo(String title) { f=new Frame("Welcome"); } public void launch() { f.setSize(50,60); f.setBackground.Color(RED); f.setVisible(true); } } Option 4 --> 4, public class frm_demo { private Frame f; public frm_demo(String title) { f=new Frame("Welcome"); } public void launch()

{ f.setSize(60,50); f.setBackground.Color(RED); f.setVisible(true); } } } Solution --> 1 Question --> While creating a Java GUI application, you want to obtain the refe rence of the object that has generated the event. Which of the following methods will you use to accomplish this task? Option 1 --> 1, getSource() Option 2 --> 2, getActioncommand() Option 3 --> 3, getModifiers() Option 4 --> 4, getAnnotation() Solution --> 1 Question --> Consider the following values, used to align the components within a container: LEFT, RIGHT, and CENTER. Which of the following layout manager uses the preceding values to set the align ment of the components? Option 1 --> 1, FlowLayout Manager Option 2 --> 2, GridBagLayout Manager Option 3 --> 3, GridLayout Manager Option 4 --> 4, CardLayout Solution --> 1 Question --> 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 th e gap between each row is 15. Which of the following code snippet will you use t o accomplish the desired task? Option 1 --> 1,GridLayout gl=new GridLayout(5, 2,10,15); Option 2 --> 2, GridLayout gl=new GridLayout(2, 5,10,15); Option 3 --> 3, GridLayout gl=new GridLayout(2, 5,15,10); Option 4 --> 4, GridLayout gl=new GridLayout(5, 2,15,10);

Solution --> 1 Question --> Consider the following code snippet: import java.awt.*; import java.awt.event.*; public class demo implements MouseListener { private Frame f; private TextField t; public demo() { f = new Frame("WELCOME"); t = new TextField(20); } * * * } Sam has created a class which implements MouseListener interface. Identify the m ethods that should be defined within the preceding class. Option 1 --> 1, mouseDragged(MouseEvent) mouseMoved(MouseEvent) Option 2 --> 2, mousePressed(MouseEvent) mouseReleased(MouseEvent) mouseEntered(MouseEvent) mouseExited(MouseEvent) mouseClicked(MouseEvent) Option 3 --> 3, mousePressed(MouseEvent) mouseReleased(MouseEvent) mouseEntered(MouseEvent) mouseExited(MouseEvent) mouseClicked(MouseEvent) mouseDragged(MouseEvent) mouseMoved(MouseEvent) Option 4 --> 4, mouseExited(MouseEvent) mouseClicked(MouseEvent) mouseDragged(MouseEvent) mouseMoved(MouseEvent) Solution --> 2 Question --> 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(); }} Sam has been assigned a task to modify the preceding code such that it tells the frame to set a size that neatly encloses the components that it contains. Identify the method that Sam should use to accomplish the desired task. Option 1 --> 1, f.pack(); Option 2 --> 2, f.add(); Option 3 --> 3, f.setLayout(); Option 4 --> 4, f.setSize(); Solution --> 1 Question --> Which of the following is correct in reference to a panel in Java? Option 1 --> 1, A Frame is a type of panel with a title and corners that can be resized. Option 2 --> 2, A panel must be placed into a window. Option 3 --> 3, A panel is a type of component. Option 4 --> 4, A panel is a free-standing native window on the display that is independent of other containers. Solution --> 2 Question --> Which of the following is correct in reference to the FileOutputStr eam class? Option 1 --> 1, The FileOutputStream constructor, overwrites the already existi ng output file. Option 2 --> 2, The FileOutputStream constructor, appends the already existing output file. Option 3 --> 3, The FileOutputStream constructor, prompts an error if the outpu t file already exists. Option 4 --> 4, The FileOutputStream constructor, creates a new file with any n ame if the output file already exists.

Solution --> 1 Question --> Sam has been assigned a task to create a TCP/IP client. Identify th e correct code snippet to accomplish the desired task. Option 1 --> 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.printStackTrace(); } } Option 2 --> 2, public class MyClient { public static void main(String args[]) { Socket s = null; try { s = new Socket(5432); } catch (IOException e) { e.printStackTrace(); } } Option 3 --> 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(); } } Option 4 --> 4, public class MyClient { public static void main(String args[]) { ServerSocket s = null; try { s = new ServerSocket(5432); } catch (IOException e) { e.printStackTrace(); } } Solution --> 1 Question --> 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(); } } } Identify the output of the preceding code, assuming that the a.txt file already exists at the given location. Option 1 --> 1, It will generate a run time error. Option 2 --> 2, It will generate a compile time error. Option 3 --> 3, It will not display any result. Option 4 --> 4, It will display the following output: File found at the given location. Solution --> 4 Question --> 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(); } } } Identify the output of the preceding code considering that the a.txt file does n ot exists in C drive.

Option 1 --> 1, It will display the following output: -1 Option 2 --> 2, It will generate a compile time error. Option 3 --> 3, It will throw a runtime exception. Option 4 --> 4, It will compile successfully and will not display any output. Solution --> 3 Question --> 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 force s the write operation to clear any accumilated data on the output stream. Identi fy the correct method that Sam should use to accomplish the desired task. Option 1 --> 1, System.out.flush(); Option 2 --> 2, System.out.reset(); Option 3 --> 3, System.out.mark(); Option 4 --> 4, System.out.markSupported(); Solution --> 1 Question --> 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 d atabase using the getConnection() method with a single parameter. Identify the correct syntax for a JDBC URL that Sam should pass as a parameter t o the getConnection(). Option 1 --> 1, <protocol>:<subprotocol>:<subname> Option 2 --> 2, <protocol>:<subprotocol> Option 3 --> 3, <protocol>:<subname> Option 4 --> 4, <protocol>:<subname>:<subprotocol> Solution --> 1 Question --> Sam has created a Java application that allows to access informatio n stored in a database "AUTH_DETAILS". Now, Sam has been assigned a task to crea te a code that modifies the state to CA where city is Oakland in the Authors tab le in the AUTH_DETAILS database using the PreparedStatement object. Identify the correct code snippet that Sam should use to accomplish the desire task. Option 1 --> 1, String str=" ";

PreparedStatement ps = con.prepareStatement(str); ps.setString(1, "CA"); ps.setString(2, "Oakland"); int rt=ps.executeUpdate(); Option 2 --> 2, String str = "UPDATE Authors SET state= ? WHERE city= ? "; PreparedStatement ps = con.prepareStatement(str); ps.setString(1, "CA"); ps.setString(2, "Oakland"); int rt=ps.executeUpdate(); Option 3 --> 3, String str = " "; PreparedStatement ps = con.prepareStatement(UPDATE Authors SET state= ? WHERE ci ty= ?); ps.setString(1, "CA"); ps.setString(2, "Oakland"); int rt=ps.Update(); Option 4 --> 4, String str = "UPDATE Authors SET state= ? WHERE city= ? "; PreparedStatement ps = con.prepareStatement(str); ps.setString(1, "CA"); ps.setString(2, "Oakland"); int rt=ps.Update(); Solution --> 2 Question --> Sam is creating a java program that implements stacks. He has to cr eate a method having following features: 1) The method should protect the shared buffer so that no two users are able to access the method simultaneously. 2) If the stack is empty in the method, the executing thread must wait. Identify the correct code snippet for the method that Sam should use to accompli sh the desired task. Option 1 --> 1, public synchronized char pop() { char ch; while(buffer.size()==0) { try { this.wait(); }catch(InterruptedException e) { } ch = buffer.remove(buffer.size()-1); return c; } Option 2 --> 2, public char pop() { char ch; while(buffer.size()==0) {

try { this.wait(); }catch(InterruptedException e) { } ch = buffer.remove(buffer.size()-1); return c; } Option 3 --> 3, public final char pop() { char ch; while(buffer.size()==0) { try { this.wait(); }catch(InterruptedException e) { } ch = buffer.remove(buffer.size()-1); return c; } Option 4 --> 4, public static char pop() { char ch; while(buffer.size()==0) { try { this.wait(); }catch(InterruptedException e) { } ch = buffer.remove(buffer.size()-1); return c; } Solution --> 1 Question --> 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(); } } Identify the correct output of the preceding code snippet. Option 1 --> 1, It will generate a compile time error as the th_demo class is n ot implementing the Runnable interface. Option 2 --> 2, It will compile successfully and on calling start, it will prin t the value of i from 0 to 9. Option 3 --> 3, It will not compile because the method run cannot have static k eyword as a return type. Option 4 --> 4, It will compile successfully and on calling start, it will pri nt the value of i=0 infinitely. Solution --> 3 Question --> While creating a Java application, you need to reflect the changes made by the transactions in a database. Which of the following method will you u se to accomplish the desired task? Option 1 --> 1, commit() Option 2 --> 2, rollback() Option 3 --> 3, executeUpdate() Option 4 --> 4, PrepareStatement() Solution --> 1 Question --> While creating a TCP/IP server application, you need to register yo ur service on port 5232. Which of the following code snippet will you use to acc omplish the desired task? Option 1 --> 1, ServerSocket s = new ServerSocket(5432); Option 2 --> 2, Socket s = new Socket("127.0.0.1",5432); Option 3 --> 3, Socket s = new Socket(5432); Option 4 --> 4, ServerSocket s = new ServerSocket("127.0.0.1",5432); Solution --> 1 Question --> Which of the following packages is used to access Thread class? Option 1 --> 1, java.lang Option 2 --> 2, java.util

Option 3 --> 3, java.awt Option 4 --> 4, java.io Solution --> 1 Question --> 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"); } } Analyze the preceding code and identify the correct output for the given code. Option 1 --> 1, It will print Hello five times. Option 2 --> 2, It will generate a runtime error. Option 3 --> 3, It will generate a compile time error. Option 4 --> 4, It will compile, and execute successfully but will not generate any output. Solution --> 1 Question --> While creating a thread in a Java application, you want to use a me thod that allows you to give other runnable threads a chance to execute. If othe r threads are runnable, the calling thread should be placed into the runnable po ol and allows another runnable thread to run. Which of the following methods of the Thread class will help you in accomplishing the desired task? Option 1 --> 1, Thread.yield() Option 2 --> 2, Thread.join() Option 3 --> 3, Thread.sleep(); Option 4 --> 4, Thread.wait() Solution --> 1 Question --> 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.jdbc.SQLServerDriver"); Connection con = DriverManager.getConnection("jdbc:sqlserver://sqlserver01; data baseName=Library;user=user1;password=password#1234"); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery(str); System.out.println("Author ID\tAuthor Name\tCity"); while (rs.next()) { String id=rs.getString("au_id"); String name=rs.getString("au_name"); String city=rs.getString("city"); System.out.print(id+"\t"); if (name.length() <=7) System.out.print(name+"\t\t"); else System.out.print("\t"+name+"\t"); System.out.println(city); } con.close(); } catch(Exception ex) { System.out.println("Error occurred"); System.out.println("Error:"+ex); } } } Identify the output of the preceding code. Option 1 --> 1, It retrieve information (author id, name, address, city, and st ate) about the authors who are living in the city where the city name begins wit h the letter "S". Option 2 --> 2, It retrieve information (author id, name, address, city, and s tate) about all the authors. Option 3 --> 3, It will generate a runtime exception due to database access err or. Option 4 --> 4, It will generate a compile time error as the user needs to impo rt javax.sql package. Solution --> 1 Question --> Which of the following methods is used to load the JDBC driver and registers it? Option 1 --> 1, forName() Option 2 --> 2, getConnection() Option 3 --> 3, absolute()

Option 4 --> 4, createStatement() Solution --> 1 Question --> The _______ object allows you to pass runtime parameters to the SQL statements using the placeholders. Option 1 --> 1, PreparedStatement Option 2 --> 2, ResultSet Option 3 --> 3, Connection Option 4 --> 4, Statement Solution --> 1 Question --> Which of the following methods of ResultSetMetaData interface retri eves the title of a table column corresponding to the index passed as a paramete r to the method? Option 1 --> 1, getColumnLabel() Option 2 --> 2, getColumnName() Option 3 --> 3, getColumnCount() Option 4 --> 4, getColumnType() Solution --> 1 Question --> Which of the following fields of the ResultSet interface specifies that the cursor of the ResultSet object is scrollable and it does not reflect ch anges in the data made by other users? Option 1 --> 1, TYPE_SCROLL_INSENSITIVE Option 2 --> 2, TYPE_SCROLL_SENSITIVE Option 3 --> 3, CONCUR_READ_ONLY Option 4 --> 4, CONCUR_UPDATABLE Solution --> 1 Question --> Which of the following drivers is called the Type 1 driver? Option 1 --> 1, JDBC-ODBC Bridge driver Option 2 --> 2, Native-API Partly-Java driver Option 3 --> 3, JDBC-Net Pure-Java driver Option 4 --> 4, Native Protocol Pure-Java driver Solution --> 1

Question --> When the client requests a connection, the server opens the socket connection with the ________ method. Option 1 --> 1, accept() Option 2 --> 2, Socket() Option 3 --> 3, readUTF() Option 4 --> 4, getInputStream() Solution --> 1 Question --> The PipedReader class is a type of _______ stream. Option 1 --> 1, Byte Option 2 --> 2, Processing Option 3 --> 3, Node Option 4 --> 4, Character Solution --> 4 Question --> Which of the following streams performs conversion on another strea m? Option 1 --> 1, Byte stream Option 2 --> 2, Node stream Option 3 --> 3, Filter stream Option 4 --> 4, Character stream Solution --> 3 Question --> Which of the following classes contains the wait and notify methods ? Option 1 --> 1, java.lang.Object Option 2 --> 2, java.lang.Thread Option 3 --> 3, java.lang.Exception Option 4 --> 4, java.lang.Error Solution --> 1 Question --> Which of the following is correct in reference to the getSQLState() method of the SQLException class?

Option 1 --> 1, It returns X/Open error code. Option 2 --> 2, It returns the next exception in the chain of exceptions. Option 3 --> 3, It loads the JDBC driver and registers the driver with the Driv erManager. Option 4 --> 4, It is used to create a Connection object. Solution --> 1 Question --> W3C stands for ___________________. Option 1 --> 1, World Wide Consortium Option 2 --> 2, World Web Consortium Option 3 --> 3, World Wide Web Consortium Option 4 --> 4, World Web Wide Consortium Solution --> 3 Question --> You want to retrieve data from a data source in a read-only and for ward-only mode. Which of the following components of a data provider will you us e? Option 1 --> 1, Connection Option 2 --> 2, DataReader Option 3 --> 3, Command Option 4 --> 4, DataAdapter Solution --> 2 Question --> Which of the following parameters of the connection string is used to specify the name of a database? Option 1 --> 1, Provider Option 2 --> 2, Integrated Security Option 3 --> 3, Data Source Option 4 --> 4, Initial Catalog Solution --> 4 Question --> Which of the following namespaces would you include in your program to use the functionality of the SqlConnection class? Option 1 --> 1, System.Data.SqlClient Option 2 --> 2, System.Data

Option 3 --> 3, System.Data.Sql Option 4 --> 4, System.Data.SqlTypes Solution --> 1 Question --> 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 cod e snippet: SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Data Source= SQLSERVER01; Initial Catalog=HR; Use r ID=sa; Password=niit#1234"; connection.Open(); SqlCommand cmd = new SqlCommand("select * from monthlysalary"); SqlDataReader myReader = cmd.ExecuteReader(); However, on execution, the code snippet is throwing a compilation error. Analyze the code snippet and identify the error. Option 1 --> 1, Instead of ExecuteReader(), the ExecuteNonQuery() method should be used. Option 2 --> 2, The myReader object should be initialized, as shown in the foll owing code snippet: SqlDataReader myReader = new SqlDataReader(); Option 3 --> 3, The SqlCommand constructor should have the query and the connec tion object as the parameter. It should be written as: SqlCommand cmd = new SqlCommand("select * from monthlysalary", connection);

Option 4 --> 4, The connection string should also include the Integrated Securi ty parameter and it should be set to true. Solution --> 3 Question --> Sam has written the following code snippet to illustrate how the St ateChange event is initialized during a connection: connection.StateChange += new StateChangeEventHandler(OnStateChange); protected static void OnStateChange(object sender, StateChangeEventArgs args) { Console.WriteLine("The current Connection state has changed from {0} to {1}.", OriginalState, CurrentState); } However, when he compiled the code snippet, it threw an error. Analyze the code snippet and identify the correct code. Option 1 --> 1, connection.StateChange += new StateChangeEventHandler(OnStateCh ange);

protected static void OnStateChange(object sender, StateChangeEventArgs args) { Console.WriteLine("The current Connection state has changed from {0} to {1}.", args.OriginalState, args.CurrentState); } Option 2 --> 2, connection.StateChange += new StateChangeEventHandler(OnStateCh ange); protected static void OnStateChange(object sender, StateChangeEventArgs args) { Console.WriteLine("The current Connection state has changed from {0} to {1}.", sender.OriginalState, sender.CurrentState); } Option 3 --> 3, connection.StateChange += new StateChangeEventHandler(OnStateCh ange); protected static void OnStateChange(object sender, StateChangeEventArgs args) { Console.WriteLine("The current Connection state has changed from {0} to {1}.", args.OriginalState, sender.CurrentState); } Option 4 --> 4, connection.StateChange += new StateChangeEventHandler(OnStateCh ange); protected static void OnStateChange(object sender, StateChangeEventArgs args) { Console.WriteLine("The current Connection state has changed from {0} to {1}.", sender.OriginalState, args.CurrentState); } Solution --> 1 Question --> Which of the following parameters indicates that the database conne ction will be reset when the connection is removed from the pool? Option 1 --> 1, Connection reset Option 2 --> 2, Enlist Option 3 --> 3, Pooling Option 4 --> 4, Connection timeout Solution --> 1 Question --> What would be the value of the Max pool size parameter if you have not explicitly specified any value? Option 1 --> 1, 1000 Option 2 --> 2, 100 Option 3 --> 3, 50

Option 4 --> 4, 200 Solution --> 2 Question --> Sam is implementing connection pooling. He wants that the pooler op ens 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(); However, he found that the code does not fulfill the requirement. Analyze the co de and provide a solution. Option 1 --> 1, The timeout should be increased so that the pooler can open a n ew connection. Option 2 --> 2, The Max pool size parameter should be included in the connectio n string. Option 3 --> 3, The Min pool size parameter should be included in the connectio n string. Option 4 --> 4, The pooling parameter should be set to false. Solution --> 4 Question --> Which of the following properties of a TextBox control is used to b ind the value of a column in the dataset? Option 1 --> 1, Locked Option 2 --> 2, Name Option 3 --> 3, Tag Option 4 --> 4, Text Solution --> 4 Question --> You want to bind a ComboBox control to a specific data element. Whi ch of the following properties will you use? Option 1 --> 1, The DisplayMember property Option 2 --> 2, The DataSource property Option 3 --> 3, The Items property Option 4 --> 4, The Text property Solution --> 1

Question --> Which of the following benefits is NOT provided by stored procedure s? Option 1 --> 1, precompiled execution Option 2 --> 2, reduced network traffic Option 3 --> 3, efficient reuse of code Option 4 --> 4, reduced bandwidth Solution --> 4 Question --> John has to develop an application that enables the users to retrie ve 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(); However, when he executed the code, it threw an error. Analyze the code and prov ide the solution. Option 1 --> 1, After creating the command object, the parameters need to be ad ded, as shown in the code snippet: cmd.Parameters.Add(new SqlParameter("@employeecode", searchemployeecode)); Option 2 --> 2, After creating the command object, the parameters need to be ad ded, as shown in the code snippet: cmd.Parameters.Add("@employeecode", searchemployeecode); Option 3 --> 3, After creating the command object, the parameters need to be ad ded, as shown in the code snippet: cmd.AddParameters(new SqlParameter("@employeecode", searchemployeecode)); Option 4 --> 4, After creating the command object, the parameters need to be ad ded, as shown in the code snippet: cmd.AddParameters("@employeecode", searchemployeecode); Solution --> 1 Question --> Which of the following properties of the DataView control enables y ou to specify an expression/condition in a string format for filtering the recor

ds? Option 1 --> 1, RowStateFilter Option 2 --> 2, RowFilter Option 3 --> 3, Sort Option 4 --> 4, Modifiers Solution --> 2 Question --> 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 snip pet: private void ToolStripButton_Click(object sender, EventArgs e) { try { this.internalCandidateTableAdapter.FillBy(this.adventureWorksDataSet.Sales); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } } However, the code snippet is throwing an error. Analyze the code snippet and pro vide the solution. Option 1 --> 1, private void ToolStripButton_Click(object sender, EventArgs e) { try { this.internalCandidateTableAdapter.Fill(this.adventureWorksDataSet.Sales); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } } Option 2 --> 2, private void ToolStripButton_Click(object sender, EventArgs e) { try { this.internalCandidateTableAdapter.Sales(this.adventureWorksDataSet.Fill); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } } Option 3 --> 3, private void ToolStripButton_Click(object sender, EventArgs e) { try

{ this.internalCandidateTableAdapter.FillBy(this.adventureWorksDataSet.Sales); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } } Option 4 --> 4, private void ToolStripButton_Click(object sender, EventArgs e) { try { this.internalCandidateTableAdapter.FilledBy(this.adventureWorksDataSet.Sales ); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } } Solution --> 3 Question --> Which of the following objects is NOT contained in the Connected cl asses? Option 1 --> 1, DataAdapter Option 2 --> 2, DataReader Option 3 --> 3, Connection Option 4 --> 4, Dataset Solution --> 4 Question --> Which of the following properties of the DbCommand object indicates or specifies how the CommandText property is interpreted? Option 1 --> 1, CommandType Option 2 --> 2, Parameters Option 3 --> 3, Transaction Option 4 --> 4, Site Solution --> 1 Question --> Which of the following properties of a DataAdapter object refers to a DML statement or a stored procedure to retrieve data from a dataset? Option 1 --> 1, InsertCommand Option 2 --> 2, SelectCommand

Option 3 --> 3, UpdateCommand Option 4 --> 4, DeleteCommand Solution --> 2 Question --> Which of the following Rule enumeration values deletes or updates t he child DataRow object when the Parent DataRow object is deleted or its unique key is changed? Option 1 --> 1, Cascade Option 2 --> 2, None Option 3 --> 3, SetDefault Option 4 --> 4, SetNull Solution --> 1 Question --> Which of the following enumeration values of the DataViewRowState e numeration retrieves the current row version of all modified rows? Option 1 --> 1, ModifiedOriginal Option 2 --> 2, CurrentRows Option 3 --> 3, OriginalRows Option 4 --> 4, ModifiedCurrent Solution --> 4 Question --> 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. Which of the following options are correct in context of the preceding statement s? Option 1 --> 1, Both, Statement A and Statement B, are true. Option 2 --> 2, Both, Statement A and Statement B, are false. Option 3 --> 3, Statement A is true and Statement B is false. Option 4 --> 4, Statement B is true and Statement A is false. Solution --> 1 Question --> How will you check whether the specified DbParameter object instanc es are same? Option 1 --> 1, By using the Equals() method of the DbParameter object

Option 2 --> 2, By using the RefereneceEquals() method of the DbParameter objec t Option 3 --> 3, By using the GetType() method of the DbParameter object Option 4 --> 4, By using the GetHashCode() method of the DbParameter object Solution --> 2 Question --> How will you determine the number of rows affected in the last batc h? Option 1 --> 1, By adding a RowUpdated event to the SqlDataAdapter object. Option 2 --> 2, By adding a RowUpdated() method to the SqlDataAdapter object. Option 3 --> 3, By adding a Updated event to the SqlDataAdapter object. Option 4 --> 4, By adding a Updated() method to the SqlDataAdapter object. Solution --> 1 Question --> Sam wants to merge dataset ds1 with dataset ds. Which of the follow ing code snippet will he use to perform the desired task? Option 1 --> 1, ds.Merge(dsMissingSchemaAction.Add); Option 2 --> 2, ds.Merge(ds1, 0, MissingSchemaAction.Add); Option 3 --> 3, ds.Merge(ds1, false, MissingSchemaAction.Add); Option 4 --> 4, ds.Merge(ds1, true, MissingSchemaAction.Add); Solution --> 4 Question --> How will you specify a sorting order on a particular column of a Da taView object? Option 1 --> 1, By using the Sort() method of the DataView object Option 2 --> 2, By using the ApplyDefaultSort property of the DataView object Option 3 --> 3, By using the Sort property of the DataView object Option 4 --> 4, By using the ApplyDefaultSort() method of the DataView object Solution --> 3 Question --> You want to create a Windows form to display the details of an empl oyee with Employee ID 3150. You want to fetch the data by sending SQL command to the database with the help of the DbCommand object. Which of the following code snippets will you write to achieve the desired task? Option 1 --> 1, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=Employee;User id=sa;Password=niit#1234";

SqlConnection cn = new SqlConnection(); cn.ConnectionString = connectionString; cn.Open(); SqlCommand cmd = cn.CreateCommand(); cmd.CommandText = "select * from Employees where Emp_ID=3150"; cmd.ExecuteNonQuery(); Option 2 --> 2, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=Employee;User id=sa;Password=niit#1234"; SqlConnection cn = new SqlConnection(); cn.ConnectionString = connectionString; cn.Open(); SqlCommand cmd = cn.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Employees where Emp_ID=3150"; cmd.ExecuteNonQuery(); Option 3 --> 3, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=Employee;User id=sa;Password=niit#1234"; SqlConnection cn = new SqlConnection(); cn.ConnectionString = connectionString; SqlCommand cmd = cn.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Employees where Emp_ID=3150"; cmd.ExecuteNonQuery(); Option 4 --> 4, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=Employee;User id=sa;Password=niit#1234"; SqlConnection cn = new SqlConnection(); cn.ConnectionString = connectionString; cn.Open(); SqlCommand cmd = new SQLCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Employees where Emp_ID=3150"; cmd.ExecuteNonQuery(); Solution --> 2 Question --> You want to retrieve all details from the Departments database by u sing the SqlDataAdapter object. Which of the following code snippets will you us e? Option 1 --> 1, SqlConnection cn = new SqlConnection();

cn.ConnectionString = "Data Source=SQLSERVER01;Initial Catalog=HR;User id=sa;Pas sword=niit#1234"; DataSet DataSet1 = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd=new SqlCommand("Select * from Departments", cn); da.SelectCommand = cmd; da.Fill(DataSet1); Option 2 --> 2, SqlConnection cn = new SqlConnection(); cn.ConnectionString = "Data Source=SQLSERVER01;Initial Catalog=HR;User id=sa;Pas sword=niit#1234"; DataSet DataSet1 = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd=new SqlCommand("Select * from Departments", cn); da.SelectCommand = cmd; DataSet1.Fill(da); Option 3 --> 3, SqlConnection cn = new SqlConnection(); cn.ConnectionString = "Data Source=SQLSERVER01;Initial Catalog=HR;User id=sa;Pas sword=niit#1234"; DataSet DataSet1 = new DataSet(); SqlDataAdapter da = da.CreateSqlDataAdapter(); SqlCommand cmd=new SqlCommand("Select * from Departments", cn); da.SelectCommand = cmd; da.Fill(DataSet1); Option 4 --> 4, SqlConnection cn = new SqlConnection(); cn.ConnectionString = "Data Source=SQLSERVER01;Initial Catalog=HR;User id=sa;Pas sword=niit#1234"; DataSet DataSet1 = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd=new SqlCommand("Select * from Departments"); da.Fill(DataSet1); Solution --> 1 Question --> Sam wants to add two tables, Department and Employee, in a single d ataset. He also wants to create a relation between the tables on a common field that is Department ID. In addition, he wants to add the tables' relation informa tion in the dataset. Which of the following code snippets will allow him to do s o? Option 1 --> 1, DataSet ds = new DataSet();

DataTable dt = ds.Tables.Add("Department"); dt.Columns.Add("Department ID", typeof(string)); dt.Columns.Add("Department Name", typeof(string)); dt.Columns.Add("Region", typeof(string)); DataTable dt1 = ds.Tables.Add("Employee"); dt1.Columns.Add("Department ID", typeof(string)); dt1.Columns.Add("Employee ID", typeof(string)); dt1.Columns.Add("Employee Name", typeof(string)); ds.PrimaryKey = new DataColumn[]{dt.Columns["Department ID"]}; ds.Relations("DepartmentDetails", dt1.Columns["Department ID"], dt.Columns["Department ID"]); Option 2 --> 2, DataSet ds = new DataSet(); DataTable dt = ds.Tables.Add("Department"); dt.Columns.Add("Department ID", typeof(string)); dt.Columns.Add("Department Name", typeof(string)); dt.Columns.Add("Region", typeof(string)); DataTable dt1 = ds.Tables.Add("Employee"); dt1.Columns.Add("Department ID", typeof(string)); dt1.Columns.Add("Employee ID", typeof(string)); dt1.Columns.Add("Employee Name", typeof(string)); dt.PrimaryKey = new DataColumn[]{dt.Columns["Employee ID"]}; ds.Relations.Add("DepartmentDetails", dt1.Columns["Employee ID"], dt.Columns["Employee ID"]); Option 3 --> 3, DataSet ds = new DataSet(); DataTable dt = ds.Tables.Add("Department"); dt.Columns.Add("Department ID", typeof(string)); dt.Columns.Add("Department Name", typeof(string)); dt.Columns.Add("Region", typeof(string)); DataTable dt1 = ds.Tables.Add("Employee"); dt1.Columns.Add("Employee ID", typeof(string)); dt1.Columns.Add("Employee Name", typeof(string)); dt.PrimaryKey = new DataColumn[]{dt.Columns["Department ID"]}; ds.Relations.Add("DepartmentDetails", dt1.Columns["Department ID"], dt.Columns["Department ID"]); Option 4 --> 4, DataSet ds = new DataSet(); DataTable dt = ds.Tables.Add("Department"); dt.Columns.Add("Department ID", typeof(string)); dt.Columns.Add("Department Name", typeof(string)); dt.Columns.Add("Region", typeof(string)); DataTable dt1 = ds.Tables.Add("Employee");

dt1.Columns.Add("Department ID", typeof(string)); dt1.Columns.Add("Employee ID", typeof(string)); dt1.Columns.Add("Employee Name", typeof(string)); dt.PrimaryKey = new DataColumn[]{dt.Columns["Department ID"]}; ds.Relations.Add("DepartmentDetails", dt1.Columns["Department ID"], dt.Columns["Department ID"]); Solution --> 4 Question --> Sam wants to filter and delete the records from a DataView where th e year is greater than 1995. Which of the following code snippets will he use to achieve the same? Option 1 --> 1, DataView dv = new DataView(); dv.RowFilter = "Year > 1995"; dv.RowStateFilter = DataViewRowState.Deleted; Option 2 --> 2, DataView dv = dv.CreateDataView(); dv.RowFilter = "Year > 1995"; dv.RowStateFilter = DataViewRowState.Deleted; Option 3 --> 3, DataView dv = new DataView(); dv.RowFilter = "Year > 1995"; dv.RowStateFilter = DataViewRowState.Delete; Option 4 --> 4, DataView dv = dv.CreateDataView(); dv.RowFilter = "Year > 1995"; dv.RowStateFilter = DataViewRowState.Delete; Solution --> 1 Question --> John wants to sort two columns, Salary and Year. He wants to sort t he Salary column in the ascending order and the Year column in the descending or der. Which of the following code snippets allows him to do so? Option 1 --> 1, DataView dv = new DataView(); dv.Sort = "Salary ASC, Year DESC"; Option 2 --> 2, DataView dv = dv.CreateDataView(); dv.Sort = "Salary ASC, Year DESC"; Option 3 --> 3, DataView dv = new DataView(); dv.Sort = "Salary Ascending, Year Descending"; Option 4 --> 4, DataView dv = dv.CreateDataView(); dv.Sort = "Salary Ascending, Year Descending"; Solution --> 1 Question --> Peter has created an application in which he wants that a user shou

ld select an employee code from a combo box and the details of the selected empl oyee are retrieved from the database. He has written the following code snippet in the application: string val = comboBox1.Text.ToString(); string constr = "Data Source=SQLSERVER01;User ID=sa;password=niit#1234;Initial C atalog=HR"; SqlConnection con = new SqlConnection(); con.ConnectionString = constr; con.Open(); string str = "select * from employees where ccode=@val"; SqlCommand cmd = new SqlCommand(str, con); cmd.CommandType = CommandType.Text; SqlParameter sql; sql.Value = val; However, when he executed the code snippet, an error occurred. Analyze the code snippet and provide the correct code snippet. Option 1 --> 1, string val = comboBox1.Text.ToString(); string constr = "Data Source=SQLSERVER01;User ID=sa;password=niit#1234;Initial C atalog=HR"; SqlConnection con = new SqlConnection(); con.ConnectionString = constr; con.Open(); string str = "select * from employees where ccode=@val"; SqlCommand cmd = new SqlCommand(str, con); cmd.CommandType = CommandType.Text; SqlParameter sql; sql = cmd.Parameters.Add("@val", SqlDbType.VarChar, 15); sql.Value = val; Option 2 --> 2, string val = comboBox1.Text.ToString(); string constr = "Data Source=SQLSERVER01;User ID=sa;password=niit#1234;Initial C atalog=HR"; SqlConnection con = new SqlConnection(); con.ConnectionString = constr; con.Open(); string str = "select * from employees where ccode=@val"; SqlCommand cmd = new SqlCommand(str, con); cmd.CommandType = CommandType.Text; SqlParameter sql; sql = sql.Parameters.Add("@val", SqlDbType.VarChar, 15); sql.Value = val; Option 3 --> 3, string val = comboBox1.Text.ToString(); string constr = "Data Source=SQLSERVER01;User ID=sa;password=niit#1234;Initial C atalog=HR";

SqlConnection con = new SqlConnection(); con.ConnectionString = constr; con.Open(); string str = "select * from employees where ccode=@val"; SqlCommand cmd = new SqlCommand(str); cmd.CommandType = CommandType.Text; SqlParameter sql; sql = cmd.Parameters.Add("@val", SqlDbType.VarChar, 15); sql.Value = val; Option 4 --> 4, string val = comboBox1.Text.ToString(); string constr = "Data Source=SQLSERVER01;User ID=sa;password=niit#1234;Initial C atalog=HR"; SqlConnection con = new SqlConnection(); con.ConnectionString = constr; con.Open(); string str = "select * from employees where ccode=@val"; SqlCommand cmd = new SqlCommand(str, con); cmd.CommandType = CommandType.Text; SqlParameter sql; sql = cmd.Add.Parameters("@val", SqlDbType.VarChar, 15); sql.Value = val; Solution --> 1 Question --> Peter has created a console application in which he is retrieving d ata 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=AdventureWork s;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(); However, when Peter executed the application, it threw an error. Analyze the cod e snippet and provide the correct code snippet. Option 1 --> 1, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=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 = new SqlDataReader(); while (dr.Read()) { Console.WriteLine(dr[0] + "" + dr[1]); } cn.Close();

Option 2 --> 2, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=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 = cmd.Execute(); while (dr.Read()) { Console.WriteLine(dr[0] + "" + dr[1]); } cn.Close();

Option 3 --> 3, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=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 = cmd.ExecuteReader(); while (dr.ExecuteReader()) { Console.WriteLine(dr[0] + "" + dr[1]); } cn.Close();

Option 4 --> 4, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=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 = cmd.ExecuteReader(); while (dr.Read()) { Console.WriteLine(dr[0] + "" + dr[1]); } cn.Close();

Solution --> 4

Question --> Peter has created an application to add records in a table and upda te the database. For this, he has written the following code snippet: SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Data Source=SQLSERVER01;Initial Catalog=HR;User i d=sa;Password=niit#1234"; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter("Select * from Employees", connectio n); SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(connection); DataSet ds = new DataSet("Employees"); adapter.Fill(ds, "Employees"); DataRow row = ds.Tables["Employees"].NewRow(); row["cEmployeeCode"] = "000018"; row["vFirstName"] = "Peter"; row["vLastName"] = "Martin"; ds.Tables["Employees"].Rows.Add(row); adapter.Update(ds, "Employees"); connection.Close(); However, when Peter executed the application, it threw an error. Analyze the cod e snippet and provide the correct code snippet. Option 1 --> 1, SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Data Source=SQLSERVER01;Initial Catalog=HR;User i d=sa;Password=niit#1234"; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter("Select * from Employees", connectio n); SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter); DataSet ds = new DataSet("Employees"); adapter.Fill(ds, "Employees"); DataRow row = ds.Tables["Employees"].Add.NewRow(); row["cEmployeeCode"] = "000018"; row["vFirstName"] = "Peter"; row["vLastName"] = "Martin"; ds.Tables["Employees"].Rows.Add(row); adapter.Update(ds, "Employees"); connection.Close();

Option 2 --> 2, SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Data Source=SQLSERVER01;Initial Catalog=HR;User i d=sa;Password=niit#1234"; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter("Select * from Employees", connectio n); SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter); DataSet ds = new DataSet("Employees"); adapter.Fill(ds, "Employees");

DataRow row = ds.Tables["Employees"].NewRow(); row["cEmployeeCode"] = "000018"; row["vFirstName"] = "Peter"; row["vLastName"] = "Martin"; ds.Tables["Employees"].Rows.Add(row); adapter.Update(ds, "Employees"); connection.Close();

Option 3 --> 3, SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Data Source=SQLSERVER01;Initial Catalog=HR;User i d=sa;Password=niit#1234"; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter("Select * from Employees", connectio n); SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter); DataSet ds = new DataSet("Employees"); ds.Fill(adapter, "Employees"); DataRow row = ds.Tables["Employees"].NewRow(); row["cEmployeeCode"] = "000018"; row["vFirstName"] = "Peter"; row["vLastName"] = "Martin"; ds.Tables["Employees"].Rows.Add(row); adapter.Update(ds, "Employees"); connection.Close();

Option 4 --> 4, SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Data Source=SQLSERVER01;Initial Catalog=HR;User i d=sa;Password=niit#1234"; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter("Select * from Employees", connectio n); SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter); DataSet ds = new DataSet("Employees"); adapter.Fill(ds, "Employees"); DataRow row = ds.Tables["Employees"].NewRow(); row["cEmployeeCode"] = "000018"; row["vFirstName"] = "Peter"; row["vLastName"] = "Martin"; ds.Tables["Employees"].Rows.AddNew(row); ds.Update(ds, "Employees"); connection.Close();

Solution --> 2 Question --> 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 foll

owing 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"; DataSet ds1 = new DataSet(); da.Fill(ds1, "Country"); cn.Close(); ds.Merge(ds1, true, MissingSchemaAction.Add); However, when he executed the application, it threw an error. Analyze the code s nippet to identify the error and provide the correct code snippet. Option 1 --> 1, SqlConnection cn = new SqlConnection("Data Source=SQLSERVER01;I nitial Catalog=HR;User id=sa;Password=niit#1234"); SqlCommand cmd = cn.CreateCommand(); cmd.CommandText = "SELECT * FROM Department"; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); cn.Open(); da.Fill(ds, "Department"); cmd.CommandText = "SELECT * FROM Country"; DataSet ds1 = new DataSet(); da.Fill(ds1, "Country"); cn.Close(); da.Merge(ds1, true, MissingSchemaAction.Add,ds); Option 2 --> 2, SqlConnection cn = new SqlConnection("Data Source=SQLSERVER01;I nitial Catalog=HR;User id=sa;Password=niit#1234"); SqlCommand cmd = cn.CreateCommand(); cmd.CommandText = "SELECT * FROM Department"; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); cn.Open(); da.Fill(ds, "Department"); cmd.CommandText = "SELECT * FROM Country"; DataSet ds1 = new DataSet(); ds.Fill(da, "Country"); cn.Close(); ds.Merge(ds1, true, MissingSchemaAction.Add);

Option 3 --> 3, SqlConnection cn = new SqlConnection("Data Source=SQLSERVER01;I nitial Catalog=HR;User id=sa;Password=niit#1234"); SqlCommand cmd = cn.CreateCommand(); cmd.CommandText = "SELECT * FROM Department"; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); cn.Open(); da.Fill(ds, "Department"); cmd.CommandText = "SELECT * FROM Country"; DataSet ds1 = new DataSet(); da.Fill(ds1, "Country"); cn.Close(); ds.Merge(ds1, true, MissingSchemaAction.Add); Option 4 --> 4, SqlConnection cn = new SqlConnection("Data Source=SQLSERVER01;I nitial Catalog=HR;User id=sa;Password=niit#1234"); SqlCommand cmd = cn.CreateCommand(); cmd.CommandText = "SELECT * FROM Department"; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); cn.Open(); da.Fill(ds, "Department"); cmd.CommandText = "SELECT * FROM Country"; DataSet ds1 = new DataSet(); ds.Fill(da, "Country"); cn.Close(); da.Merge(ds1, true, MissingSchemaAction.Add,ds); Solution --> 3 Question --> You are creating an application in which you want to view the emplo yee codes of the employees who are married. For this, you need to filter the dat a 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=AdventureWork s;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 = ds.Tables["HumanResources.Employee"];

DataView dv = ds.CreateDataView(dt, "MaritalStatus = 'M'", "MaritalStatus", Data ViewRowState.CurrentRows); On execution, the application throws an error. Analyze the code snippet and prov ide the solution. Option 1 --> 1, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=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 = ds.Tables["HumanResources.Employee"]; DataView dv = new DataView(dt, "MaritalStatus = 'M'", "MaritalStatus", DataViewR owState.CurrentRows); Option 2 --> 2, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=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); DataSet ds = new DataSet(); da.Fill(ds, "HumanResources.Employee"); DataTable dt = ds.Tables["HumanResources.Employee"]; DataView dv = new DataView(dt, "MaritalStatus = 'M'", "MaritalStatus", DataViewR owState.CurrentRows); Option 3 --> 3, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=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 = da. CreateNewDataSet(); da.Fill(ds, "HumanResources.Employee"); DataTable dt = ds.Tables["HumanResources.Employee"]; DataView dv = new DataView(dt, "MaritalStatus = 'M'", "MaritalStatus", DataViewR owState.CurrentRows); Option 4 --> 4, string connectionString = "Data Source=SQLSERVER01;Initial Cata log=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 = da.CreateNewDataSet(); da.Fill(ds, "HumanResources.Employee"); DataTable dt = ds.Tables["HumanResources.Employee"]; DataView dv = dt.CreateDataView(dt, "MaritalStatus = 'M'", "MaritalStatus", Data ViewRowState.CurrentRows); Solution --> 1 Question --> Which of the following options allows the DataReader class to handl e columns, which store large binary data? Option 1 --> 1, The SequentialAccess property Option 2 --> 2, The ExecuteReader() method Option 3 --> 3, The GetBytes() method Option 4 --> 4, The SingleRow property Solution --> 1 Question --> Which of the following options is the starting position of the upda te in the syntax of the UPDATETEXT function? Option 1 --> 1, Pointer Option 2 --> 2, Offset Option 3 --> 3, Delete_Length Option 4 --> 4, Data Solution --> 2 Question --> Which of the following WriteToServer() method copies all rows from the DataRow array to a destination table? Option 1 --> 1, SqlBulkCopy.WriteToServer (DataTable) Option 2 --> 2, SqlBulkCopy.WriteToServer (IDataReader) Option 3 --> 3, SqlBulkCopy.WriteToServer (DataRow[]) Option 4 --> 4, SqlBulkCopy.WriteToServer (DataTable, DataRowState) Solution --> 3 Question --> The __________ class is used for bulk copy of records.

Option 1 --> 1, SqlCopyBulk Option 2 --> 2, SqlCommand Option 3 --> 3, SqlConnection Option 4 --> 4, SqlBulkCopy Solution --> 4 Question --> Which of the following namespaces will you include to use the Permi ssionState enumeration? Option 1 --> 1, System.Security.Permissions Option 2 --> 2, System.Security.Policy Option 3 --> 3, System.Security.AccessControl Option 4 --> 4, System.Security.Authentication Solution --> 1 Question --> Which of the following classes will you use to execute SQL notifica tions? Option 1 --> 1, The SqlClientPermission class Option 2 --> 2, The SqlDependency class Option 3 --> 3, The SqlBulkCopy class Option 4 --> 4, The DataAdapter class Solution --> 2 Question --> Which of the following properties of a transaction states that any data modification made by one transaction must be independent from the modificat ions made by the other transaction? Option 1 --> 1, Durability Option 2 --> 2, Consistency Option 3 --> 3, Atomicity Option 4 --> 4, Isolation Solution --> 4 Question --> A local transaction is created and managed within the ____________ namespace. Option 1 --> 1, System.Transactions

Option 2 --> 2, System.Data Option 3 --> 3, System.Data.Sql Option 4 --> 4, System.Data.SqlClient Solution --> 1 Question --> Which of the following methods is called when a transaction is succ essfully completed? Option 1 --> 1, Rollback() Option 2 --> 2, Commit() Option 3 --> 3, BeginTransaction() Option 4 --> 4, ExecuteNonQuery() Solution --> 2 Question --> Which of the following isolation levels is used when accuracy is re quired on long-running queries and multi-statement transactions, but no updates are performed on the data? Option 1 --> 1, Snapshot Option 2 --> 2, Repeatable Read Option 3 --> 3, Read Committed with Snapshots Option 4 --> 4, Read Committed with Locks Solution --> 1 Question --> You are using a DbCommand object, command, in your application. You want to change the behavior of the command object to a sequential stream when y ou execute the ExecuteReader() method. Which of the following code snippet allow s you to do so? Option 1 --> 1, command.ExecuteReader(CommandBehavior.SequentialAccess); Option 2 --> 2, command.ExecuteReader(Behavior.SequentialAccess); Option 3 --> 3, command.ExecuteReader(CommandBehavior(SequentialAccess)); Option 4 --> 4, command.ExecuteReader(CommandBehavior.SequentialAccess(command) ); Solution --> 1 Question --> Identify the correct syntax of the UPDATETEXT function. Option 1 --> 1, UPDATETEXT <Table_Name>.<Column_Name> <Data> <Pointer> <Offset> <Delete_Length>

Option 2 --> 2, UPDATETEXT <Table_Name>.<Column_Name> <Offset> <Pointer> <Delet e_Length> <Data> Option 3 --> 3, UPDATETEXT <Table_Name>.<Column_Name> <Pointer> <Offset> <Delet e_Length> <Data> Option 4 --> 4, UPDATETEXT <Table_Name>.<Column_Name> <Offset> <Delete_Length> <Pointer> <Data> Solution --> 3 Question --> You need to enable a Service Broker for a SQL Server database. Whic h of the following SQL statements will you use? Option 1 --> 1, ALTER DATABASE DATABASE_NAME SET ENABLE.BROKER; Option 2 --> 2, ALTER DATABASE DATABASE_NAME SET ENABLE_BROKER; Option 3 --> 3, ALTER DATABASE DATABASE_NAME SET BROKER.ENABLE; Option 4 --> 4, ALTER DATABASE DATABASE_NAME SET BROKER_ENABLE; Solution --> 2 Question --> You want to create and perform local transactions against a single data source. Which of the following options provide you with the methods for doi ng so? Option 1 --> 1, The SqlConnection Class Option 2 --> 2, The IDataReader interface Option 3 --> 3, The SqlCommand class Option 4 --> 4, The IDbTransaction interface Solution --> 4 Question --> You are creating an application that implements transactions. In th e application, you want that the queries running inside one transaction are affe cted by the committed changes in another transaction. Which of the following typ es of transaction isolation levels will you use? Option 1 --> 1, Read Uncommitted Option 2 --> 2, Read Committed with Locks Option 3 --> 3, Read Committed with Snapshots Option 4 --> 4, Repeatable Read Solution --> 1 Question --> You are creating an application for a hospital. The application sho uld enable the management of the hospital to view the photographs of all the pat ients and store them in a file. The details of all the patients including the ph

otographs are stored in a database. Which of the following code snippet will you write to achieve the required functionality? Option 1 --> 1,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 = command.ExecuteReader(CommandBehavior.SequentialAcce ss); while (myReader.Read()) { patientID = myReader.GetString(0); string fileName = @"C:\Patient" + patientID + ".bmp"; fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write); bw = new BinaryWriter(fs); startIndex = 0; retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize); while (retval == bufferSize){ bw.Write(outbyte); bw.Flush(); startIndex += bufferSize; retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize); } bw.Write(outbyte, 0, (int)retval - 1); bw.Flush(); bw.Close(); fs.Close(); } myReader.Close(); connection.Close(); } Option 2 --> 2,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 = command.ExecuteReader(CommandBehavior.RandomAccess); while (myReader) { patientID = myReader.GetString(0); string fileName = @"C:\Patient" + patientID + ".bmp"; fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write); bw = new BinaryWriter(fs); startIndex = 0; retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize); while (retval == bufferSize){ bw.Write(outbyte); bw.Flush(); startIndex += bufferSize; retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize); } bw.Write(outbyte, 0, (int)retval - 1);

bw.Flush(); bw.Close(); fs.Close(); } myReader.Close();connection.Close(); } Option 3 --> 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; string patientID = ""; connection.Open(); SqlDataReader myReader = command.ExecuteReader(Command.SequentialAccess); while (myReader.Read()){ patientID = myReader.GetString(0); string fileName = @"C:\Patient" + patientID + ".bmp"; fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write); bw = new BinaryWriter(fs); startIndex = 0; retval = myReader.GetBytes(1, startIndex bufferSize); while (retval == bufferSize) { bw.Write(outbyte); bw.Flush(); startIndex += bufferSize; retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize); } bw.Write(outbyte, 0, (int)retval - 1); bw.Flush(); bw.Close(); fs.Close(); } myReader.Close(); connection.Close(); } Option 4 --> 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 = command.ExecuteReader(CommandBehavior.Access(Sequent ial)); while (myReader.Read()) { patientID = myReader.GetString(0); string fileName = @"C:\Patient" + patientID + ".bmp"; fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write); bw = new BinaryWriter(fs); startIndex = 0; retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize); while (retval == bufferSize) { bw.Write(outbyte); bw.Flush();

startIndex += bufferSize; retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize); } bw.Write(outbyte, 0, (int)retval - 1); bw.Flush(); bw.Close(); fs.Close(); } myReader.Close(); connection.Close(); } Solution --> 1 Question --> You are creating an application in which you have to write BLOB val ue to the database. To optimize the usage of system resources, you are writing t he BLOB to the database in chunks. Which of the following code snippets will you write to achieve the required functionality? Option 1 --> 1, FileStream file = new FileStream(curFileName, FileMode.OpenOrCr eate, FileAccess.Read); byte[] rawdata = new byte[file.Length]; file.Read(rawdata, 0, System.Convert.ToInt32(file.Length)); file.Close(); string sql = "SELECT * FROM PATIENTS"; SqlConnection connection = new SqlConnection(); connection.ConnectionString = connectionString; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(sql, connection); SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter); DataSet ds = new DataSet("PATIENTS"); adapter.Fill(ds, "PATIENTS"); DataRow row = ds.Tables["PATIENTS"].NewRow.Add(); row["cPatientCode"] = "P009"; row["imPhoto"] = rawdata; ds.Tables["EMPLOYEES"].Rows.Add(row); adapter.Update(ds, "PATIENTS"); Option 2 --> 2, FileStream file = new FileStream(curFileName, FileMode.OpenOrCr eate, FileAccess.Read); byte[] rawdata = new byte[file.Length]; file.Read(rawdata, 0, System.Convert.ToInt32(file.Length)); file.Close(); string sql = "SELECT * FROM PATIENTS"; SqlConnection connection = new SqlConnection(); connection.ConnectionString = connectionString; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(sql, connection); SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter); DataSet ds = new DataSet("PATIENTS"); adapter.Fill(ds, "PATIENTS"); DataRow row = ds.Tables["PATIENTS"].NewRow(); row["cPatientCode"] = "P009"; row["imPhoto"] = rawdata; ds.Tables["EMPLOYEES"].Rows.Add(row);

adapter.Update(ds, "PATIENTS"); Option 3 --> 3, FileStream file = new FileStream(curFileName, FileMode.OpenOrCr eate); byte[] rawdata = new byte[file.Length]; file.Read(rawdata, 0, System.Convert.ToInt32(file.Length)); file.Close(); string sql = "SELECT * FROM PATIENTS"; SqlConnection connection = new SqlConnection(); connection.ConnectionString = connectionString; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(sql); SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter); DataSet ds = new DataSet("PATIENTS"); adapter.Fill(ds, "PATIENTS"); DataRow row = ds.Tables["PATIENTS"].NewRow(); row["cPatientCode"] = "P009"; row["imPhoto"] = rawdata; ds.Tables["EMPLOYEES"].Rows.Add(row); adapter.Update(ds, "PATIENTS"); Option 4 --> 4, FileStream file = new FileStream(curFileName, FileMode.OpenOrCr eate, FileAccess.Read); byte[] rawdata = new byte[file.Length]; file.Read(rawdata, 0, System.Convert.ToInt32(file.Length)); file.Close(); string sql = "SELECT * FROM PATIENTS"; SqlConnection connection = new SqlConnection(); connection.ConnectionString = connectionString; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(sql, connection); SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(); DataSet ds = new DataSet("PATIENTS"); adapter.Fill(ds, "PATIENTS"); DataRow row = ds.Tables["PATIENTS"].NewRow(); row["cPatientCode"] = "P009"; row["imPhoto"] = rawdata; ds.Tables["EMPLOYEES"].Rows.AddRow; adapter.Update(ds, "PATIENTS"); Solution --> 2 Question --> You have to perform the bulk copy operation. Identify the correct s equence of steps to perform the bulk copy operation. Option 1 --> 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 DestinationTableName property to the name of the target table. 5. Call the WriteToServer() method.

Option 2 --> 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 DestinationTableName property to the name of the target table. Option 3 --> 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 DestinationTableName property to the name of the target table. 5. Call the WriteToServer() method. Option 4 --> 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 DestinationTableName property to the name of the target table. Solution --> 3 Question --> Sam is creating an application in which a transaction has been crea ted 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 empdetail s table. If the transaction successfully executes the command, the Commit() meth od 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#12 34"; SqlConnection cn = new SqlConnection(); cn.ConnectionString = connectString; cn.Open(); SqlTransaction tran = null; Being a member of the same development team as Sam was, you need to complete the code. Which of the following code snippets will you write to complete the preceding code? Option 1 --> 1,try { tran = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("INSERT INTO empdetails(ccode,cname, caddress,cstate,ccountry, cDesignation,cDepartment)VALUES(1101,'Linda Taylor','O xfordshire','London','UK','Manager', 'Finance')", cn, tran); cmd.ExecuteQuery(); tran.Commit(); Console.WriteLine("Transaction Committed\n"); } catch (SqlException ex)

{ tran.Rollback(); Console.WriteLine("Error - TRANSACTION ROLLED BACK\n" + Message); } catch (System.Exception ex) { Console.WriteLine("System Error\n" + ex.Message); } finally { cn.Close(); } Console.ReadLine(); } Option 2 --> 2,try { tran = cn.BeginTransaction(); SqlCommand cmd = tran.CreateSqlCommand("INSERT INTO empdetails(ccode ,cname,caddress,cstate,ccountry, cDesignation,cDepartment)VALUES(1101,'Linda Tay lor','Oxfordshire','London','UK','Manager', 'Finance')", cn, tran); cmd.ExecuteNonQuery(); tran.Commit(); Console.WriteLine("Transaction Committed\n"); } catch (SqlException ex) { tran.Rollback(); Console.WriteLine("Error - TRANSACTION ROLLED BACK\n" + ex.Message); } catch (System.Exception ex) { Console.WriteLine("System Error\n" + ex.Message); } finally { cn.Close(); } Console.ReadLine(); } Option 3 --> 3,try { tran = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("INSERT INTO empdetails(ccode,cname, caddress,cstate,ccountry, cDesignation,cDepartment)VALUES(1101,'Linda Taylor','O xfordshire','London','UK','Manager', 'Finance')", cn, tran); cmd.ExecuteNonQuery(); tran.Commit(); Console.WriteLine("Transaction Committed\n"); } catch (SqlException ex) { tran.Rollback(cmd); Console.WriteLine("Error - TRANSACTION ROLLED BACK\n" + ex.Message); } catch (System.Exception ex) {

Console.WriteLine("System Error\n" + ex.Message); } finally { cn.Close(); } Console.ReadLine(); } Option 4 --> 4,try { tran = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("INSERT INTO empdetails(ccode,cname, caddress,cstate,ccountry, cDesignation,cDepartment)VALUES(1101,'Linda Taylor','O xfordshire','London','UK','Manager', 'Finance')", cn, tran); cmd.ExecuteNonQuery(); tran.Commit(); Console.WriteLine("Transaction Committed\n"); } catch (SqlException ex) { tran.Rollback(); Console.WriteLine("Error - TRANSACTION ROLLED BACK\n" + ex.Message); } catch (System.Exception ex) { Console.WriteLine("System Error\n" + ex.Message); } finally { cn.Close(); } Console.ReadLine(); } Solution --> 4 Question --> 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 INTO EmployeeBackUp (cEmployeeCode,vFi rstName,vLastName)VALUES(000005,'David','Cooper')"; cmd1.ExecuteNonQuery(); Option 1 --> 1,SqlCommand rowCount = new SqlCommand("SELECT COUNT(*) FROM dbo.E mployeeBackUp",cn);

long countStart = System.Convert.ToInt32(rowCount.Execute()); Console.WriteLine("Starting row count = {0}", countStart); SqlCommand commandSourceData = new SqlCommand("SELECT cEmployeeCo de,vFirstName,vLastName FROM Employees", cn); SqlDataReader reader = commandSourceData.ExecuteReader(); using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionString, S qlBulkCopyOptions.KeepIdentity SqlBulkCopyOptions.UseInternalTransaction)) { bulkCopy.BatchSize = 10; bulkCopy.DestinationTableName = "dbo.EmployeeBackUp"; try { bulkCopy.WriteToServer(reader);} catch (Exception ex) {Console.WriteLine(ex.Message);} finally {reader.Close();} } long countEnd = System.Convert.ToInt32(rowCount.ExecuteScalar()); Console.WriteLine("{0} rows were added.", countEnd - countStart); }}} private static string GetConnectionString() { return "Data Source=SQLSERVER01;Initial Catalog=HR;User id=sa;Password= niit#1234";} Option 2 --> 2,SqlCommand rowCount = new SqlCommand("SELECT COUNT(*) FROM dbo.E mployeeBackUp",cn); long countStart = System.Convert.ToInt32(rowCount.ExecuteScalar() ); Console.WriteLine("Starting row count = {0}", countStart); SqlCommand commandSourceData = new SqlCommand("SELECT cEmployeeCo de,vFirstName,vLastName FROM Employees", cn); SqlDataReader reader = commandSourceData.ExecuteReader(); using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionString, S qlBulkCopyOptions.KeepIdentity SqlBulkCopyOptions.UseInternalTransaction)) { bulkCopy.BatchSize = 10; bulkCopy.Destination = "dbo.EmployeeBackUp"; try{bulkCopy.WriteToServer(reader);} catch (Exception ex) {Console.WriteLine(ex.Message);} finally {reader.Close();} } long countEnd = System.Convert.ToInt32(rowCount.ExecuteScalar()); Console.WriteLine("{0} rows were added.", countEnd - countStart); }}} private static string GetConnectionString() {return "Data Source=SQLSERVER01;Initial Catalog=HR;User id=sa;Password=n iit#1234";} Option 3 --> 3,SqlCommand rowCount = new SqlCommand("SELECT COUNT(*) FROM dbo.E mployeeBackUp",cn); long countStart = System.Convert.ToInt32(rowCount.ExecuteScalar() ); Console.WriteLine("Starting row count = {0}", countStart); SqlCommand commandSourceData = new SqlCommand("SELECT cEmployeeCo de,vFirstName,vLastName FROM Employees", cn); SqlDataReader reader = commandSourceData.ExecuteReader(); using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionString, S

qlBulkCopyOptions.KeepIdentity SqlBulkCopyOptions.UseInternalTransaction)) { bulkCopy.BatchSize = 10; bulkCopy.DestinationTableName = "dbo.EmployeeBackUp"; try {bulkCopy.WriteToServer(reader);} catch (Exception ex) {Console.WriteLine(ex.Message);} finally {reader.Close();} } long countEnd = System.Convert.ToInt32(rowCount.ExecuteScalar()); Console.WriteLine("{0} rows were added.", countEnd - countStart); }}} private static string GetConnectionString() {return "Data Source=SQLSERVER01;Initial Catalog=HR;User id=sa;Password=n iit#1234";} Option 4 --> 4,SqlCommand rowCount = new SqlCommand("SELECT COUNT(*) FROM dbo.E mployeeBackUp",cn); long countStart = System.Convert.ToInt32(rowCount.ExecuteScalar() ); Console.WriteLine("Starting row count = {0}", countStart); SqlCommand commandSourceData = new SqlCommand("SELECT cEmployeeCo de,vFirstName,vLastName FROM Employees", cn); SqlDataReader reader = commandSourceData.ExecuteReader(); using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionString, S qlBulkCopyOptions.KeepIdentity SqlBulkCopyOptions.Transaction)) { bulkCopy.BatchSize = 10; bulkCopy.DestinationTableName = "dbo.EmployeeBackUp"; try{bulkCopy.WriteToServer();} catch (Exception ex) {Console.WriteLine(ex.Message);} finally {reader.Close();} } long countEnd = System.Convert.ToInt32(rowCount.ExecuteScalar()); Console.WriteLine("Ending row count = {0}",countEnd); Console.WriteLine("{0} rows were added.", countEnd - countStart); }}} private static string GetConnectionString() {return "Data Source=SQLSERVER01;Initial Catalog=HR;User id=sa;Password=n iit#1234";} Solution --> 3 Question --> Sam is creating an application for a hospital. The application shou ld 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(connectionStri ng)) 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(connect

ionString)) Line 6: { destinationConnection.Open(); Line 7: using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnection)) Line 8: { bulkCopy.DestinationTableName = "Patients_backUp"; try Line 9: {bulkCopy.WriteToServer(reader);} Line 10: catch (Exception ex) Line 11: {Console.WriteLine(ex.Message);} Line 12: finally Line 13: { reader.Close(); } } }} However, when he executed the application, he found that it is not working as de sired. Identify the line that has error and provide the correct code snippet. Option 1 --> 1,Line 7: using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlCo nnection)) has error. It should be: using (SqlBulkCopy bulkCopy = new SqlBulkCopy(destinationConnection)) Option 2 --> 2,Line 9: should be: {bulkCopy.Write(reader);} Option 3 --> 3,Line 9: should be: {bulkCopy.WriteTo(reader);} {bulkCopy.WriteToServer(reader);} has error. It

{bulkCopy.WriteToServer(reader);} has error. It

Option 4 --> 4,Line 7: using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlCo nnection)) has error. It should be: using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sourceConnection)) Solution --> 1 Question --> Sam wants a client-side code to execute SQL notification. For this, the client-side code requires necessary permissions. To provide the required pe rmissions to the client-side code, Sam has written the following code snippet: private bool CanRequestNotifications() { Permissions permission = new Permissions(PermissionState.Unrestricted); try { permission.Demand(); return true; } catch (System.Exception) { return false; } } However, when he executed the preceding code snippet, he found that it is throwi ng an error. Analyze the code snippet and provide the correct code. Option 1 --> 1, private bool CanRequestNotifications() { ClientPermissions permission = new ClientPermissions(PermissionState.Unrestricted); try { permission.Demand();

return true; } catch (System.Exception) { return false; } } Option 2 --> 2, private bool CanRequestNotifications() { SqlClientPermission permission = new SqlClientPermission(Permissions.Unrestricted); try { permission.Demand(); return true; } catch (System.Exception) { return false; } } Option 3 --> 3, private bool CanRequestNotifications() { SqlClientPermission permission = new SqlClientPermission(PermissionState.Unrestricted); try { permission.Demand(); return true; } catch (System.Exception) { return false; } } Option 4 --> 4, private bool CanRequestNotifications() { ClientPermission permission = new ClientPermission(Permissions.Unrestricted); try { permission.Demand(); return true; } catch (System.Exception) { return false; } } Solution --> 3

Question --> Peter wants to execute SQL notifications in his application. For th is, 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(connectionString); 6. UpdateGrid(); } However, when he executed the application, he found that the preceding code snip pet has an error. Identify the line that has error and provide the correct code snippet. Option 1 --> 1, Line 3 has an error. The code should be: Line 3: private SqlDependency; Option 2 --> 2, Line 5 has an error. The code should be: Line 5: SqlDependency.Start(connectionString); Option 3 --> 3, Line 2 has an error. The code should be: Line 2: private void GridDelegate(DataTable table); Option 4 --> 4, Line 5 has an error. The code should be: Line 5: dep.Start(connectionString); Solution --> 2 Question --> Robert is creating an application in which the BeginTransaction() m ethod is called and a SQL command is passed that will insert one record in the e mpdetails 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=SQLSERVER 01;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 SqlCommand("INSERT INTO empdetails(ccode,cname,c address)VALUES(1101,'Linda Taylor','Oxfordshire')", cn, tran); Line 8: cmd.ExecuteNonQuery(); Line 9: tran.Commit();

Line 10: Console.WriteLine("Transaction Committed\n"); } Line 11: catch (SqlException ex) Line 12: {tran.Rollback();} catch (System.Exception ex) Line 13: {Console.WriteLine("System Error\n" + ex.Message); } Line 14: finally Line 15: {cn.Close();} On execution, the code snippet threw an error. Analyze the code snippet and prov ide the correct code snippet. Option 1 --> 1,Line 2: SqlConnection cn = CreateSqlConnection(); has error. It should be: SqlConnection cn = new SqlConnection(); Option 2 --> 2, Line 8: cmd.ExecuteNonQuery(); has errors. It should be: cmd.ExecuteQuery(); Option 3 --> 3,Line 6: tran = cn.BeginTransactions(); have errors. It should be : tran = cn.BeginTransaction(); Option 4 --> 4,Line 2: SqlConnection cn = CreateSqlConnection(); and Line 6: tran = cn.BeginTransactions(); have errors. These should be: SqlConnection cn = new SqlConnection(); and tran = cn.BeginTransaction(); Solution --> 4 Question --> Rebecca has written the following code snippet to demonstrate the u se 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(cUs erName,cPassword)VALUES('Darren', 'Cooper')", cn)) { 5. int rowsUpdated = cmd.Execute(); 6. if (rowsUpdated > 0) { 7. using(SqlConnection cn1 = new SqlConnection("Initial Cata log=HR;Data Source=SQLSERVER01;User id=sa;Password=niit#1234")) { 8. cn1.Open(); 9. using (SqlCommand cmd1 = new SqlCommand("DELETE Depart ment WHERE cDepartmentCode=1111", cn1)) { 10. int rowsUpdated1 = cmd1.ExecuteNonQuery(); 11. if (rowsUpdated1 > 0) { 12. ts.Completed(); 13. Console.WriteLine("Transaction Committed\n"); 14. cn1.Close();

} } } } } 15. } } 16. } } When she executed the application, it threw an error. Identify the line that is causing the error and provide the code. Option 1 --> 1, Line 5 and Line 12 are causing the error. The correct code shou ld be: Line 5: int rowsUpdated = cmd.ExecuteNonQuery(); Line 12: ts.Complete(); Option 2 --> 2, Line 5 is causing the error. The correct code should be: Line 5: int rowsUpdated = cmd.ExecuteQuery(); Option 3 --> 3, Line 1 is causing the error. The correct code should be: Line 1: using (TransactionScope ts = new TransactionScope.CreateTransaction()) Option 4 --> 4, Line 5 and Line 10 are causing the error. The correct code shou ld be: Line 5: int rowsUpdated = cmd.ExecuteQuery(); Line 10: int rowsUpdated1 = cmd1.Execute(); Solution --> 1 Question --> Which of the following properties of the XmlWriterSettings class ge ts or sets the level of compliance with which the System.Xml.XmlWriter complies? Option 1 --> 1, ConformanceLevel Option 2 --> 2, CloseOutput Option 3 --> 3, CheckCharacters Option 4 --> 4, Encoding Solution --> 1 Question --> Which of the following properties of the XmlReaderSettings class ge ts or sets a value indicating whether to do character checking or not? Option 1 --> 1, ConformanceLevel Option 2 --> 2, CheckCharacters Option 3 --> 3, ValidationType Option 4 --> 4, Schemas Solution --> 2 Console.ReadLine(); cn.Close();

Question --> The ____________ class uses the ValidationEventHandler() callback m ethod that is called when a validation error occurs. Option 1 --> 1, XmlWriter Option 2 --> 2, XmlWriterSettings Option 3 --> 3, XmlValidatingReader Option 4 --> 4, XmlConvert Solution --> 3 Question --> In the .NET Framework, NamedNodeMap is implemented by the _________ _____ class. Option 1 --> 1, XmlTextReader Option 2 --> 2, XmlDocument Option 3 --> 3, XmlNodeList Option 4 --> 4, XmlNamedNodeMap Solution --> 4 Question --> Which of the following namespaces contains the SqlXml class? Option 1 --> 1, System.Xml.XPath Option 2 --> 2, System.Xml.Schema Option 3 --> 3, System.Xml Option 4 --> 4, System.Data.SqlTypes Solution --> 4 Question --> You want to provide non-cached, forward-only, and write-only access to XML data. Which of the following classes enables you to achieve this? Option 1 --> 1, XmlWriter Option 2 --> 2, XmlWriterSettings Option 3 --> 3, XmlConvert Option 4 --> 4, XmlTextWriter Solution --> 1 Question --> You want to determine whether the XmlReader instance imposes valida tion or not. Which of the following classes enables you to do this?

Option 1 --> 1, XmlWriter Option 2 --> 2, XmlWriterSettings Option 3 --> 3, XmlReaderSettings Option 4 --> 4, XmlConvert Solution --> 3 Question --> You want to identify a row in the <DataInstance> block as modified. Which of the following attributes enables you to do this? Option 1 --> 1, hasErrors Option 2 --> 2, parentID Option 3 --> 3, hasChanges Option 4 --> 4, id Solution --> 3 Question --> You are writing a code in which you need to put all the attributes of an element node into a collection. Which of the following options enables you to achieve this? Option 1 --> 1, The NextSibling property Option 2 --> 2, The XmlElement.Attributes property Option 3 --> 3, The GetAttribute() method Option 4 --> 4, The GetAttributeNode() method Solution --> 2 Question --> You want to ignore inline schemas and load the XML data into the ex isting dataset schema. Which of the following XmlReadMode Options enables you to do so? Option 1 --> 1, IgnoreSchema Option 2 --> 2, InferSchema Option 3 --> 3, Auto Option 4 --> 4, DiffGram Solution --> 1 Question --> You need to create a program that creates an XML file, OrderDetails .xml, by using the XmlWriter class in .NET. Which of the following code snippets enables you to perform the task? Option 1 --> 1, static void Main(string[] args)

{ XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; settings.NewLineOnAttributes = true; using (XmlWriter writer = XmlWriter.Create("C:\\OrderDetails.xml", sett ings)) { writer.WriteComment("Order Details of Velocidade Inc."); writer.WriteStartElement("OrderDetails"); writer.WriteStartElement("Order"); writer.WriteAttributeString("OrderID","O001"); writer.WriteElementString("ProductName", "Toys"); writer.WriteElementString("Price", "100"); writer.WriteEndElement(); writer.WriteStartElement("Order"); writer.WriteAttributeString("OrderID", "O002"); writer.WriteElementString("ProductName","Stationary"); writer.WriteElementString("Price", "30"); writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); } } Option 2 --> 2, static void Main(string[] args) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = "*"; settings.NewLineOnAttributes = true; using (XmlWriter writer = XmlWriter.Create("C:\\OrderDetails.xml")) { writer.WriteComment("Order Details of Velocidade Inc."); writer.WriteStartElement("OrderDetails"); writer.WriteStartElement("Order"); writer.WriteAttributeString("OrderID","O001"); writer.WriteElementString("ProductName", "Toys"); writer.WriteElementString("Price", "100"); writer.WriteEndElement(); writer.WriteStartElement("Order"); writer.WriteAttributeString("OrderID", "O002"); writer.WriteElementString("ProductName","Stationary"); writer.WriteElementString("Price", "30"); writer.WriteEndElement(); writer.Flush(); } } Option 3 --> 3, static void Main(string[] args)

{ XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; settings.NewLineOnAttributes = true; using (XmlWriter writer = XmlWriter.Create("C:\OrderDetails.xml", setti ngs)) { writer.WriteComment("Order Details of Velocidade Inc."); writer.WriteStartElement("OrderDetails"); writer.WriteStartElement("Order"); writer.WriteAttributeString("OrderID","O001"); writer.WriteElementString("ProductName", "Toys"); writer.WriteElementString("Price", "100"); writer.WriteEndElement(); writer.WriteStartElement("Order"); writer.WriteAttributeString("OrderID", "O002"); writer.WriteElementString("ProductName","Stationary"); writer.WriteElementString("Price", "30"); writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); } } Option 4 --> 4, static void Main(string[] args) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; settings.NewAttributes = true; using (XmlWriter writer = XmlWriter.Create(@"C:\\OrderDetails.xml", set tings)) { writer.WriteComment("Order Details of Velocidade Inc."); writer.WriteStartElementNode("OrderDetails"); writer.WriteStartElementNode("Order"); writer.WriteAttributeString("OrderID","O001"); writer.WriteElementString("ProductName", "Toys"); writer.WriteElementString("Price", "100"); writer.WriteEndElement(); writer.WriteStartElement("Order"); writer.WriteAttributeString("OrderID", "O002"); writer.WriteElementString("ProductName","Stationary"); writer.WriteElementString("Price", "30"); writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); } }

Solution --> 1 Question --> You are creating an application in which you need to read an XML do cument, books.xml, and display the content of the document to the reader. Which of the following code snippets will you use to read the document? Option 1 --> 1, static void Main(string[] args) { XmlReader reader = null; try { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; reader = XmlReader.Create("C:\\books.xml", settings); while (reader.Read()) { reader.MoveToElement(); Console.WriteLine("XmlReader Properties Test"); Console.WriteLine("==================="); Console.WriteLine("Name:" + reader.Name); Console.WriteLine("Base URI:" + reader.BaseURI); Console.WriteLine("Local Name:" + reader.LocalName); Console.WriteLine("Attribute Count:" + reader.AttributeCount.ToSt ring()); Console.WriteLine("Depth:" + reader.Depth.ToString()); Console.WriteLine("Node Type:" + reader.NodeType.ToString()); Console.WriteLine("Data:" + reader.Value.ToString()); } Console.ReadLine(); } finally { if (reader != null) reader.Close(); } } Option 2 --> 2, static void Main(string[] args) { XmlReader reader = null; try { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; reader = XmlReader.Create("C:\\books.xml", settings); while (reader.Read()) { reader.MoveToElement(); Console.WriteLine("XmlReader Properties Test"); Console.WriteLine("==================="); Console.WriteLine("Name:" + reader.Name); Console.WriteLine("Base URI:" + reader.BaseURI); Console.WriteLine("Local Name:" + reader.LocalName); Console.WriteLine("Attribute Count:" + reader.AttributeCount.ToSt ring()); Console.WriteLine("Depth:" + reader.Depth.ToString()); Console.WriteLine("Node Type:" + reader.Node.ToString());

Console.WriteLine("Data:" + reader.Value.ToString()); } Console.ReadLine(); } finally { if (reader != null) reader.Close(); } } Option 3 --> 3, static void Main(string[] args) { XmlReader reader = null; try { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; reader = XmlReader.Create("C:\\books.xml", settings); while (reader.Read()) { reader.MoveToElement(); Console.WriteLine("XmlReader Properties Test"); Console.WriteLine("==================="); Console.WriteLine("Name:" + reader.Name); Console.WriteLine("Base URI:" + reader.BaseURI); Console.WriteLine("Local Name:" + reader.LocalName); Console.WriteLine("Attribute Count:" + reader.AttributeCount.ToSt ring()); Console.WriteLine("Depth:" + reader.Depth.ToString()); Console.WriteLine("Node Type:" + reader.Node.ConvertType.ToString ()); Console.WriteLine("Data:" + reader.Value.ToString()); } Console.ReadLine(); } finally { if (reader != null) reader.Close(); } } Option 4 --> 4, static void Main(string[] args) { XmlReader reader = null; try { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; reader = XmlReader.CreateDocument("C:\\books.xml", settings); while (reader.Read()) { reader.MoveToElement(); Console.WriteLine("XmlReader Properties Test"); Console.WriteLine("==================="); Console.WriteLine("Name:" + reader.Name); Console.WriteLine("Base URI:" + reader.BaseURI);

Console.WriteLine("Local Name:" + reader.LocalName); Console.WriteLine("Attribute Count:" + reader.AttributeCount.ToSt ring()); Console.WriteLine("Depth:" + reader.Depth.ToString()); Console.WriteLine("Node Type:" + reader.NodeType.ToString()); Console.WriteLine("Data:" + reader.Value.ToString()); } Console.ReadLine(); } finally { if (reader != null) reader.Close(); } } Solution --> 1 Question --> You need to create a program that validates the products.xml file a gainst the products.xsd file. Which of the following code snippets enables you t o do so? Option 1 --> 1, namespace validatingXmlDocument class Program { static void Main(string[] args) { XmlTextReader reader = new XmlTextReader("C:\\products.xml"); XmlValidatingReader validatingReader = new XmlValidatingReader(reade r); validatingReader.ValidationType = ValidationType.Schema; validatingReader.ValidationEventHandler +=new ValidationEventHandler (ValidationHandler); while(validatingReader.Read()); Console.WriteLine("Validation finished"); } public static void ValidationHandler(Object sender, ValidationEventArgs args) { Console.WriteLine("Validation Error"); Console.WriteLine("\tSeverity:{0}", sender.Severity); Console.WriteLine("\tMessage :{0}", sender.Message); Console.ReadLine(); } } } { Option 2 --> 2, namespace validatingXmlDocument class Program { static void Main(string[] args) { XmlTextReader reader = new XmlTextReader("C:\products.xml"); XmlValidatingReader validatingReader = new XmlValidatingReader(reade r); validatingReader.ValidationType = ValidationType.Schema; validatingReader.ValidationEventHandler +=new ValidationEventHandler (ValidationHandler); while(validatingReader.Read()); Console.WriteLine("Validation finished"); } public static void ValidationHandler(Object sender, ValidationEventArgs {

args) { Console.WriteLine("Validation Error"); Console.WriteLine("\tSeverity:{0}", args.Severity); Console.WriteLine("\tMessage :{0}", args.Message); Console.ReadLine(); } } } Option 3 --> 3, namespace validatingXmlDocument class Program { static void Main(string[] args) { XmlTextReader reader = new XmlTextReader("C:\\products.xml"); XmlValidatingReader validatingReader = new XmlValidatingReader(reade r); validatingReader.ValidationType = ValidationType.Schema; validatingReader.ValidationEventHandler +=new ValidationEventHandler (ValidationHandler); while(validatingReader.Read()); Console.WriteLine("Validation finished"); } public static void ValidationHandler(Object sender, ValidationEventArgs args) { Console.WriteLine("Validation Error"); Console.WriteLine("\tSeverity:{0}", args.Severity); Console.WriteLine("\tMessage :{0}", args.Message); Console.ReadLine(); } } } { Option 4 --> 4, namespace validatingXmlDocument class Program { static void Main(string[] args) { XmlTextReader reader = new XmlTextReader("C:\\products.xml"); XmlValidatingReader validatingReader = new XmlValidatingReader(reade r); validatingReader.ValidationType = ValidationType.Schema; validatingReader.ValidationEventHandler +=new ValidationEventHandler (ValidationHandler); while(validatingReader.Reading()); Console.WriteLine("Validation finished"); } public static void ValidationHandler(Object sender, ValidationEventArgs args) { Console.WriteLine("Validation Error"); Console.WriteLine("\tSeverity:{0}", args.Severity); Console.WriteLine("\tMessage :{0}", args.Message); Console.ReadLine(); } } } { Solution --> 3 Question --> Predict the output of the following code snippet:

XmlDocument doc = new XmlDocument(); doc.LoadXml(("<BOOKDETAILS><BOOK BOOKID='B001'><BOOKNAME>Angels and Demons</BOOK NAME><AUTHOR>Dan Brown</AUTHOR></BOOK><BOOK BOOKID='B002'><BOOKNAME>Dr. Jekyll a nd Mr. Hyde</BOOKNAME><AUTHOR>Robert Louis Stevenson</AUTHOR></BOOK></BOOKDETAIL S>")); XmlNode node = doc.DocumentElement.FirstChild; node.RemoveChild(node.FirstChild); doc.Save(Console.Out); Console.ReadLine(); Option 1 --> 1, The first BOOK BOOKID element is removed. Option 2 --> 2, The code will not delete any element. Option 3 --> 3, The BOOKNAME element of the first BOOK element is removed. Option 4 --> 4, The code will give an error. Solution --> 3 Question --> You have created a table named Students, by using the following SQL queries: CREATE TABLE Students(Marks xml) INSERT Students VALUES('<Marks><English>85</English><Math>100</Math></Marks>') INSERT Students VALUES('<Marks><English>83</English><Math>96</Math></Marks>') Now, you need to create a program that retrieves the records stored in Students table and display them in a DataGrid control. Which of the following code snippe ts enables you to perform the desired task. Option 1 --> 1,private void cmdRetrieve_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); //connectionString is the connection string using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = connectionString; conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM Students"; using (SqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { SqlXml student = rdr.GetSqlXml(0); if (!student.IsNull) { ds.ReadXml(student.Create()); } } } } dataGrid1.DataSource = ds; }} } Option 2 --> 2,private void cmdRetrieve_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); //connectionString is the connection string using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = connectionString; conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM Students"; using (SqlDataReader rdr = cmd.ExecuteReader())

{ while (rdr.Read()) { SqlXml student = rdr.GetSqlXml(0); if (!student.IsNull) { ds.ReadXml(student.Cre ateReader()); } } } } dataGrid1.DataSource = ds; } } } Option 3 --> 3, private void cmdRetrieve_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); //connectionString is the connection string using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = connectionString; conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM Students"; using (SqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Readto End()) { SqlXml student = rdr.GetSqlXml(0); if (!student.IsNull) { ds.ReadXml(student.CreateR eader()); } } } } dataGrid1.DataSource = ds;}} } Option 4 --> 4, private void cmdRetrieve_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); //connectionString is the connection string using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = connectionString; conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM Students"; using (SqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) {SqlXml student = rdr.GetSqlXml(0); if (!student.IsNull) { ds.ReadXml(student.Cr eateReader());}}}} dataGrid1.DataSource = student;}}} Solution --> 2 Question --> 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(); } }

Identify the output of the preceding code. Option 1 --> 1, The output of the given code is: Display in derived class. Option 2 --> 2, The output of the given code is: Display in base class. Display in derived class. Option 3 --> 3, The output of the given code is: Display in derived class. Display in base class. Option 4 --> 4, The output of the given code is: Display in base class. Solution --> 2 Question --> While writing a Java code you need to declare an integer array that can hold 10 elements. Which of the following options will you use to accomplish the desired task? Option 1 --> 1, int[] a = new int[10]; Option 2 --> 2, int[10] a = new int[]; Option 3 --> 3, int[] a = new int[9]; Option 4 --> 4, int[9] a = new int[]; Solution --> 1 Question --> Which of the following options refers to method overloading in Java ? Option 1 --> 1, 2. The functions 3. The functions 4. The functions Option 2 --> 2, 2. The functions 3. The functions 4. The functions 1. The functions should have same name. can have different return type. should have different argument list. should be defined in the same class. 1. The functions should have same name. can have different return type. should have different argument list. can be defined in the different class.

Option 3 --> 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. Option 4 --> 4, 2. The functions 3. The functions 4. The functions Solution --> 1 Question --> You have created a base class STUDENT, and a derived class STUD_DET AILS in a java program. Now, you want to use the STUD_DETAILS class to invoke th e constructor of the STUDENT class. Identify the correct keyword that you should use to accomplish the desired task? Option 1 --> 1, super Option 2 --> 2, abstract Option 3 --> 3, static Option 4 --> 4, virtual Solution --> 1 Question --> 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"; Identify the correct statement to compare the two given string values in the pr eceding statements. Option 1 --> 1, System.out.println(s1=s2); Option 2 --> 2, System.out.println(s1.equals(s2)); Option 3 --> 3, System.out.println(s1==s2); Option 4 --> 4, System.out.println(s1.equal(s2)); Solution --> 2 Question --> Sam has been assigned a task to create a Java application to create a heterogeneous collection, in which all the items have a common ancestor class . Identify the correct code that Sam should use to accomplish the desired task. Option 1 --> 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 Integer(1); obj[2]=new Float(1.0f); 1. The functions should have same name. can have different return type. can have same argument list. can be defined in the different class.

} } Option 2 --> 2, public class poly_demo { public static void main(String[] args) { Date[] obj = new Date[2]; obj[0] = new Date(23,4,2009); obj[1] = new Date(23,5,2009); } } Option 3 --> 3, public class poly_demo { public static void main(String[] args) { Date[] obj = new Date[2]; obj[0] = new Object(23,4,2009); obj[1] = new Date(23,5,2009); } } Option 4 --> 4, public class poly_demo { public static void main(String[] args) { Object [] obj=new Object[3]; obj[0]=new Object(1.1d); obj[1]=new Object(1); obj[2]=new Object(1.0f); } } Solution --> 1 Question --> 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. T he sum method should use enhance for loop such that it displays the sum of the values given in the array. Identify the correct code that Sam sho

uld use to accomplish the desired task. Option 1 --> 1, int sum(int[] a) { int res = 0; for (int i : a) res += i; System.out.println(res); return res; } Option 2 --> 2, int sum(int[] a) { int res = 0; for (int i : res) res += i; System.out.println(res); return res; } Option 3 --> 3, int sum(int[] a) { int res = 0; for (int i : a) res += a; System.out.println(res); return res; } Option 4 --> 4, int sum(int[] a) { int res = 0; for (int i : res) res += a; System.out.println(res); return res; } Solution --> 1 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; } } Identify the correct output of the preceding code snippet. Option 1 --> 1, It will generate a compile time error stating b is not an abstr act class and does not override the sum method. Option 2 --> 2, It will throw a runtime exception. Option 3 --> 3, It will generate a compile time error stating b class inherit c lass a. Option 4 --> 4, It will compile and execute successfully. Solution --> 1 Question --> 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 the assertion for the preceding code. Id entify which of the following commands will Sam use to achieve this task. Option 1 --> 1, java demo Option 2 --> 2, java demo file Option 3 --> 3, java -ea demo Option 4 --> 4, java -ea test file1 Solution --> 3 Question --> 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 th e preceding enum and gives the following output: SUNDAY 1 MONDAY 2 TUESDAY 3 Identify the correct code that Sam should use to accomplish the desired task. Option 1 --> 1, class demo1 { Days num; public static void main(String[] args) { demo1 obj = new demo1(); for(Days dy: Days.values()) System.out.println(dy + " " + dy.getdays()); } } Option 2 --> 2, class demo1 { Days num; public static void main(String[] args) { demo1 obj = new demo1(); obj.num = Days.SUNDAY; demo1 obj1 = new demo1(); for(Days dy: Days.values()) System.out.println(obj1.num.getdays()); } } Option 3 --> 3, class demo1 { Days num; public static void main(String[] args) { demo1 obj = new demo1(); obj.num = Days.SUNDAY; System.out.println(obj.num.getdays()); demo1 obj1 = new demo1(); obj.num = Days.MONDAY; System.out.println(obj1.num.getdays()); demo1 obj2 = new demo1(); obj.num = Days.TUESDAY; System.out.println(obj.num.getdays()); } } Option 4 --> 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()); } } Solution --> 1

Question --> Which of the following class is the base class used for the uncheck ed exceptions that arise as a result of program bugs? Option 1 --> 1, RuntimeException Option 2 --> 2, VirtualMachineError Option 3 --> 3, IOException Option 4 --> 4, AssertionError Solution --> 1 Question --> Which of the following keywords makes a variable accessible from an y instance of the class? Option 1 --> 1, static Option 2 --> 2, final Option 3 --> 3, abstract Option 4 --> 4, protected Solution --> 1 Question --> Which of the following keywords enable the class to use the methods of an interface? Option 1 --> 1, static Option 2 --> 2, extends Option 3 --> 3, implements Option 4 --> 4, abstract Solution --> 3 Question --> Sam is creating a Java application. He wants to create a method tha t should be invoked without creating an instance of the object at the runtime. Identify the keyword to be used to satisfy the preceding scenario needed in main method? Option 1 --> 1, final Option 2 --> 2, abstract Option 3 --> 3, static Option 4 --> 4, public Solution --> 3

Question --> The __________ clause defines a block of code that always executes, regardless of whether an exception was caught. Option 1 --> 1, finally Option 2 --> 2, final Option 3 --> 3, throws Option 4 --> 4, throw Solution --> 1 Question --> Which of the following methods returns the system property object? Option 1 --> 1, setProperties() Option 2 --> 2, getProperties() Option 3 --> 3, getProperty() Option 4 --> 4, setProperty() Solution --> 2 Question --> Which of the following keywords is used to test the programmer's as sumptions during development without writing exception handlers for an exception ? Option 1 --> 1, assert Option 2 --> 2, finally Option 3 --> 3, throw Option 4 --> 4, throws Solution --> 1 Question --> If the superclass method throws an IOException, then which of the f ollowing statement is correct in reference to the exceptions that can be thrown by the overriding method? Option 1 --> 1, It will not throw an exception of its own super class, such as Exception. Option 2 --> 2, It will not allow you to declare any other exception in the thr ows clause. Option 3 --> 3, It will not throw FileNotFoundException exception. Option 4 --> 4, It will not throw an IllegalArgumentException exception. Solution --> 1 Question --> 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 co nnect 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 ServerTimedOutException. Identify the correct code snippet that Sam should use to accomplish the desired task. Option 1 --> 1, public void MyException(String servname) throws ServerTimedOutE xception { boolean success; int p = 80; success = open(servname,p); if(! success) { throw new ServerTimedOutException("Not able to connect",p); } } Option 2 --> 2, public void MyException(String servname) throw ServerTimedOutEx ception { boolean success; int p = 80; success = open(servname,p); if(! success) { throws new ServerTimedOutException("Not able to connect",p); } } Option 3 --> 3, public void MyException(String servname) throws ServerTimedOutE xception { boolean success; int p = 80; success = open(servname,p); if(! success) { throw ServerTimedOutException("Not able to connect",p); } } Option 4 --> 4, public void MyException(String servname) throw ServerTimedOutEx ception

{ boolean success; int p = 80; success = open(servname,p); if(! success) { throws ServerTimedOutException("Not able to connect",p); } } Solution --> 1 Question --> Which of the following exceptions is the result of a divide-by-zero operation for integers? Option 1 --> 1, NumberFormatException Option 2 --> 2, ArithmeticException Option 3 --> 3, IllegalArgumentException Option 4 --> 4, NullPointerException Solution --> 2 Question --> 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. Which of the following is correct in reference to the preceding statements? Option 1 --> 1, Both statement A and B are true. Option 2 --> 2, Both statement A and B are false. Option 3 --> 3, Statement A is true, and statement B is false. Option 4 --> 4, Statement A is false, and statement B is true. Solution --> 2 Question --> 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 str ings. Identify the correct code that Anthony should use to accept and print the comman d-line arguments. Option 1 --> 1, public class command { public static void main(String[] args) { for(int i=0;i<args.length;i++) System.out.println("args["+i+"] is " +args[i]); }

Option 2 --> 2, public class command { public static void main(String[] args) { while((args=in.readLine())!=null) System.out.println("args["+i+"] is " +args[i]); } } Option 3 --> 3, public class command { public static void main(String[] args) { for(int i=0;i<args.length;i++) InputStreamReader i = new InputStreamReader(args); System.out.println("args["+i+"] is " +args[i]); } } Option 4 --> 4, public class command { public static void main(String[] args) { InputStreamReader i = new InputStreamReader(args); while((args=in.readLine())!=null) System.out.println("args["+i+"] is " +args[i]); } } Solution --> 1 Question --> 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); } } } Identify the output of the preceding code. Option 1 --> 1, It generates a runtime error. Option 2 --> 2, It generates a compile time error. Option 3 --> 3, It retrieves the property value. Option 4 --> 4, It retrieves the property name and value pair. Solution --> 4 Question --> 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(); } } Identify the output of the preceding code. Option 1 --> 1, It will generate a NullPointer Exception. Option 2 --> 2, It will generate StackOverFlowError. Option 3 --> 3, It will generate a IllegalArgumentException. Option 4 --> 4, It will generate OutOfMemoryError. Solution --> 1 Question --> 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 unche cked exceptions that might arise as a result of program bug. Which of the following is correct in reference to the preceding statements? Option 1 --> 1, Both statement A and B are true. Option 2 --> 2, Both statement A and B are false. Option 3 --> 3, Statement A is true, and statement B is false. Option 4 --> 4, Statement A is false, and statement B is true. Solution --> 1 Question --> 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); } } } Identify the output of the preceding code. Option 1 --> 1, It will give the following output: 1 2 3 4 5 Option 2 --> 2, It will execute successfully but no output will be generated. Option 3 --> 3, It will generate the following output: 5 4 3 2

1 Option 4 --> 4, It will generate a runtime error. Solution --> 2 Question --> Which of the following options is correct in reference to the Syste m.err variable of the java.lang.System class? Option 1 --> 1, It is an InputStream object that refers (initially) to the user 's keyboard. Option 2 --> 2, It is a PrintStream object that refers (initially) to the user' s keyboard. Option 3 --> 3, It is a PrintStream object that refers (initially) to the termi nal window that launched the Java technology application. Option 4 --> 4, It is an InputStream object that refers (initially) to the term inal window that launched the Java technology application. Solution --> 3 Question --> 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 standar d input. Identify the correct code snippet that Sam should use to accomplish the desired task. Option 1 --> 1, InputStreamReader i = new InputStreamReader(System.in); BufferedReader in = new BufferedReader(i); Option 2 --> 2, InputReader i = new InputReader(System.in); BufferedReader in = new BufferedReader(i); Option 3 --> 3, BufferedReader in = new BufferedReader(System.in); InputStreamReader i = new InputStreamReader(in); Option 4 --> 4, BufferedReader in = new BufferedReader(System.in); InputReader i = new InputReader(System.i); Solution --> 1 Question --> 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 c ollection in which duplicate values are permitted. Identify the correct code sni ppet that Sam should use to accomplish the desired task. Option 1 --> 1, List l = new ArrayList(); l.add("ONE"); l.add(new Integer(4)); l.add("ONE"); Option 2 --> 2, Set l = new HashSet(); l.add("ONE"); l.add(new Integer(4)); l.add("ONE"); Option 3 --> 3, List l = new List(); l.add("ONE"); l.add(new Integer(4)); l.add("ONE"); Option 4 --> 4, Set l = new Set(); l.add("ONE"); l.add(new Integer(4)); l.add("ONE"); Solution --> 1 Question --> While building a Java GUI application, you need to create an item w ithin a menu. Which of the following listener will you implement that can be ass ociated with the MenuItem component? Option 1 --> 1, ActionListener Option 2 --> 2, AdjustmentListerner Option 3 --> 3, ComponentListener Option 4 --> 4, ItemListener Solution --> 1 Question --> Which of the following layout managers is the default layout manage r for the Frame and Dialog classes? Option 1 --> 1, FlowLayout Option 2 --> 2, BorderLayout

Option 3 --> 3, CardLayout Option 4 --> 4, GridLayout Solution --> 2 Question --> The _______ method tells the frame to set a size that neatly enclos es the components that it contains. Option 1 --> 1, setlayout() Option 2 --> 2, pack() Option 3 --> 3, add() Option 4 --> 4, setVisible() Solution --> 2 Question --> Which of the following AWT components is a top-level window with a title and a border? Option 1 --> 1, Dialog Option 2 --> 2, Frame Option 3 --> 3, Panel Option 4 --> 4, Canvas Solution --> 1 Question --> Which of the following methods belongs to the ContainerListener int erface? Option 1 --> 1, componentAdded() Option 2 --> 2, componentMoved() Option 3 --> 3, componentHidden() Option 4 --> 4, componentShown() Solution --> 1 Question --> The Container class is an abstract subclass of ____________. Option 1 --> 1, Component Option 2 --> 2, MenuComponent Option 3 --> 3, Insets Option 4 --> 4, Event

Solution --> 1 Question --> 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); } public static void main(String args[]) { jfc_demo obj = new jfc_demo(); obj.disp(); } } Sam has been assigned a task to convert the given code to JFC technology. Identify the correct steps and syntax that Sam should use to accomplish the desi red task. Option 1 --> 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.getContentPane().add(Component) Option 2 --> 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.getContentPane().add(Component) Option 3 --> 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(Component).getContentPane() Option 4 --> 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(Component).getContentPane() Solution --> 1

You might also like