Sei sulla pagina 1di 55

If there are images in this attachment, they will not be displayed.

Download the original attachment

ADO.NET JAVA
The __________ principle states that while designing an interactive product, the interfaces should have similar operations and should use similar elements for similar tasks. 2, Consistency Which of the following principles of interactive design states that it is important to keep the users informed about their actions? 2, Feedback Which of the following options is a lifecycle model that is selected by designers when the project is small and they want to use a flexible lifecycle model? 2, Star model _________ requirements capture the system goals with respect to effectiveness, efficiency, safety, utility, learnability, and memorability of a product. 3, Usability Which of the following data gathering techniques involves having a conversation with the participants where the researcher orally solicits responses? 3, Interviews NewTech Book Store has launched its website to sell books to its customers around the world. The website displays thumbnails of books being sold instead of displaying the names of books in text. Which of the following cognition elements has been applied by NewTech in their website? 2, Attention NewTech Book Store has launched its website to sell books to its registered users all over the world. The website provides a link to register new users. When a new user clicks the link to register

himself/herself, the New User Registration page opens in a separate window. This page is then used to enter and submit the essential user details. After the site was launched, it was observed that the feature worked fine in Windows XP Operating System (OS). However, when the same link is clicked in Mac OS or Linux OS, the page is not displayed as the new window does not get opened. In the preceding scenario, analyze and provide the requirements that have not been considered by NewTech while developing its website? 4, Non-functional requirements A team of engineers at MobiDick, Inc. has developed a mobile phone. Before launching it in the market, they decided to test the usability and acceptance of the phone on a sample population. As per the feedback received, the team got to know that the phone is difficult to use and its features cannot be easily apprehended. Also, the user interface of the phone is very complicated. Because of this, the team will now have to redesign the mobile phone. Analyze the situation and suggest which of the following implementations could have avoided this rework by the team? 3, The team should have developed the conceptual model before physical model. Which of the following options is NOT a factor that is to be considered for selecting the appropriate prototyping technique? 4, Location and accessibility of stakeholders Which of the following is NOT a correct guideline to be followed while designing a GUI for touch screens? 3, The size of the push button in a touch screen should be less than 2x2 cm and they should be spread out on the Jim is creating a website for an organization. He needs to ensure that the links for Site Map, Contact Us, and Home should be displayed on top of all the pages of the website. Provide the strategy that Jim should adopt to display the links. 2, Jim should create global links. Jim has been working upon a website of his organization to make sure that it gets displayed on handheld devices as well. After the launch it

was observed that maximum percentage of users accessing the website over their mobile phones had to scroll down a number of screens before reaching the links pointing to relevant content. Jim's manager has now asked him to modify this new version of the website such that the users are able to find relevant content easily. Provide the correct Web viewing method that Jim should implement in the current scenario. 3, Jim can use the filtered display A team of software engineers at NewTech Labs needs to develop a console-based operating system. The operating system should respond to the commands typed by the users in the console window. Before starting with the development, the manager wants a conceptual model to be developed by the team. You need to identify, from the following options, the type of conceptual model that should be developed for the operating system being developed. 1, The conceptual model should be instruction-based. Alice needs to develop a conceptual model for a car game being developed by her team. The game requires the players to select race tracks, cars, and car specifications. The players can also select whether the gear mode for their selected car should be automatic or manual. In addition, the players can also change the color of their cars. Identify the model that best suits the game. In addition, provide the reason because of which Alice should develop that model. 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. While giving a lecture on principles of interactive design, John informed the participants that they could reduce the number of errors in an application by making the administrator-related features as inactive when a normal user works on the application. He further informed the participants that this is an implementation of the visibility principle of interactive design. Analyze whether the knowledge imparted by John regarding the design principle is correct. If not, provide the correct information that John should have given to the participants? 4, No. The principle that reflects the knowledge imparted by John is the Constraints principle. Joanna is creating an application that displays the current time to the users. In addition to displaying the time, she wants to give the users the flexibility of viewing either an analog clock or a digital clock. However,

