What will be the output of the following code snippet? Object s1 = new String("Hello"); Object s2 = new String("Hello"); if(s1 == s2) { System.out.println("s1 and s2 are =="); }else if (s1.equals(s2)) { System.out.println("s1 and s2 are equals()"); }
Correct Answer: The classloader is a subsystem of JVM that is used to load classes and interfacesThere are many types of classloaders eg Bootstrap classloader, Extension classloader, System classloader, Plugin classloader etc
2. What is the difference between method overriding and overloading?
Correct Answer: Overriding is a method with the same name and arguments as in a parent, whereas overloading is the same method name but different arguments
3. If a method is declared as protected, where may the method be accessed?
Correct Answer: A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared
4. What do you understand by private, protected and public?
Correct Answer: These are accessibility modifiers Private is the most restrictive, while public is the least restrictive There is no real difference between protected and the default type (also known as package protected) within the context of the same package, however the protected keyword allows visibility to a derived class in a different package
Correct Answer: A thread is a lightweight subprocess, a smallest unit of processing It is a separate path of execution It shares the memory area of process As shown in the above figure, thread is executed inside the process There is context-switching between the threads There can be multiple processes inside the OS and one process can have multiple threads
Correct Answer: JDBC technology is an API (included in both J2SE and J2EE releases) that provides cross-DBMS connectivity to a wide range of SQL databases and access to other tabular data sources, such as spreadsheets or flat files With a JDBC technology-enabled driver, you can connect all corporate data even in a heterogeneous environment
Correct Answer: A table of data representing a database result set, which is usually generated by executing a statement that queries the database ResultSet object maintains a cursor pointing to its current row of data Initially the cursor is positioned before the first row The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set
9. What are the different JDBC drivers available ?
Correct Answer: There are mainly four type of JDBC drivers available They are: Type 1 : JDBC-ODBC Bridge Driver - A JDBC-ODBC bridge provides JDBC API access via one or more ODBC drivers Note that some ODBC native code and in many cases native database client code must be loaded on each client machine that uses this type of driver Hence, this kind of driver is generally most appropriate when automatic installation and downloading of a Java technology application is not important For information on the JDBC-ODBC bridge driver provided by Sun Type 2: Native API Partly Java Driver- A native-API partly Java technology-enabled driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, DB2, or other DBMS Note that, like the bridge driver, this style of driver requires that some binary code be loaded on each client machine Type 3: Network protocol Driver- A net-protocol fully Java technology-enabled driver translates JDBC API calls into a DBMS-independent net protocol which is then translated to a DBMS protocol by a server This net server middleware is able to connect all of its Java technology-based clients to many different databases The specific protocol used depends on the vendor In general, this is the most flexible JDBC API alternative It is likely that all vendors of this solution will provide products suitable for Intranet use In order for these products to also support Internet access they must handle the additional requirements for security, access through firewalls, etc, that the Web imposes Several vendors are adding JDBC technology-based drivers to their existing database middleware products Type 4: JDBC Net pure Java Driver - A native-protocol fully Java technology-enabled driver converts JDBC technology calls into the network protocol used by DBMSs directly This allows a direct call from the client machine to the DBMS server and is a practical solution for Intranet access Since many of these protocols are proprietary the database vendors themselves will be the primary source for this style of driver Several database vendors have these in progress
Correct Answer: No The JDBC-ODBC Bridge does not support multi threading The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC Multi-threaded Java programs may use the Bridge, but they won't get the advantages of multi-threading