JAVA
Question 1 |
Which of these is a super class of all errors and exceptions in the Java language?
Runtime Exceptions | |
Throwable | |
Catchable | |
None of the above |
Question 1 Explanation:
The Throwable class is the superclass of all errors and exceptions in the Java language.
Question 2 |
Type 4 JDBC driver is a driver
which is written in C++ | |
which requires an intermediate layer | |
which communicates through Java sockets | |
which translates JDBC function calls into API not native to DBMS |
Question 2 Explanation:
The JDBC type 4 driver, also known as the Direct to Database Pure Java Driver, is a database driver implementation that converts JDBC calls directly into a vendor-specific database protocol.
Written completely in Java, type 4 drivers are thus platform independent. They install inside the Java Virtual Machine of the client. This provides better performance than the type 1 and type 2 drivers as it does not have the overhead of conversion of calls into ODBC or database API calls. Unlike the type 3 drivers, it does not need associated software to work.
As the database protocol is vendor specific, the JDBC client requires separate drivers, usually vendor supplied, to connect to different types of databases.
Advantages Completely implemented in Java to achieve platform independence.
These drivers don't translate the requests into an intermediary format (such as ODBC).
The client application connects directly to the database server. No translation or middleware layers are used, improving performance.
The JVM can manage all aspects of the application-to-database connection; this can facilitate debugging.
Disadvantages Drivers are database specific, as different database vendors use widely different (and usually proprietary) network protocols.

Type-1 driver (or) JDBC-ODBC bridge driver
Type-2 driver (or) Native-API driver
Type-3 driver (or) Network Protocol driver
Type-4 driver (or) Thin driver
Written completely in Java, type 4 drivers are thus platform independent. They install inside the Java Virtual Machine of the client. This provides better performance than the type 1 and type 2 drivers as it does not have the overhead of conversion of calls into ODBC or database API calls. Unlike the type 3 drivers, it does not need associated software to work.
As the database protocol is vendor specific, the JDBC client requires separate drivers, usually vendor supplied, to connect to different types of databases.
Advantages Completely implemented in Java to achieve platform independence.
These drivers don't translate the requests into an intermediary format (such as ODBC).
The client application connects directly to the database server. No translation or middleware layers are used, improving performance.
The JVM can manage all aspects of the application-to-database connection; this can facilitate debugging.
Disadvantages Drivers are database specific, as different database vendors use widely different (and usually proprietary) network protocols.