she needs to ensure that the time displayed in either of the interface is always correct. She has decided to use Vector graphics to implement this functionality in the application. Analyze if Joanna will be able to accomplish the requirement. If not, provide from the following options, the feature that will enable her to implement the same. 2, No. The required functionality can be implemented by using Lookless controls in the application. You are creating a Web application that displays various wildlife images to the users. One page may display 4 to 5 images to the users. To avoid overlapping of the images on the page, you have decided to place them by specifying x and y coordinates. Which of the following layouts will you use to accomplish the same? 4, Canvas layout Jenny is required to conduct an interview for a number of participants. She needs to gather data regarding personal details and academic qualifications of each of the participants. She has a set of questions which she will be asking in a particular sequence from each participant. Identify the type ofinterview that Jenny is implementing in the current scenario. 1, Structured interview Which of the following model is used when the user wants to search for particular information or wants to discuss an issue? 2, Conversation-based model The _________ prototyping technique describes each action sequentially. 1, storyboard _________ screen controls can be used to set attributes, properties, or values. 1, Selection In _______ layout, controls are placed in the form of x and y coordinates. 2, canvas Which of the following options is NOT a direct observation technique?

4, Interaction logging Which of the following keywords is used to resolve ambiguity between instance variables and parameters? In addition, it is also used to pass the current object as a parameter to another method? 2, this Which of the following files contains the code for the Java Virtual Machine (JVM)? 2, .class file Which of the following keyword declares that the attribute is accessible only to the methods within the same class? 2, private Which of the following options is used to declare and initialize a character variable? 4, char ch = 'S'; You have written the following code to create a java program: class Hi { public void japp() { System.out.println("Java Application"); } } class Hello { public void disp() {

System.out.println("Display"); } } public class MyApp { public static void main(String[] args) { Hello obj = new Hello(); Hi obj1 = new Hi(); obj.disp(); obj1.japp(); } } Now, you need to save the preceding code. Which of the following name will you use to save the preceding code as a java file? 3, MyApp.java Which of the following refers to the methodology of hiding certain elements of the implementation of a class but providing a public interface for the client software? 3, Encapsulation 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? 2, It will generate compile time error. You need to declare a variable in a java class. Which of the following identifiers will you use to accomplish the desired task? 1, thisOne

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? 4, -d Identify the reference variable in the MyApp class in the following code snippet: class Hello { privateint d=1; privateint 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) { inti,j; Hello obj = new Hello(5,10); } } 1, The variable obj is a reference variable in the MyApp class. Consider the following code:

class Example { public void display() { System.out.println("Display in base class."); } } public class example1 extends Example{ public void display() { super.display(); System.out.println("Display in derived class."); } public static void main(String[] args) { example1 s = new example1(); s.display(); } } Identify the output of the preceding code. 2, The output of the given code is: 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? 1, int[] a = new int[10]; Which of the following options refers to method overloading in Java? 1, 1. The functions should have same name. 2. The functions can have different return type.

