Sunday, 28 February 2016

GNIIT SEM B MT2 EXAM QUESTIONS

GNIIT SEM B MT2 EXAM QUESTIONS


1 .Consider  the following  statements:
Statement A :— To start a Thread you mast as call the constructor of Thread  class.
Statement B :– The thread class implements Runnable interface.
SOLUTION——both are true
2. Which of the following class will you use to read the contents of a file as a stream of bytes?
PipeReader,  FileReader, StringReader, FileInputReader.
SOLUTION-fileinputreader
3. What will be the output of the following code
Import  java.awt.*;
Public class Example
{
Private Frame f;
Private Button b1,b2,b3,n4,b5,b6;
Public Example()
{
F=new Frame(“GridLayout Demo”);
B1=new Button(“1”);
B2=new Button(“2”);
B3=new Button(“3”);
B4=new Button(“4”);
B5=new Button(“5”);
B6=new Button(“6”);
}
Public void display()
{
f.setLayout(New GridLayout());
f.add(b1);
f.add(b2);
f.add(b3);
f.add(b4);
f.add(b5);
f.add(b6);
f.setVisible(true);
}
Public static void main(String ar[])
{
Example e=new Example();
e.display();
}
}
SOLUTION :—————-
4. Which of the following method will you call to set the size of a frame.
Pack();
setLayout();
setSize();
setVisible();
SOLUTION:——-setsize();
5. To display apanel you moust add it to __________
A Frame;
Any Component
A text Component
Another panel
SOLUTION:—————-
6. Which of the following is the immediate superclass of the DataOutputStream, BufferedoutputStream, and PrintStream class?
Solution:—————
7. A method in a java class contains code that might result in an exception .Which of the following keyword you use in the method to indicate that the calling method should handle the exception?
SOLUTION :—————-
8. Which of the following  is the keycomponent of a data provider?
DataAdapter, DataTable , DataTable Callection, DataRelationCallection.
SOLUTION:—dataadapter—————–
9.What will be the output of the preceding code?
Public class Example
{
Public static void main (String [])
{
ArrayList<integer>list=new ArrayList<integer();
Int num1=1;
List.add(num1); int num2=2;
List.add(num1);
List.add(num2);
Iterator elements=list.iterator();
While(element.hasNext())
{
ArrayList<integer>list=new ArrrayList<integer();
Int num1=1;  int num2=2;
List.add9num1);
List.add(num2);
Iterate elements=List.iterator();
Wjile(element.has.Next())
{
System.out.println(element.next());
}
}
}
SOLUTION:——–
10.You can use the FileReader class to read___________ .
Integer, characters,streams,Files.
SOLUTION–characters——–
11.Which of the following keywords ensures that a method cannot be overridden Protected, final, static, abstract.
SOLUTION:–abstract—————
12. Which will be the out of the following program;
Class Example
{
Public static void main(String ar[]0
{
int b=11;
b=b>>2
System.out.println(b);
}
}
SOLUTION:——–
13.What will be the output of the following program:
Public  class Example
{
Public static void main (String ar[])
{
For(int i=1; i<5; i++)
{
System.out.println(“HELLO”);
}
}
}
Solution:—-
14. Consider the following statements:
Statement A : Operator || returns true if one of the operand is true;
Statement B: Operator|| returns false if both operands are false.
SOLUTION:—– Both statement are true.
15. Which of the following operation is a short Circcuit logical operator.
&&, | , !,&
SOLUTION:–&&
16. Which of the following is a valid java indentifier
New, long, scount, const.                long
SOLUTION:__long________
17. Pridict the output of the following code
Import java.util.*;
Public class Example
{
Public static void main(String ar[])
{
Try
{
System.out.printin(“HELLO”);
}
}
}
Solution:———–
18. Anew employee smit has joined softTeach solution ltd. His details need to be added to an empdetails table. This task should be done through a transcation which of the following code snippet will allow you to perform this task.
//use SqlTranaction=null example from book
SOLUTION:—-
19. Define the following
Secnario Prototyping , Vertical Prototyping, Skerching, Wizard of oz.
20. Learn about:
a.path-based home-page
b.News-oriented Home-page
c.Menu Homepage
d.Splash Screen Homepage
21. Jenny is designing a computer based tutorial for the kids. To allracts the kids she designed a visual impressive interface.  Identity  by  considering  which user experience goal. Jenny designed the computer based tutorial:
a.Helpful
b.Aesthectically pleasing
c.Suppord Creativity
d.ebjoyable
SOLUTION:—-
22.Which of the following should be used for easy navigation when the web page is long.
a. jump to Top button
b. Links
c. Signature Graphics.
d. Header and  footer.
SOLUTION:——–
23. Consider the following code Snippat.
XmlDocument doc=new XmlDocument();
Doc.Loadxml(‘<BOOK DETAILS><BOOK BOOKID=”B001”><BOOK NAME>ANGELS</BOOK NAME>AR.JEKY</BOOK NAME><AUTHOR>ROBERT</AUTHOE></BOOK></BOOK DETAILS>”)
Which of the following code snippet when oppended to the precoding snipped will produce the following output.
<BOOK DETAILS>
<BOOK BOOKID=”B001”>
<BOOK NAME>ANGELS</BOOK NAME>
<AUTHOR>DOWN BROWN<AUTHOR>
<BOOK>
<BOOK BOOKID=”B001”.
<BOOK NAME>DR.JEKY</BOOK NAME>
<AUTHOR>ROBERT</AUTHOR?\>
</BOOK>
24. Which of the following statement is true about the infer Schema XmlReaderMode operation?
SOLUTION:———-
25. Which of the following method of the xmlTextWriter class creates an XML declaration?
WriteElementString(), WriterDeclaration(),WriteStartElement(),WriteStartDocument().
SOLUTION:———–
26.Consider the following code and select the correct option
Public class Example
{
Public static void main(String ar[]) throws  interruptedException
{
String info[]={“java”,”C++”);
For9int i=0;i<info.length;i++)
{
Thread.sleep(4000);
}
System.out.println(inf0[i]);
}
}
}
SOLUTION:—————-
26. LEARN THE CODE OF PAGE 4.7 OF ADO.NET.
27.Which of following is the best practice for designing the web content to mobile phone.
a. The use of Drop Down List Should be used for navigation.
b.  Css  and frames Should be used for web pages developed for mobile phones.
c. Use cookied because most of the mobile pbone do support them.
d. The  website Should be simple and shallow.
SOLUTION:——
28. Consider the following code Snippet UPDATEXT Student. Photo @A@B@C@D Sqlprameter
P= Command.pParameters.Add(@A,SqlDbType.x,16 ) in the preceding code Snipper What does x represents?
Image, int, Binary,String
SOLUTION:——-
29.  How will you ensure that the UPDATETEXT function does not delete the existing data?
a. By Specifying the length of data to be deleted as o.
b. By specifying the length of data to be deleted as null.
c. By specifying the length of data to be deleted as an empty string.
d. By Specifying the length of data to be deleted as None.
SOLUTION:—————–
30. What is wrong with this code:
String employeeCode;
employeeCode=textBox1.text;
string ConnectionString=”Data Source=SQLSERVER 01;Intial Catalog=HR;UserId=sa;Password=niit#123;
SqlConnection cn=new SqlConnection();
Cn.ConnectionString=connectionString;
Cn.Open;
sqlCommand cmd=cn.CreateCommand();
cmd.CommandType=CommandTypetext;
cmd.CommandText=”Selectt * from Employees where empid=@cCode”;
cmd.Parameters.Add9new SqlParameter(@cCode,employee code));
textBox2.Text=Convert.ToString((cmd.ExecuteScalar());
textBox3.Text=Convert.ToString((cmd.ExecuteScalar());
cn.Close();
SOLUTION:——-
31. LEARN CODE OF CHAPTER-4 OF ADO.NET.
32. Which function of the DbCommand class would enable to retrieve the number of row affecected whenever any transaction is implement in the database through the front end.
a.  Execute Reader().
b. ExecuteScalar().
c. ExecuteNonQuary()
d. Equals(),
SOLUTION;——c—
33. Which method of the DbCommand object excutes a qyary and returns the first column of the first row in the result set returned by the query
a.  ExcuteReader()
b. Execute Scalar()
c. Execute NonQuery()
d. Equals()    b
SOLUTION:———–b—-
34. Identify whether the preceding code will give the desired output or not?
SqlConnection con=new SqlConnection();
Con.ConnectionString=”Data Source=SQLsERVER01;Intial Catalog=”HR; UserId=sa;Password=password”;
Con.Open;
SqlCommand cmd=new SqlCommand(“Select * from Employees”,con);
Cmd=drExecuteReader();
While(dr.Read())
{
ComboBox1.item.Add(dr[0]);
}
Con.Close();
SOLUTION:—————-
35.Consider the following code Snipper
SqlConnection connection=new SqlConnection();
Connection.ConnectionString=”DataSource=SourceDB; Initial Catalog=Library; User ID=Administrator; Pasword=Password;
What does Library Signifies in the preceding code Snippet.
SOLUTION:————–
36. Which namespace do you need to include  in order to give permission to user so that he is able to Execute query notification?
System.Permissions.
System.Permissions.Security
System.Security.Permissions
System.Security
SOLUTION;————
37. TO make a variable constraint  you need to define the variable with Keyword.
Static
Private,
Final
Public
SOLUTION:—–
38. What will be the output of the following code:
Public  class Example
{
Public static void main(String ar[]0
{
try
System.out.print.ln(“1”);
System.out.print.ln(1/0);
System.out.print.ln(“2”);
}
Catch(ArithmeticException e)
{
System.out.print.ln(“3”);
}
Catch(Exception e)
{
System.out.print.ln(“4”);
}
Finally
{
System.out.print.ln(“5”);
}
}
}
SOLUTION:————– THE OUT PUT OF FOLLOWING CODE ARE (1,3,5);
39. Select the correc option:
STATEMENT A:- —  There can be multiple catch block after a try block.
STATEMETN B:— The finally clause defines a block of code that is always exeeuted irrespective as an exception being thrown or not.
SOLUTION:—a true b false–
40. You must declare method of an interface as
Static, private ,final, public
SOLUTION:—public
41. Which of the following is not a valid switch Statement.
SOLUTION (TO REMEMBER THE SYNTEX)
42. Predict the output of the following code
Public class Example
{
Public static void main (String ar[])
{
String[]names={“ Linex”, “Unix”, “Windows”, MacOS”};
For(String List:names)
System.out.print.ln(“List”);
}
}
SOLUTION:——
43. Which method is used to invoke the default Constructor of base class.
SOLUTION:—–new–
44. Which of the following option will you use to determine the number of element that an  array contains:
Length,size sixe(),length()
SOLUTION:–length——-
45. Your program needs to use Ram Class present in the xyz.ab package . Which statement import that class to your program.
Import xyz.*; import Ram.*; import xyz.ab.*; import.Ram;
SOLUTION:———import xyz.ab*.;—-
46.  public class Example
{
Public static void main (String ar[])
{
String str1=ar[0];
String str2=ar[1];
String str3=ar[3];
System.out.println(str1+str2+str3);
}
}
What  will be the output of the preceding code with the following command:
javaExample12 java Programing language
SOLUTION:——-
47. Define the following
Vertical Protyping, Horizantal Prototyping, Wizard of oz technique.
48. Which type of data qathering technique can be used to clooect quantitive data;
Question naires, Focus Group; NaturaListic observation, Interviews
SOLUTION:————-
49. What are the goals of the following
Efficiency, memorability, Utility, Effectiveness
SOLUTION:————
50.  What is true about the interSchema Readmode option.
1. It loads the xml data into the exist dataset Schema.
2. It doesnot deduce the Schema according to the structure of xml data.
3. It ignores any inline schema
4. It esamines the xml data and selects the oppropriate option.
SOLUTION:———–
51. Which of the following code snipper retrieves the xml
1. string str=dataset1.GetXml();
2. String str=dataSet1.Convert.GetXml;
3. String str=dataSet1.GetXml;
4.String str=getXml(dataSet1);
SOLUTION:————
52. Consider an example.txt file saved in your working directory that contains the following contents:
User Name=Admin
Password=Administrator
Host=local host
What code will you write to read the contents of the example.txt file and display it on console?
SOLUTION:————
53. What is the correct definition of atomicity?
SOLUTION:—-
54. What is true about a disconnected environment ?
1. Data is not always up to data
2. Allows one application to interface with the data source at a time.
3. Changes for data concurrency issues are less
4. A Constant connection is always required
SOLUTION:—–
55. Identify whether the following code the desired output or not.
SqlConnection connection =new SqlConnection();
Connection.connectionString=”Data Source= SQLSERVER01;Intial Catalog=HR; User ID=sa; Password=password;
Connection.Open;
SqlCommand cmd=new SqlCommand(connection,”delete from Employee where cEmployeeCode=1000015’ “);
SqlDataReader myReader=cmd.ExecuteReader();
myReader.read();
SOLUTION;————————-
56. What will be the output of the following code?
Public class Example
{
Public static void main(String ar[])
{
Int res=0;
Int[]ar=new int[]{1,2,3,4,5};
For(int element:arr)
{
Res +=element;
}
System.out.print.ln(res);
}
}
SOLUTION:—————
57. To compile execute  java Programs you need to set the path environment variable to—————————————–.
SOLUTION : ————————–
58. Consider the following statement:
Thread.sleep(x);
What is true about x?
SOLUTION :————————-
59. Which method will you call to start a thread?
SOLUTION: —start———
60. Consider the following code
Frame f=new Frame(“Frame”);
menuBar mb=new MenuBar();
what code willyou write to add the menuBar to the frame?
SOLUTION: ———————
61. Which layout manager enables you to assign row and column number to arrange component>
SOLUTION:—-gridlayout——————–
62.Event AWT component has a _______________method that drows the specified component on a container
SetSize(), drow(), paint(),setVisible()
SOLUTION : —————–
63. In a java multithreading program , under  what circumstance will you call the yield()
Method of a thread?
1. To give other urnnable threads a change to execute
2.  To terminiate the current thread
3. To stop the current thread for a specific time
4. To start a new method.
SOLUTION :———–
64. Predict the method:
Public class Example
{
Public Example()
{
System.out.println(“Inside Constructor”);
}
Static
{
System.out.println(“Inside static block”);
}
Public static void main(String ar[])
{
System.out.println(“Inside main method”);
}
}
SOLUTION  :———
65. Select the correct integer length for the int datatype.
SOLUTION :——
66. Predict the output:
Public class example extends Thread
{
Public static void main(String ar[])
{
Example obj=new Example();
Obj.run();
}
Public void start()
{
For(int i=0; i<5;i++)
{
System.out.println(“Hello”);
}
}
}
SOLUTION  :———-
67. Which one is NOT a valid state of a thread?
Dead,Running, Listening, Bloched
SOLUTION : —listening————-
68. Which one is a valid TCP/IP port number?
-7070, 65535, -8080,1000000
SOLUTION :—————
69. Consider that you are creating a GUI application and you need an action listener to handele events of type Action Event.
What will be the correct code?
SOLUTION :——
70. STATEMENT A :- The code to add a button object to the center region of a frame frame.add(button,”Center”);
STATEMENT B:—— The code to add a button object to the center region of a frame using border layout is :-
Frame.add(button,BorderLayout.CENTER);
SOLUTION: ———–
71. The default layout manager of a panel is ——————
SOLUTION:  -flowlayout———-
72. Which method enables you to force write that an output stream accumulats?
Flush(), close(), read(), write().
SOLUTION: ———–
73. Which exception will be thrown if a program tries to read from a file that does not exist?
SOLUTION: —————
74. Which components of a data set  contains all the tables retrived from the dataSource?
1. DataTable
2.DataTableCollection
3.Data Relation collection
4.Data column Collection
SOLUTION: ————
75. public class Example
{
Public static void main(String ar[])
{
Try
{
String name=ar[1];
System.out.println(name);
}
Catch(Exception e)
{
}
}
}
What will be output of given the following command java Example james.
SOLUTION; ————
76. STATEMENT A:  – Variable defined with static keyword are called class variable
STATEMENT B: — A static variable is available from any instance of a class.
SOLUTION; ———-
77. Which exception is thrown when you try to divide a number by 0?
SOLUTION: ———-
78. What will be the out put
public class Example
{
static int num;
public static void main(String ar[])
{
System.out.println(num);
}
}
SOLUTION; ————
79. Statement A: ———- When your class extends a super class, your class inherits all the public methods of the super class.
STATEMENT B:——- When your class extends a SuperClass your class inherites all the constructor of the  suoper class.
SOLUTION: ——–
80. All java class directly or indirectly extends the ________________________ class.
1. Class
2. object
3. String
4. Main
SOLUTION: ——————
81.  abstract class Example
{
Abstract void display();
void display All()
{
System.out.println(“Hello”);
}
}
What change should be done so that output hello will displayed.
SOLUTION: ——————
82. What are the different goals of the following
1. Constrainst
2.Mapping
3.FeedBack
4. Visibility
SOLUTION : ———————
83. Which type of environmental requirements address question related to the hierachy of the orgazination?
1. Orgazinationalenvironment
2.Physicalenvironment
3.Technical environment
4.Social environment
SOLUTION: —————–
84.You need to validata xmlfile myFile.xml aginst a schema myfile.xsd By using Xml validating Read what will be the corrrect code?
SOLUTION : ———-
85. DataSet ds=new DataSet();
Ds.Readxml(“c:\\student.Xml”,XmlReadMode.InferSchema);
dataGridview1.DataSource=x;
what does x represents for?
1.ds.Table[0].DefaultView
2. ds.Tables.DefaultView
3.ds.DafualtView.Tables[0]
4. ds.defaultView
SOLUTION: ————
86. Which method of the XmlTextReader class reads the very next node from the stream?
1.MoveToNext Attribute();
2.ReadString()
3.Read()
4.Read NextElement
SOLUTION: ———-
87.Which method is used to collection and interprect data from end user to design an application?
1.Caherence
2. Exhnography
3.Contextual Design
4.Participatory Desin
SOLUTION: ————-
88. How many paramentrs does the GetBytes method take?
SOLUTION: —–
89. Which menthod of DataRow object would enable to insert a row in a table at a specified position?
SOLUTION: ————
90. Which method of the DataRow object accesses a row in a table by its primary key value?
1. find()
2. insert At()
3.Select()
4. Add()
SOLUTION: –
91. Which is used to prove Security permission to a user for excuting SQL notification?
1.SqlConnection
2.SqlClientPermission
3.SqlCommand
4.SqlDataAdapter
SOLUTION: —————–
92. public class Example
{
public static void main(String ar[])
{
ArrayList list=new ArrayList();
Integer num=new Integer(10);
list.add(0,num);
Integer.numobj=(Integer)list.get(0);
int num2=numobj int value();
System.out.println(num2);
}
}
Wjich of the following code woll you use to replace the preceding code for aptimization using generice and outoboxing?
SOLUTION; —-
93. Perdict the output
public class Wxamole extends  Thread
{
public static void main(String ar[])
{
for(int i=0;i<3; i++)
new Example().start();
}
public void run()
{
System.out.println(“Dello”);
}
}
SOLUTION: ——— PRINT    ” HELLO”  3 TIMES.
94. Wjich of the following will you use to read a stream of bytes in a program?
1.Writer  2.Reader    3. OutrputStream  4. InputStream
SOLUTION: —– InputStream.
95. You need an action listener to handle events of type ActionEvent. Which of the following Listener code will you use?
SOLUTION: ——
96. ___________________are those that a program is expected to handle in a program.
1. Object of the error class   2. Runtime exception  3. Checked Exception. 4. Unchecked exception
SOLUTION: ———-  Checked Exception
97. Predict the output
Public calss Example
{
Find int I;
Public static void main(String ar[])
{
System.pot.println(new Example(););
}
}
SOLUTION ———–
98. Consider the following code:
Public class Example
{
Public class Example
{
Public static int num1=4;
Public int num2=5;
}
In the preceding code , which one is a class variable
SOLUTION ———–  BOTH ARE THE CLASS VAROABLE
99.You must declare method of an interface as
Public
Private
Static
Final
SOLUTION ——–  PUBLIC
100. What will be the output of the following code
Class Example
{
Public static void main (String ar[])
{
Int  num=5;
Do
{
System.out.println(“The  number is “ + num);
}
While(num<10);
}
}
SOLUTION – WILL DISPLAY THE OUTPUT “ The number is 5” infinity
101. Predict the output
Public class Example
{
Public static void main(String ar[])
{
String str;
Str=str+”HELLO WORLD”;
System.out.println(str);
}
}
SOLUTION — Compilation error because variable str is not initialized
102. ————– is the default of double datatype?
a. null
b.1.00
c.0.00
d.1
SOLUTION —— 0.00
103. STATEMENT A : String a permitive datatype to represent a sequence of characters.
STATEMENT  B :You can declare a string variable as: String str=”I am String”;
SOLUTION ——  A is false   B is true.
104. Which of the following code snippet will allow you to creae an xml file of the following format?
<?xml version=”1.0” encode=”utf-8”?>
<OrderDetails>
<Order OrderID=”o 001”>
<Name> Tous</Name>
<Price>100</Price>
</Order>
<order OrderID=”o002”>
<Name>Stationary</Name>
<Price>30</Price>
</Order>
</OrderDetails>
SOLUTION – PAGENO 6.8 OF Ado.Net
105. You have create an xml file using XmlWriter. When you open the xmlfile in notepad You get the following output in one line:
<?xml version=”1.0” encoding=”utf-8”?>
<!— order details of Q!–>
<OrderDetail><Order OrderID=”o001”><Name>Toys</Name><Price>100</Price></Order ><Order OrderID=”o002”><Name>Stationary</Name><Price>30</Price></Order>
WHAT might be the possible couse?
  1. The indentChars property has niot been set to “ “
  2. 2.The indent property of New Line on Attribute class not been set to true
  3. The indent property of Xml Writer Setting class has not been set to true
  4. The indent Char property of XmlWriterSetting class has been set to true
SOLUTION :——————-
106. Consider the following snoppet to read an image file
File.Read(x,y,z); //file is an object of the fileStream class.
What are the datetype of x,y,z,?
SOLUTION ————–
107. Whch class is used to copy data in bulk to sql Server table?
1. Sql Command
2. Sql Data Reader
3. SqlCommand
4. Sql bulkCopy
SOLUTION —————-
108. Consider the following code snippet
Dataview dv=new DataView();
dv.RowFilter=”Price=100”;
What is the function of the RowFilter property in the preceding code snippet?
SOLUTION —-
109. After calling which method do yoy need to execute a command with in a transaction set the connection property of the command to a connection running the oppropriate transaction and then execute the command?
1. RollBack()
2. EndTransaction()
3. BeginTransaction()
4.Commit()
SOLUTION —

No comments:

Post a Comment