1. Which interface does DataInputStream implements?
Ans: DataInput
2. Return type of newLine() method in BufferedWriter class is boolean
Ans: False
3. Will this code compile?
class Demo
{
Demo(char status)
{
System.out.println("Parameterized constructor");
}
public static void main(String args[])
{
Demo ob=new Demo('A');
}
}
Ans: This code will compile as the default constructor is not used in main()
4. Which method is used to print the description of the exception?
Ans: printStackTrace()
5. The method forward(request,response) will
Ans: return back to the same method from where the forward was invoked
6. Select a query that retrieves all of the unique coursename from the student table?
Ans: SELECT DISTINCT coursename FROM studentinfo;
7. Which of the following is true?
Ans: all of the above (Enum in java is a data type, enum can have fields, constructors and methods, enum may implement many interfaces but cannot extend any class because it internally extends Enum class)
8. ON UPDATE CASCADE ensures which of the following?
Ans: Data Integrity
9. public class Test{
public static void main(String args[]){
String obj="I LIKE JAVA";
System.out.println(obj.charAt(5));
}
}
What is the output of above program?
Ans: E
10. class Equals
{
public static void main(String args[])
{
int x=100;
double y=100.1;
boolean b=(x=y); /*Line 7*/
System.out.println(b);
}
}
What is the output of above code snippet?
Ans: Compilation fails
11. Which of the following interprets html code and renders webpages to user?
Ans: browser
12. Which normal form is considered adequate for relational database design?
Ans: 3NF
13. What type of exception can readLine() of DataInputStream throws?
Ans: IOException
14. Which of these is method is used for writing bytes to an OutputStream?
Ans: write()
15. Is Java an open source software language?
Ans: Yes, Its an open source
16. Which of these are the subclasses of InputStream class?
Ans: All of the mentioned (AudioInputStream, ByteArrayInputStream, FileInputStream)
17. What is the return type of read() method in BufferedInputStream?
Ans: int
18. Every statement in java programming language ends with
Ans: Semicolon
19. All the methods in an interface are_______and________by default
Ans: Public, abstract
20. A stream that is intended for general purpose IO, not usually character, data, is called..
Ans: ByteStream
21. Parameter of______datatype is accepted by skipBytes()?
Ans: int
22. Which of these interface is not a member of java.io package?
Ans: ObjectFilter
23. Is the read function of DataInputStream class overridden?
Ans: True
24. Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
Ans: append()
25. The reset method of BufferedInputStream accepts parameters
Ans: False
26. What is the output of this program?
import java.util.*;
class Array
{
public static void main(String args[])
{
int array[]=new int[5];
for(int i=5;i>0;i--)
array[5-i]=i;
Arrays.sort(array);
for(int i=0;i<5;++i)
System.out.println(array[i]);
}
}
Ans: 12345.0
27. Java platform consists of below components
Ans: Java API, JVM
28. Return type of newLine() in BufferedWriter class is Boolean
Ans: False
29. What is the return type of read function in DataInputStream class?
Ans: int
30. public class StringExam{
public static void main(String args[])
{
String s1="Arun";
String s2="Arun";
String s3=new String("Arun");
String s4=new String("Arun");
System.out.println(s1.equals(s2));
System.out.println(s1==s2);
System.out.println(s3.equals(s4));
System.out.println(s3==s4);
}
}
Ans: true true true false
31._____is a collection of objects with similar properties
Ans: class
32. Which of these keywords must be used to monitor for exceptions?
Ans: try
33. Is readShort() of DataInputStream final?
Ans: True
34. The FileReader assumes that you want to_____the bytes in the file using the default character encoding for the computer your application is running on
Ans: decode
35. The way a particular application views the data from the database that the application uses is a
Ans: Sub schema
36. InputStreamReader(InputStream) creates an InputStreamReader that uses______
Ans: default character encoding
37. An object of which is created by the web container at time of deploying the project?
Ans: ServletContext
38. How many parameters does the read() accept in DataInputStream class?
Ans: 1,3
39. Given request is an HttpServletRequest, which code snippets will create a session if one doesn't exist?
Ans: request.getSession();
40. Java programs should be compiled for each type of platform
Ans: false
41. How many parameters does the skipByte() accept in DataInputStream class?
Ans: 1
42. What is the return type of read() method in BufferedInputStream?
Ans: int
43. What command is used to remove the directory?
Ans: rmdir
44. java.util.Properties class extends________class
Ans: java.util.Hashtable
45. Which of the following describes the correct sequence of the steps involved in making a connection with a database.
1. Loading the driver
2. Process the results
3. Making the connection with the database
4. Executing the SQL statements
Ans: 1,3,4,2
46. Writer class is for processing Character streams
Ans: True
47. How many numeric data types are supported in Java?
Ans: 6
48. java.exe can be found at which 2 places in JDK directory?
Ans: JAVA_HOME\jre\bin
49. public void write(int b) of FileOutputStream implements the write method of OutputStream
Ans: True
50. The sendRedirect() method of HttpServletResponse interface can be used to redirect response to another resource, it may be servlet, jsp or html file?
Ans: True
51. Arrays when passed to a method they are always passed by refernce. Is this true or false?
Ans: True
52. JVM is available for:
Ans: All popular Operating Systems
53. Which of these can be thrown using the throw statement?
Ans: All the above (a) Error, b) Throwable, c) Exception)
54. Which of the following is the data query statement in QUEL?
Ans: SELECT
55. How many techniques are used in Session Tracking?
Ans: 4.0
56. is write() method in BufferedWriter class overloaded?
Ans: True
57. Fork is
Ans: The creation of a new process
58. JDK7 introduced a new version of try statement known as____
Ans: try-with-resources statement
59. How many parameter does the readBoolean() of DataInputStream accepts?
Ans: 0
60. Java is a______independent language
Ans: Platform
61. What is the return type of close() method in BufferdReader class?
Ans: void
62. What is the output of the code
public class test{
public static void main(String args[]){
int i=1,j=1;
try{
i++;
j--;
if(i/j>1)
i++;
}
catch(ArithmeticException e){
System.out.println(0);
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println(1);
}
catch(Exception e){
System.out.println(2);
}
finally{
System.out.println(3);
}
System.out.println(4);
}
}
Ans: 0,3,4
63. A file containing relatively permanent data is
Ans: Master File
64. Which of the following are the five built-in functions provided by SQL?
Ans: COUNT, SUM, AVG, MAX, MIN
65. It is a good practice to put the cleanup code(like closing Connection or PrintWriter object) in______block, even when no exceptions are anticipated.
Ans: finally
66. Which life cycle method make ready the servlet for garbage collection
Ans: destroy
67. reset() have boolean return type in BufferedReader class
Ans: True
68. Subclass of Writer class is?
Ans: StringWriter
69. Development tools are
Ans: Both A and B ( a) compiler, b) java application launcher )
70. The expected signature of the main method is public static void main(). What happens if we make a mistake and forget to put the static keyword? Assume that we are executing using command prompt.
Ans: The JVM fails at runtime with NoSuchMethodError
71. Which of these class is used to read characters in a file?
Ans: FileReader
72. readLine() method have integer return types in BufferedReader class.
Ans: False
73. Java is an interpreter that interprets the byte code into machine dependent code and executes program
Ans: True
74. Which method is used access the cookies that are added to response object?
Ans: getCookies()
75. What checks the code fragments for illegal code that can violate access right to objects?
Ans: Bytecode verifier
76. What MySQL property is used to create a surrogate key in MySQL?
Ans: AUTO_INCREMENT
77. Program counter register is a type of area allocated by_____
Ans: none of these
78. What is the output of the below code?
class MyClass
{
int i;
float j;
public static void main(String[] args)
{
System.out.println("i="+i+"j="+j);
}
}
Ans: i=0 j=0.000000
79. Both Primary key and unique key allows NULL
Ans: false
80. What is the return type of read() method of InputStreamReader?
Ans: int
81. Which of the following require large computer memory?
Ans: All of the mentioned (Imaging, Graphics, Voice)
82. The tracks on a disk which can be accessed without repositioning the R/W heads is
Ans: Cylinder
83. Which will legally declare, construct and initialize an array?
Ans: int myList[]={4, 3, 7};
84.______in Java identifies and discards the objects that are no longer needed by a program so that their resources can be reclaimed and reused
Ans: Garbage Collection
85. What exception is thrown by read() method of InputStreamReader?
Ans: IOException
86. A non-correlated subquery can be defined as____
Ans: A set of one or more sequential queries in which generally the result of the inner query is used as the search value in the outer query
87. What is the fullform of WORA?
Ans: Write Once Run Anywhere
88. Is readByte() of DataInputStream final?
Ans: True
89. When three or more AND and OR conditions are combined, it is easier to use the SQL keyword(s):
Ans: Both IN and NOT IN
90. What type of exceptions can readFloat() of DataInputStream throws?
Ans: IOException
91. Arrays when passed to a method they are always passed by reference. Is this true or false?
Ans: true
92. A______file contains bytecodes
Ans: .class
93. Servlets handle multiple simultaneous requests by using threads?
Ans: True
94. In BufferedOutputStream, the method notify is inherited from:
Ans: java.lang.object
95. What will be the output of the below code:
public class Test{
public static void main(String args[])
{
String a="2";
String b="8";
System.out.println(a+b);
}
}
Ans: 28
96. A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction?
Ans: Do not declare with any accessibility modifiers
97. close() method have integer return type in BufferedReader class
Ans: false
98. Which two statements are true regarding constraints?
Ans: A column with the UNIQUE constraint can contain NULL
99. Java is a_______level programming language
Ans: high
100. Which of these classes defined in java.io and used for file-handling are abstract:
A) InputStream
B) PrintStream
C) Reader
D) FileInputStream
E) FileWriter
Ans: A and C
101. You want to calculate the sum of commissions earned by the employees of an organisation. If an employee doesn't receive any commission, it should be calculated as zero. Which will be the right query to achieve this?
Ans: select sum(nvl(commission,0))from employees
102. Which class does not override the equals() method, inheriting them directly from class object?
Ans: java.lang.StringBuffer
103.
public class Test{
public static void main(String args[]){
System.out.println(new Test().mystery("DELIVER"));}
public String mystery(String s){
String s1=s.substring(0,1);
String s2=s.substring(1,s.length()-1);
String s3=s.substring(s.length()-1);
if(s.length()<=3) return s3+s2+s1;
else
return s1+mystery(s2)+s3;
}}
What is the output of the above program?
Ans: DEVILER
104. What data type does FileReader.readLine() return?
Ans: String
105.
String s="hello";
String t=s;
t=s+"world";
System.out.println(s);
What would be the output of the above code snippet?
Ans: hello
106. A part located in the central processing unit that stores data and information is known as
Ans: Core memory
107. FileInputStream class extends_____class
Ans: InputStream
108. mark() method have void return type in BufferedReader class.
Ans: True
109. _______is a special type of integrity constraint that relates two relations and maintains consistency across the relations
Ans: Referential integrity constraints
110. BufferedWriter is_______
Ans: Class
111. FileReader class inherits from the InputStreamReader class
Ans: True
112. What are all false about ENUMS?
Ans: Enums can extend any other type
113. What is the return type of readDouble() of DataInputStream class?
Ans: double
114. What is the return type of reverse() method in StringBuffer class?
Ans: StringBuffer
115. Given request is an HttpServletRequest, which code snippets will creates a session if one doesn't exist?
Ans: request.getSession();
116. Which of these method of FileReader class is used to read characters from a file?
Ans: read()
117. Which method is used to access the cookies that are added to response object?
Ans: getCookies()
118. _________joins two or more tables based on a specified column value not equaling a specified column value in another table
Ans: NON-EQUIJOIN
Ans: DataInput
2. Return type of newLine() method in BufferedWriter class is boolean
Ans: False
3. Will this code compile?
class Demo
{
Demo(char status)
{
System.out.println("Parameterized constructor");
}
public static void main(String args[])
{
Demo ob=new Demo('A');
}
}
Ans: This code will compile as the default constructor is not used in main()
4. Which method is used to print the description of the exception?
Ans: printStackTrace()
5. The method forward(request,response) will
Ans: return back to the same method from where the forward was invoked
6. Select a query that retrieves all of the unique coursename from the student table?
Ans: SELECT DISTINCT coursename FROM studentinfo;
7. Which of the following is true?
Ans: all of the above (Enum in java is a data type, enum can have fields, constructors and methods, enum may implement many interfaces but cannot extend any class because it internally extends Enum class)
8. ON UPDATE CASCADE ensures which of the following?
Ans: Data Integrity
9. public class Test{
public static void main(String args[]){
String obj="I LIKE JAVA";
System.out.println(obj.charAt(5));
}
}
What is the output of above program?
Ans: E
10. class Equals
{
public static void main(String args[])
{
int x=100;
double y=100.1;
boolean b=(x=y); /*Line 7*/
System.out.println(b);
}
}
What is the output of above code snippet?
Ans: Compilation fails
11. Which of the following interprets html code and renders webpages to user?
Ans: browser
12. Which normal form is considered adequate for relational database design?
Ans: 3NF
13. What type of exception can readLine() of DataInputStream throws?
Ans: IOException
14. Which of these is method is used for writing bytes to an OutputStream?
Ans: write()
15. Is Java an open source software language?
Ans: Yes, Its an open source
16. Which of these are the subclasses of InputStream class?
Ans: All of the mentioned (AudioInputStream, ByteArrayInputStream, FileInputStream)
17. What is the return type of read() method in BufferedInputStream?
Ans: int
18. Every statement in java programming language ends with
Ans: Semicolon
19. All the methods in an interface are_______and________by default
Ans: Public, abstract
20. A stream that is intended for general purpose IO, not usually character, data, is called..
Ans: ByteStream
21. Parameter of______datatype is accepted by skipBytes()?
Ans: int
22. Which of these interface is not a member of java.io package?
Ans: ObjectFilter
23. Is the read function of DataInputStream class overridden?
Ans: True
24. Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
Ans: append()
25. The reset method of BufferedInputStream accepts parameters
Ans: False
26. What is the output of this program?
import java.util.*;
class Array
{
public static void main(String args[])
{
int array[]=new int[5];
for(int i=5;i>0;i--)
array[5-i]=i;
Arrays.sort(array);
for(int i=0;i<5;++i)
System.out.println(array[i]);
}
}
Ans: 12345.0
27. Java platform consists of below components
Ans: Java API, JVM
28. Return type of newLine() in BufferedWriter class is Boolean
Ans: False
29. What is the return type of read function in DataInputStream class?
Ans: int
30. public class StringExam{
public static void main(String args[])
{
String s1="Arun";
String s2="Arun";
String s3=new String("Arun");
String s4=new String("Arun");
System.out.println(s1.equals(s2));
System.out.println(s1==s2);
System.out.println(s3.equals(s4));
System.out.println(s3==s4);
}
}
Ans: true true true false
31._____is a collection of objects with similar properties
Ans: class
32. Which of these keywords must be used to monitor for exceptions?
Ans: try
33. Is readShort() of DataInputStream final?
Ans: True
34. The FileReader assumes that you want to_____the bytes in the file using the default character encoding for the computer your application is running on
Ans: decode
35. The way a particular application views the data from the database that the application uses is a
Ans: Sub schema
36. InputStreamReader(InputStream) creates an InputStreamReader that uses______
Ans: default character encoding
37. An object of which is created by the web container at time of deploying the project?
Ans: ServletContext
38. How many parameters does the read() accept in DataInputStream class?
Ans: 1,3
39. Given request is an HttpServletRequest, which code snippets will create a session if one doesn't exist?
Ans: request.getSession();
40. Java programs should be compiled for each type of platform
Ans: false
41. How many parameters does the skipByte() accept in DataInputStream class?
Ans: 1
42. What is the return type of read() method in BufferedInputStream?
Ans: int
43. What command is used to remove the directory?
Ans: rmdir
44. java.util.Properties class extends________class
Ans: java.util.Hashtable
45. Which of the following describes the correct sequence of the steps involved in making a connection with a database.
1. Loading the driver
2. Process the results
3. Making the connection with the database
4. Executing the SQL statements
Ans: 1,3,4,2
46. Writer class is for processing Character streams
Ans: True
47. How many numeric data types are supported in Java?
Ans: 6
48. java.exe can be found at which 2 places in JDK directory?
Ans: JAVA_HOME\jre\bin
49. public void write(int b) of FileOutputStream implements the write method of OutputStream
Ans: True
50. The sendRedirect() method of HttpServletResponse interface can be used to redirect response to another resource, it may be servlet, jsp or html file?
Ans: True
51. Arrays when passed to a method they are always passed by refernce. Is this true or false?
Ans: True
52. JVM is available for:
Ans: All popular Operating Systems
53. Which of these can be thrown using the throw statement?
Ans: All the above (a) Error, b) Throwable, c) Exception)
54. Which of the following is the data query statement in QUEL?
Ans: SELECT
55. How many techniques are used in Session Tracking?
Ans: 4.0
56. is write() method in BufferedWriter class overloaded?
Ans: True
57. Fork is
Ans: The creation of a new process
58. JDK7 introduced a new version of try statement known as____
Ans: try-with-resources statement
59. How many parameter does the readBoolean() of DataInputStream accepts?
Ans: 0
60. Java is a______independent language
Ans: Platform
61. What is the return type of close() method in BufferdReader class?
Ans: void
62. What is the output of the code
public class test{
public static void main(String args[]){
int i=1,j=1;
try{
i++;
j--;
if(i/j>1)
i++;
}
catch(ArithmeticException e){
System.out.println(0);
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println(1);
}
catch(Exception e){
System.out.println(2);
}
finally{
System.out.println(3);
}
System.out.println(4);
}
}
Ans: 0,3,4
63. A file containing relatively permanent data is
Ans: Master File
64. Which of the following are the five built-in functions provided by SQL?
Ans: COUNT, SUM, AVG, MAX, MIN
65. It is a good practice to put the cleanup code(like closing Connection or PrintWriter object) in______block, even when no exceptions are anticipated.
Ans: finally
66. Which life cycle method make ready the servlet for garbage collection
Ans: destroy
67. reset() have boolean return type in BufferedReader class
Ans: True
68. Subclass of Writer class is?
Ans: StringWriter
69. Development tools are
Ans: Both A and B ( a) compiler, b) java application launcher )
70. The expected signature of the main method is public static void main(). What happens if we make a mistake and forget to put the static keyword? Assume that we are executing using command prompt.
Ans: The JVM fails at runtime with NoSuchMethodError
71. Which of these class is used to read characters in a file?
Ans: FileReader
72. readLine() method have integer return types in BufferedReader class.
Ans: False
73. Java is an interpreter that interprets the byte code into machine dependent code and executes program
Ans: True
74. Which method is used access the cookies that are added to response object?
Ans: getCookies()
75. What checks the code fragments for illegal code that can violate access right to objects?
Ans: Bytecode verifier
76. What MySQL property is used to create a surrogate key in MySQL?
Ans: AUTO_INCREMENT
77. Program counter register is a type of area allocated by_____
Ans: none of these
78. What is the output of the below code?
class MyClass
{
int i;
float j;
public static void main(String[] args)
{
System.out.println("i="+i+"j="+j);
}
}
Ans: i=0 j=0.000000
79. Both Primary key and unique key allows NULL
Ans: false
80. What is the return type of read() method of InputStreamReader?
Ans: int
81. Which of the following require large computer memory?
Ans: All of the mentioned (Imaging, Graphics, Voice)
82. The tracks on a disk which can be accessed without repositioning the R/W heads is
Ans: Cylinder
83. Which will legally declare, construct and initialize an array?
Ans: int myList[]={4, 3, 7};
84.______in Java identifies and discards the objects that are no longer needed by a program so that their resources can be reclaimed and reused
Ans: Garbage Collection
85. What exception is thrown by read() method of InputStreamReader?
Ans: IOException
86. A non-correlated subquery can be defined as____
Ans: A set of one or more sequential queries in which generally the result of the inner query is used as the search value in the outer query
87. What is the fullform of WORA?
Ans: Write Once Run Anywhere
88. Is readByte() of DataInputStream final?
Ans: True
89. When three or more AND and OR conditions are combined, it is easier to use the SQL keyword(s):
Ans: Both IN and NOT IN
90. What type of exceptions can readFloat() of DataInputStream throws?
Ans: IOException
91. Arrays when passed to a method they are always passed by reference. Is this true or false?
Ans: true
92. A______file contains bytecodes
Ans: .class
93. Servlets handle multiple simultaneous requests by using threads?
Ans: True
94. In BufferedOutputStream, the method notify is inherited from:
Ans: java.lang.object
95. What will be the output of the below code:
public class Test{
public static void main(String args[])
{
String a="2";
String b="8";
System.out.println(a+b);
}
}
Ans: 28
96. A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction?
Ans: Do not declare with any accessibility modifiers
97. close() method have integer return type in BufferedReader class
Ans: false
98. Which two statements are true regarding constraints?
Ans: A column with the UNIQUE constraint can contain NULL
99. Java is a_______level programming language
Ans: high
100. Which of these classes defined in java.io and used for file-handling are abstract:
A) InputStream
B) PrintStream
C) Reader
D) FileInputStream
E) FileWriter
Ans: A and C
101. You want to calculate the sum of commissions earned by the employees of an organisation. If an employee doesn't receive any commission, it should be calculated as zero. Which will be the right query to achieve this?
Ans: select sum(nvl(commission,0))from employees
102. Which class does not override the equals() method, inheriting them directly from class object?
Ans: java.lang.StringBuffer
103.
public class Test{
public static void main(String args[]){
System.out.println(new Test().mystery("DELIVER"));}
public String mystery(String s){
String s1=s.substring(0,1);
String s2=s.substring(1,s.length()-1);
String s3=s.substring(s.length()-1);
if(s.length()<=3) return s3+s2+s1;
else
return s1+mystery(s2)+s3;
}}
What is the output of the above program?
Ans: DEVILER
104. What data type does FileReader.readLine() return?
Ans: String
105.
String s="hello";
String t=s;
t=s+"world";
System.out.println(s);
What would be the output of the above code snippet?
Ans: hello
106. A part located in the central processing unit that stores data and information is known as
Ans: Core memory
107. FileInputStream class extends_____class
Ans: InputStream
108. mark() method have void return type in BufferedReader class.
Ans: True
109. _______is a special type of integrity constraint that relates two relations and maintains consistency across the relations
Ans: Referential integrity constraints
110. BufferedWriter is_______
Ans: Class
111. FileReader class inherits from the InputStreamReader class
Ans: True
112. What are all false about ENUMS?
Ans: Enums can extend any other type
113. What is the return type of readDouble() of DataInputStream class?
Ans: double
114. What is the return type of reverse() method in StringBuffer class?
Ans: StringBuffer
115. Given request is an HttpServletRequest, which code snippets will creates a session if one doesn't exist?
Ans: request.getSession();
116. Which of these method of FileReader class is used to read characters from a file?
Ans: read()
117. Which method is used to access the cookies that are added to response object?
Ans: getCookies()
118. _________joins two or more tables based on a specified column value not equaling a specified column value in another table
Ans: NON-EQUIJOIN
Q) import java.util.*;
ReplyDeleteimport java.lang.*;
import java.io.*;
public class Exam1 {
public static void main(String[] args) {
ContractEmployee arun = new ContractEmployee();
arun.freeTime(); }
}
class Employee{
final void timeOut(){
System.out.println("Its time out zone");
}
}
class ContractEmployee extends Employee{
final void freeTime(){
timeOut();
}
} What is the output of above program? a0 its time out zone b)Code will not compile because final method cannot be invoked from a subclass c) Code will not compile because employee class is not final d) runtime error
a
Deleteclass Parent{
ReplyDeletefinal static public void display() {
System.out.println("Parent display method");
}
}
class Child extends Parent{
public void display() {
System.out.println("Parent display method");
}
}Select one or more true statements for above code 1. static method cannot be overridden by instance method. 2 Parent class final method can not be overriden in child class 3 a method can be final and static together. a) 1 alone is correct 2,3 are incorrect. b)1,2 alone is correct 3 is wrong. c) 1,2,3 are correct d) 1,2,3 are incorrect
c) all the points are correct
DeleteDetails are very simple and easy to understand..
ReplyDeleteVisit: Best Java Course
Do you have ny content on .net
ReplyDeleteThank you for sharing this powerful article, your explanation is clear and very easy to understand. Please kindly visit our site to get more information about IT solution.SEO Company in Pakistan
ReplyDelete