3. The functions should have different argument list. 4. The functions should be defined in the same class. You have created a base class STUDENT, and a derived class STUD_DETAILS in a java program. Now, you want to use the STUD_DETAILS class to invoke the constructor of the STUDENT class. Identify the correct keyword that you should use to accomplish the desired task? 1, super Consider the following code snippet that contains two string s1 and s2, which contains the value NIIT and Niit respectively: String s1="NIIT"; String s2="Niit"; Identify the correct statement to compare the two given string values in the preceding statements. 2, System.out.println(s1.equals(s2)); 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. 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); }

} 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_demoobj= new enh_demo(); obj.sum(i); } } Sam has been assigned a task to write the method definition of the sum method. The sum method should use enhance for loop such that it displays the sum of the values given in the array. Identify the correct code that Sam should use to accomplish the desired task. 1, intsum(int[] a) { int res = 0; for (int i : a) res += i; System.out.println(res);

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

} } Identify the output of the preceding code. 1, It will generate a runtime error. Consider the following code: class acc{ int a; privateint b; voidsetvalue(int i){ b=i; } intgetvalue(){ return b; } } public class acc_demo { public static void main(String [] args){ accobj = new acc(); obj.a =11; obj.setvalue(33); System.out.println("Value of a:" + obj.a); System.out.println("Value of b using:"+obj.getvalue());

} } Identify the output of the preceding code. 2, It will display the values assigned to a and b. Which of the following options is used to compare an object to a specified class type? 1, instanceof operator After creating an array, how can you use the same reference variable to refer to an entirely new array? 1, int[] myArray = new int[6]; Consider the following java program: public class branching { public static void main(String[] args) { int i=0; int j=0; int k=0; if(i<3) { if(j<3) { if(k<3) { System.out.println("BRANCHING STATEMENT");

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

The two operands a and b are assigned the values 128 and 1 respectively. What will be the result if left shift operation is performed on the given operands a and b? 1, 256 You have created a method add() with in a class STUDENT. You want that the add() should only be accessible to the classes that belongs to the same package as that of a STUDENT class. Which of the following access modifiers will you use to accomplish the desired task? 3, default Which of the following options cannot have a polymorphic behavior? 3, Object Consider the following code: class demo { privateint x=1; public void setValue() { int x=4, y=5; this.x = x+y; setNewValue(10); } public void setNewValue(int x) { int y=8; this.x = x+y; System.out.println(x); System.out.println(y);

} } public class var_sc_demo { public static void main(String[] args) { demoobj = new demo(); obj.setValue(); } } Identify the output of the preceding code. 1, The output of the given code is: 10 8 Consider the following code: importjava.lang.*; class copy { char[] a={'N','I','I','T'}; char[] b = {'C','o','u','r','s','e'}; public void copyArr() { ***

}} public class arr_cpy { public static void main(String[] args) { copyobj = new copy(); obj.copyArr(); } } Sam has been assigned a task to update the preceding code such that it copies the value of the array a to array b using the arraycopy function. In addition, he has to print the resultant. Identify the correct code snippet that Sam should use to accomplish the desired result. 1, System.arraycopy(a,0,b,0,a.length); Which of the following options is correct in reference to the final keyword? 4, The blank final instance variable must be assigned in a constructor. Consider the following code snippet: public class a { staticint i=0; public static void main(String[] a) {} } How many copies of the variable i would be created, if you have created four objects of class a? 1, One

If you apply ____ keyword to a class, the class cannot be subclassed. 1, final Which of the following formatting codes in java uses scientific notations? 1, %g Consider the following code: importjava.util.*; public class itr_demo { public static void main(String[] args) { HashSet s=getValue(); Iterator iter=s.iterator(); while (iter.hasNext()) { iter.next(); System.out.println(s); } } staticHashSetgetValue() { HashSet<String>arrList=new HashSet<String>(); arrList.add("1"); arrList.add("2");

arrList.add("3"); arrList.add("4"); returnarrList; } } Identify the output of the given code. 1, [3, 2, 4, 1] [3, 2, 4, 1] [3, 2, 4, 1] [3, 2, 4, 1] Consider the following code snippet: abstract class a { public abstract double sum(); public abstract double mul(); } public class b extends a { double a =40; double b=20; double c=0; public double mul() {

c=b*a; System.out.println(c); return c; } } Identify the correct output of the preceding code snippet. 1, It will generate a compile time error stating b is not an abstract class and does not override the sum method. 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. Identify which of the following commands will Sam use to achieve this task. 3, java -ea demo Which of the following class is the base class used for the unchecked exceptions that arise as a result of program bugs? 1, RuntimeException Which of the following keywords makes a variable accessible from any instance of the class? 1, static

Which of the following keywords enable the class to use the methods of an interface? 3, implements Sam is creating a Java application. He wants to create a method that should be invoked without creating an instance of the object at the runtime. Identify the keyword to be used to satisfy the preceding scenario needed in main method? 3, static The __________ clause defines a block of code that always executes, regardless of whether an exception was caught. 1, finally Which of the following methods returns the system property object? 2, getProperties() Which of the following keywords is used to test the programmer's assumptions during development without writing exception handlers for an exception? 1, assert If the superclass method throws an IOException, then which of the following statement is correct in reference to the exceptions that can be thrown by the overriding method? 1, It will not throw an exception of its own super class, such as Exception. Consider the following code snippet: public class ServerTimedOutException extends Exception { privateint port; publicServerTimedOutException(String message, int port)

{ super(message); this.port; } publicintgetport() { return port; } } Sam has written a client-server Java program. In the client code, he tries to connect to the server and expect the server to respond within five seconds. Now he wants that if the server does not respond within the specified time, the code should throw a user defined exception ServerTimedOutException. Identify the correct code snippet that Sam should use to accomplish the desired task. 1, public void MyException(String servname) throws ServerTimedOutException Which of the following exceptions is the result of a divide-by-zero operation for integers? 2, ArithmeticException 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? 2, Both statement A and B are false.

Consider the following code: importjava.util.Properties; importjava.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. 4, It retrieves the property name and value pair. Consider the following code: class EMP { String empName; public void display()

{ System.out.println(empName); } } public class err_cat { EMP e[]; publicerr_cat() { for(int i=0;i!= 2;i++) { e[i] = new EMP(); } e[0].empName="Hello"; } public static void main(String args[]) { err_catempObj; empObj = new err_cat(); } } Identify the output of the preceding code. 1, It will generate a NullPointer Exception. Consider the following statements: Statement A: The Error class is the base class for unchecked errors.

Statement B: The RuntimeException class is the base class that is used for unchecked exceptions that might arise as a result of program bug. Which of the following is correct in reference to the preceding statements? 1, Both statement A and B are true. Consider the following code: public class asser_demo { staticint n = 1; staticintgetnum() { 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. 2, It will execute successfully but no output will be generated. Which of the following options is correct in reference to the System.err variable of the java.lang.System class? 3, It is a PrintStream object that refers (initially) to the terminal window that launched the Java technology application. 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 standard input. Identify the correct code snippet that Sam should use to accomplish the desired task. 1, InputStreamReader i = new InputStreamReader(System.in); BufferedReader in = new BufferedReader(i); Consider the following code snippet: importjava.util.*; public class demo {

public static void main(String[] args) { *** System.out.println(l); } } Sam has been assigned a task to create a Java application to create an ordered collection in which duplicate values are permitted. Identify the correct code snippet that Sam should use to accomplish the desired task. 1, List l = new ArrayList(); l.add("ONE"); l.add(new Integer(4)); l.add("ONE"); While building a Java GUI application, you need to create an item within a menu. Which of the following listener will you implement that can be associated with the MenuItem component? 1, ActionListener Which of the following layout managers is the default layout manager for the Frame and Dialog classes? 2, BorderLayout The _______ method tells the frame to set a size that neatly encloses the components that it contains. 2, pack() Which of the following AWT components is a top-level window with a title and a border? 1, Dialog

Which of the following methods belongs to the ContainerListener interface? 1, componentAdded() The Container class is an abstract subclass of ____________. 1, Component Consider the following code: import java.awt.*; public class jfc_demo { private Frame f; private Button b; publicjfc_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_demoobj = 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 desired task. 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) 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. 1, public class frm_demo { private Frame f;

publicfrm_demo(String title) { f=new Frame("Welcome"); } public void launch() { f.setSize(50,60); f.setBackground(Color.red); f.setVisible(true); } } While creating a Java GUI application, you want to obtain the reference of the object that has generated the event. Which of the following methods will you use to accomplish this task? 1, getSource() 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 alignment of the components? 1, FlowLayout Manager You need to implement a grid layout containing 5 rows and 2 columns. In addition, you need to ensure that the gaps between each column is 10 and the gap between each row is 15. Which of the following code snippet will you use to accomplish the desired task? 1,GridLayoutgl=new GridLayout(5, 2,10,15); Consider the following code snippet:

import java.awt.*; importjava.awt.event.*; public class demo implements MouseListener { private Frame f; privateTextField t; public demo() { f = new Frame("WELCOME"); t = new TextField(20); } *** } Sam has created a class which implements MouseListener interface. Identify the methods that should be defined within the preceding class. 2, mousePressed(MouseEvent) mouseReleased(MouseEvent) mouseEntered(MouseEvent) mouseExited(MouseEvent) mouseClicked(MouseEvent) Consider the following code snippet: import java.awt.*; public class LayoutExample { private Frame f;

private Button b1; private Button b2; publicLayoutExample() { 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[]) { LayoutExampleguiWindow = 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. 1, f.pack(); Which of the following is correct in reference to a panel in Java? 2, A panel must be placed into a window.

Which of the following is correct in reference to the FileOutputStream class? 1, The FileOutputStream constructor, overwrites the already existing output file. Sam has been assigned a task to create a TCP/IP client. Identify the correct code snippet to accomplish the desired task. 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(); } } 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. 4, It will display the following output: File found at the given location. Consider the following code: import java.io.*; public class strm_demo { public static void main(String[] args) throws IOException { try { FileReaderobj = 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 not exists in C drive. 3, It will throw a runtime exception. Consider the following code snippet: System.out.println("Enter the Designation:"); *** ReadString = bufferStream.readLine(); Sam has been assigned a task to modify the given code snippet such that it forces the write operation to clear any accumilated data on the output stream. Identify the correct method that Sam should use to accomplish the desired task. 1, System.out.flush(); Sam is creating a Java application. He has created an object of the Connection interface to establish a connection of the Java application with a database using the getConnection() method with a single parameter. Identify the correct syntax for a JDBC URL that Sam should pass as a parameter to the getConnection(). 1, <protocol>:<subprotocol>:<subname> Sam has created a Java application that allows to access information stored in a database "AUTH_DETAILS". Now, Sam has been assigned a task to create a code that modifies the state to CA where city is Oakland in the Authors table in the AUTH_DETAILS database using the

PreparedStatement object. Identify the correct code snippet that Sam should use to accomplish the desire task. 2, String str = "UPDATE Authors SET state= ? WHERE city= ? "; PreparedStatementps = con.prepareStatement(str); ps.setString(1, "CA"); ps.setString(2, "Oakland"); intrt=ps.executeUpdate(); Sam is creating a java program that implements stacks. He has to create 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 accomplish the desired task. 1, public synchronized char pop() { charch; while(buffer.size()==0) { try { this.wait(); }catch(InterruptedException e) { }

ch = buffer.remove(buffer.size()-1); return c; } 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.

3, It will not compile because the method run cannot have static keyword as a return type. 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 use to accomplish the desired task? 1, commit() While creating a TCP/IP server application, you need to register your service on port 5232. Which of the following code snippet will you use to accomplish the desired task? 1, ServerSocket s = new ServerSocket(5432); Which of the following packages is used to access Thread class? 1, java.lang Consider the following code: public class thread_demo extends Thread{ public static void main(String args[]) { for(int i=0;i<5;i++) newthread_demo().start(); } public void run() { System.out.println("Hello"); } } Analyze the preceding code and identify the correct output for the given code.

1, It will print Hello five times. While creating a thread in a Java application, you want to use a method that allows you to give other runnable threads a chance to execute. If other threads are runnable, the calling thread should be placed into the runnable pool and allows another runnable thread to run. Which of the following methods of the Thread class will help you in accomplishing the desired task? 1, Thread.yield() 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; databaseName=Library;user=user1;password=password#1234"); Statement stmt=con.createStatement(); ResultSetrs=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. 1, It retrieve information (author id, name, address, city, and state) about the authors who are living in the city where the city name begins with the letter "S". Which of the following methods is used to load the JDBC driver and registers it? 1, forName()

The _______ object allows you to pass runtime parameters to the SQL statements using the placeholders. 1, PreparedStatement Which of the following methods of ResultSetMetaData interface retrieves the title of a table column corresponding to the index passed as a parameter to the method? 1, getColumnLabel() Which of the following fields of the ResultSet interface specifies that the cursor of the ResultSet object is scrollable and it does not reflect changes in the data made by other users? 1, TYPE_SCROLL_INSENSITIVE Which of the following drivers is called the Type 1 driver? 1, JDBC-ODBC Bridge driver When the client requests a connection, the server opens the socket connection with the ________ method. 1, accept() The PipedReader class is a type of _______ stream. 4, Character Which of the following streams performs conversion on another stream? 3, Filter stream Which of the following classes contains the wait and notify methods? 1, java.lang.Object Which of the following is correct in reference to the getSQLState() method of the SQLException class? 1, It returns X/Open error code. W3C stands for ___________________. 3, World Wide Web Consortium

You want to retrieve data from a data source in a read-only and forwardonly mode. Which of the following components of a data provider will you use? 2, DataReader Which of the following parameters of the connection string is used to specify the name of a database? 4, Initial Catalog Which of the following namespaces would you include in your program to use the functionality of the SqlConnection class? 1, System.Data.SqlClient You are creating an application to retrieve data from a database in a read-only and forward-only mode. For this, you have written the following code snippet: SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Data Source= SQLSERVER01; Initial Catalog=HR; User ID=sa; Password=niit#1234"; connection.Open(); SqlCommandcmd = new SqlCommand("select * from monthlysalary"); SqlDataReadermyReader = cmd.ExecuteReader(); However, on execution, the code snippet is throwing a compilation error. Analyze the code snippet and identify the error. 3, The SqlCommand constructor should have the query and the connection object as the parameter. It should be written as: SqlCommandcmd = new SqlCommand("select * from monthlysalary", connection); Which of the following parameters indicates that the database connection will be reset when the connection is removed from the pool? 1, Connection reset

What would be the value of the Max pool size parameter if you have not explicitly specified any value? 2, 100 Sam is implementing connection pooling. He wants that the pooler opens a new connection instead of attempting to acquire a connection from the pool. For this, he has written the following code: SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Data Source=SQLSERVER01;user ID=sa; password=niit#1234;Initial Catalog=HR;Connection Timeout = 20; Pooling = true"; connection.Open(); However, he found that the code does not fulfill the requirement. Analyze the code and provide a solution. 4, The pooling parameter should be set to false. Which of the following properties of a TextBox control is used to bind the value of a column in the dataset? 4, Text You want to bind a ComboBox control to a specific data element. Which of the following properties will you use? 1, The DisplayMember property Which of the following benefits is NOT provided by stored procedures? 4, reduced bandwidth John has to develop an application that enables the users to retrieve the details of an employee from a database based on a employee code. He has written the following code snippet:

1, After creating the command object, the parameters need to be added, as shown in the code snippet: cmd.Parameters.Add(new SqlParameter("@employeecode", searchemployeecode)); Which of the following properties of the DataView control enables you to specify an expression/condition in a string format for filtering the records? 2, RowFilter Which of the following objects is NOT contained in the Connected classes? 4, Dataset Which of the following properties of the DbCommand object indicates or specifies how the CommandText property is interpreted? 1, CommandType Which of the following properties of a DataAdapter object refers to a DML statement or a stored procedure to retrieve data from a dataset? 2, SelectCommand Which of the following Rule enumeration values deletes or updates the child DataRow object when the Parent DataRow object is deleted or its unique key is changed? 1, Cascade Which of the following enumeration values of the DataViewRowState enumeration retrieves the current row version of all modified rows? 4, ModifiedCurrent Consider the following statements: Statement A: In the connected environment the data is always current and updated. Statement B: Connected environment leads to network congestion.

Which of the following options are correct in context of the preceding statements? 1, Both, Statement A and Statement B, are true. How will you check whether the specified DbParameter object instances are same? 2, By using the RefereneceEquals() method of the DbParameter object How will you determine the number of rows affected in the last batch? 1, By adding a RowUpdated event to the SqlDataAdapter object. Sam wants to merge dataset ds1 with dataset ds. Which of the following code snippet will he use to perform the desired task? 4, ds.Merge(ds1, true, MissingSchemaAction.Add); How will you specify a sorting order on a particular column of a DataView object? 3, By using the Sort property of the DataView object Sam wants to filter and delete the records from a DataView where the year is greater than 1995. Which of the following code snippets will he use to achieve the same? 1, DataView dv = new DataView(); dv.RowFilter = "Year > 1995"; dv.RowStateFilter = DataViewRowState.Deleted; John wants to sort two columns, Salary and Year. He wants to sort the Salary column in the ascending order and the Year column in the descending order. Which of the following code snippets allows him to do so? 1, DataView dv = new DataView(); dv.Sort = "Salary ASC, Year DESC";

Which of the following options allows the DataReader class to handle columns, which store large binary data? 1, The SequentialAccess property Which of the following options is the starting position of the update in the syntax of the UPDATETEXT function? 2, Offset Which of the following WriteToServer() method copies all rows from the DataRow array to a destination table? 3, SqlBulkCopy.WriteToServer (DataRow[]) The __________ class is used for bulk copy of records. 4, SqlBulkCopy Which of the following namespaces will you include to use the PermissionState enumeration? 1, System.Security.Permissions Which of the following classes will you use to execute SQL notifications? 2, The SqlDependency class Which of the following properties of a transaction states that any data modification made by one transaction must be independent from the modifications made by the other transaction? 4, Isolation A local transaction is created and managed within the ____________ namespace. 1, System.Transactions Which of the following methods is called when a transaction is successfully completed? 2, Commit()

Which of the following isolation levels is used when accuracy is required on long-running queries and multi-statement transactions, but no updates are performed on the data? 1, Snapshot Which of the following isolation levels is used when accuracy is required on long-running queries and multi-statement transactions, but no updates are performed on the data? 1, Snapshot 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 you execute the ExecuteReader() method. Which of the following code snippet allows you to do so? 1, command.ExecuteReader(CommandBehavior.SequentialAccess); Identify the correct syntax of the UPDATETEXT function. 3, UPDATETEXT <Table_Name>.<Column_Name><Pointer><Offset><Delete_Length> <Data> You need to enable a Service Broker for a SQL Server database. Which of the following SQL statements will you use? 2, ALTER DATABASE DATABASE_NAME SET ENABLE_BROKER; You want to create and perform local transactions against a single data source. Which of the following options provide you with the methods for doing so? 4, The IDbTransaction interface You are creating an application that implements transactions. In the application, you want that the queries running inside one transaction are affected by the committed changes in another transaction. Which of the following types of transaction isolation levels will you use? 1, Read Uncommitted You have to perform the bulk copy operation. Identify the correct sequence of steps to perform the bulk copy operation.

3, 1. Connect to the source server to get the data to be copied. Sam is creating an application for a hospital. The application should create a backup copy of the Patients table. He has written the following code snippet to copy data from the Patients table to the Patients_backUp table: Line 1: using (SqlConnectionsourceConnection = new SqlConnection(connectionString)) Line 2:{ sourceConnection.Open(); Line 3: SqlCommandcommandSourceData = new SqlCommand("SELECT * FROM Patients;", sourceConnection); Line 4: SqlDataReader reader = commandSourceData.ExecuteReader(); Line 5: using (SqlConnectiondestinationConnection = new SqlConnection(connectionString)) Line 6: { destinationConnection.Open();

Line 7: using (SqlBulkCopybulkCopy = new SqlBulkCopy(sqlConnection)) Line 8: try Line 9: Line 10: Line 11: Line 12: Line 13: {bulkCopy.WriteToServer(reader);} catch (Exception ex) {Console.WriteLine(ex.Message);} finally { reader.Close(); } } }} { bulkCopy.DestinationTableName = "Patients_backUp";

However, when he executed the application, he found that it is not working as desired. Identify the line that has error and provide the correct code snippet. 1,Line 7: using (SqlBulkCopybulkCopy = new SqlBulkCopy(sqlConnection)) has error. It should be:

using (SqlBulkCopybulkCopy = new SqlBulkCopy(destinationConnection)) Peter wants to execute SQL notifications in his application. For this, he has written the following code snippet in the application: public partial class Form1 : Form { 1. private string connectionString = "Data Source=SQLSERVER01;Initial Catalog=BomSaudeHospital;Pooling=False;User id=sa;Password=niit#1234"; 2. 3. private delegate void GridDelegate(DataTable table); privateSqlDependencydep;

public Form1() { 4. } private void Form1_Load(object sender, EventArgs e) { 5. 6. } However, when he executed the application, he found that the preceding code snippet has an error. Identify the line that has error and provide the correct code snippet. 2, Line 5 has an error. The code should be: Line 5: SqlDependency.Start(connectionString); SqlDependency.StartDependency(connectionString); UpdateGrid(); InitializeComponent();

Robert is creating an application in which the BeginTransaction() method is called and a SQL command is passed that will insert one record in the empdetails table. If the particular transaction successfully executes the changes should be committed otherwise the changes should be rolled back. He has written the following code snippet in the application: Line 1: string connectString = "Initial Catalog=HR;Data Source=SQLSERVER01;User id=sa;Password=niit#1234"; Line 2: Line 3: Line 4: Line 5: try{ Line 6: tran = cn.BeginTransactions(); SqlConnectioncn = CreateSqlConnection(); cn.ConnectionString = connectString; cn.Open(); SqlTransactiontran = null;

Line 7: SqlCommandcmd = new SqlCommand("INSERT INTO empdetails(ccode,cname,caddress)VALUES(1101,'Linda Taylor','Oxfordshire')", cn, tran); Line 8: Line 9: Line 10: Line 11: Line 12: cmd.ExecuteNonQuery(); tran.Commit(); Console.WriteLine("Transaction Committed\n"); } catch (SqlException ex) {tran.Rollback();}

catch (System.Exception ex) Line 13: Line 14: Line 15: {Console.WriteLine("System Error\n" + ex.Message); } finally {cn.Close();}

On execution, the code snippet threw an error. Analyze the code snippet and provide the correct code snippet. Ans- 4,Line 2: SqlConnectioncn = CreateSqlConnection(); and Line 6: tran = cn.BeginTransactions(); have errors. These should be: SqlConnectioncn = new SqlConnection(); and tran = cn.BeginTransaction(); Rebecca has written the following code snippet to demonstrate the use of managing distributed transactions: class Program { static void Main(string[] args) { 1. { 2. using(SqlConnectioncn = new SqlConnection("Initial Catalog=HR;Data Source=SQLSERVER01;User id=sa;Password=niit#1234")) { 3. cn.Open(); using (TransactionScopets = new TransactionScope())

4. using (SqlCommandcmd = new SqlCommand("INSERT INTO HRusers(cUserName,cPassword)VALUES('Darren', 'Cooper')", cn)) { 5. 6. { introwsUpdated = cmd.Execute(); if (rowsUpdated> 0)

7. using(SqlConnection cn1 = new SqlConnection("Initial Catalog=HR;Data Source=SQLSERVER01;User id=sa;Password=niit#1234")) { 8. cn1.Open();

9. using (SqlCommand cmd1 = new SqlCommand("DELETE Department WHERE cDepartmentCode=1111", cn1)) { 10. 11. { 12. 13. 14. } } } } } 15. } } 16. } Console.ReadLine(); cn.Close(); ts.Completed(); Console.WriteLine("Transaction Committed\n"); cn1.Close(); int rowsUpdated1 = cmd1.ExecuteNonQuery(); if (rowsUpdated1 > 0)

} When she executed the application, it threw an error. Identify the line that is causing the error and provide the code. Ans- 1, Line 5 and Line 12 are causing the error. The correct code should be: Line 5: introwsUpdated = cmd.ExecuteNonQuery(); Line 12: ts.Complete(); Which of the following properties of the XmlWriterSettings class gets or sets the level of compliance with which the System.Xml.XmlWriter complies? 1, ConformanceLevel Which of the following properties of the XmlReaderSettings class gets or sets a value indicating whether to do character checking or not? 2, CheckCharacters The ____________ class uses the ValidationEventHandler() callback method that is called when a validation error occurs. 3, XmlValidatingReader In the .NET Framework, NamedNodeMap is implemented by the ______________ class. 4, XmlNamedNodeMap Which of the following namespaces contains the SqlXml class? 4, System.Data.SqlTypes 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? 1, XmlWriter You want to determine whether the XmlReader instance imposes validation or not. Which of the following classes enables you to do this? 3, XmlReaderSettings

You want to identify a row in the <DataInstance> block as modified. Which of the following attributes enables you to do this? 3, hasChanges 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? 2, The XmlElement.Attributes property You want to ignore inline schemas and load the XML data into the existing dataset schema. Which of the following XmlReadMode Options enables you to do so? 1, IgnoreSchema Predict the output of the following code snippet: XmlDocument doc = new XmlDocument(); doc.LoadXml(("<BOOKDETAILS><BOOK BOOKID='B001'><BOOKNAME>Angels and Demons</BOOKNAME><AUTHOR>Dan Brown</AUTHOR></BOOK><BOOK BOOKID='B002'><BOOKNAME>Dr. Jekyll and Mr. Hyde</BOOKNAME><AUTHOR>Robert Louis Stevenson</AUTHOR></BOOK></BOOKDETAILS>")); XmlNode node = doc.DocumentElement.FirstChild; node.RemoveChild(node.FirstChild); doc.Save(Console.Out); Console.ReadLine(); Ans- 3, The BOOKNAME element of the first BOOK element is removed.

Potrebbero piacerti anche