Type-1 driver (or) JDBC-ODBC bridge driver
Type-2 driver (or) Native-API driver
Type-3 driver (or) Network Protocol driver
Type-4 driver (or) Thin driver
Question 3 |
Consider the following Java code fragment:
1 public class While
2 {
3 public void loop()
4 {
5 int x = 0;
6 while(1)
7 {
8 System.out.println("x plus one is" +(x+1));
9 }
10 }
11 }
1 public class While
2 {
3 public void loop()
4 {
5 int x = 0;
6 while(1)
7 {
8 System.out.println("x plus one is" +(x+1));
9 }
10 }
11 }
There is syntax error in line no. 1 | |
There is syntax errors in line nos. 1 & 6 | |
There is syntax error in line no. 8 | |
There is syntax error in line no. 6 |
Question 3 Explanation:
Java does not - unlike C - interpret 0 as false and 1 as true.
So we cannot use integers in the while() statement.
So line number 6 will give syntax error.
So we cannot use integers in the while() statement.
So line number 6 will give syntax error.
Question 4 |
What is the output of the following JAVA program ?
class simple { public static void main(String[] args) { simple obj = new simple(); obj.start(); } void start() { long [] P = {3, 4, 5}; long [] Q = method (P); System.out.print (P[0] + P[1] + P[2]+”:”); System.out.print (Q[0] + Q[1] + Q[2]); } long [] method (long [] R) { R [1] = 7; return R; } } //end of class
12 : 15 | |
15 : 12 | |
12 : 12 | |
15 : 15 |
Question 4 Explanation:
• First we will create the object of simple class.
• By using object , we call the function start( ).
• In the start() function definition, first statement is integer array with three elements.
• long [ ] Q= method (P); Again function method(p) will be called.
• In the definition of method function, we are changing the second element of array to value 7 and returning updated array to array Q.
• We are passing address of P as argument to method so Modifications happened in the method automatically reflects to array P.
• Both array P and Q consists of values {3,7,5}.
• The sum of the three values are 15.
• By using object , we call the function start( ).
• In the start() function definition, first statement is integer array with three elements.
• long [ ] Q= method (P); Again function method(p) will be called.
• In the definition of method function, we are changing the second element of array to value 7 and returning updated array to array Q.
• We are passing address of P as argument to method so Modifications happened in the method automatically reflects to array P.
• Both array P and Q consists of values {3,7,5}.
• The sum of the three values are 15.
Question 5 |
In Java, which of the following statements is/are True ?
-
S1 : The ‘final’ keyword applied to a class definition prevents the class from being extended through derivation.
S2 : A class can only inherit one class but can implement multiple interfaces.
S3 : Java permits a class to replace the implementation of a method that it has inherited. It is called method overloading.
S1 and S2 only | |
S1 and S3 only | |
S2 and S3 only | |
All of S1, S2 and S3
|
Question 5 Explanation:
• If a class has multiple methods having same name but different in parameters, it is known as Method Overloading.Method Overloading is a feature that allows a class to have more than one method having the same name, if their argument lists are different. So the option-3 is False.
• The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be: variable, method and class.
• A Java class can only extend one parent class. Multiple inheritance (extends) is not allowed. Interfaces are not classes. However, and a class can implement more than one interface.
• The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be: variable, method and class.
• A Java class can only extend one parent class. Multiple inheritance (extends) is not allowed. Interfaces are not classes. However, and a class can implement more than one interface.
Question 6 |
Which of the following statements is/are True ?
P : C programming language has a weak type system with static types. Q : Java programming language has a strong type system with static types. Code :P only | |
Q only | |
Both P and Q | |
Neither P nor Q
|
Question 6 Explanation:
→ A strongly typed language has stricter typing rules at compile time, which implies that errors and exceptions are more likely to happen during compilation. Most of these rules affect variable assignment, return values and function calling.
→ A weakly typed language has looser typing rules and may produce unpredictable results or may perform implicit type conversion at runtime.
→ Java, C#, Ada and Pascal are sometimes said to be more strongly typed than C, a claim that is probably based on the fact that C supports more kinds of implicit conversions, and C also allows pointer values to be explicitly cast while Java and Pascal do not.
→ Java itself may be considered more strongly typed than Pascal as manners of evading the static type system in Java are controlled by the Java virtual machine's type system.
→ C# and VB.NET are similar to Java in that respect, though they allow disabling of dynamic type checking by explicitly putting code segments in an "unsafe context".
→ Pascal's type system has been described as "too strong", because the size of an array or string is part of its type, making some programming tasks very difficult.
→ A weakly typed language has looser typing rules and may produce unpredictable results or may perform implicit type conversion at runtime.
→ Java, C#, Ada and Pascal are sometimes said to be more strongly typed than C, a claim that is probably based on the fact that C supports more kinds of implicit conversions, and C also allows pointer values to be explicitly cast while Java and Pascal do not.
→ Java itself may be considered more strongly typed than Pascal as manners of evading the static type system in Java are controlled by the Java virtual machine's type system.
→ C# and VB.NET are similar to Java in that respect, though they allow disabling of dynamic type checking by explicitly putting code segments in an "unsafe context".
→ Pascal's type system has been described as "too strong", because the size of an array or string is part of its type, making some programming tasks very difficult.
Question 7 |
Consider the following Java code segment:
Public class while /*line1*/
{
Public void loop()
{
int x=0;
while(1) /*line 6*/
{
system.out.println(“x plus one is”+(x+1));
}
}
}
Which of the following is true?
Public class while /*line1*/
{
Public void loop()
{
int x=0;
while(1) /*line 6*/
{
system.out.println(“x plus one is”+(x+1));
}
}
}
Which of the following is true?
There is a syntax error in line -1
| |
There are syntax errors in,line -1 and line -6 | |
There is a syntax error in line -6 | |
No syntax error |
Question 7 Explanation:
We can’t used the keyword “while” as class name.So it will give syntax error.
Question 8 |
Parent class of all java classes is____
Java.lang.system
| |
Java.lang.object | |
Java.lang.class | |
Java.lang,reflect.object |
Question 8 Explanation:
public class Object:
Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.
Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.
Question 9 |
Which of the following java statement declare and allocate a 2-dimensional array integers with four rows and five columns?
int array[ ] [ ]=new int [5][4]; | |
int array [4][5]; | |
int array[5][4]; | |
int array[ ] [ ]=new int[4][5]; |
Question 9 Explanation:
→ In question they are clearly mentioned that 4 rows and 5 columns.
→ Syntax int array[ ] [ ]=new int[row size][column size];
(or)
int[ ] [ ] array=new int[row size][column size];
So, Option D is correct answer.
→ Syntax int array[ ] [ ]=new int[row size][column size];
(or)
int[ ] [ ] array=new int[row size][column size];
So, Option D is correct answer.
There are 9 questions to complete.