Java
Java
Java
1. ODBC Ans. Open Database Connectivity. 2. HTML Ans. Hyper Text Markup Language 3. RISC Ans. Reduced Instruction Set Computing 4. ASCII Ans. American Standard Code For Information Interchange 5. ANSI Ans. American National Standard Institute. 6. XML Ans. Extended Markup Language 7. FLOPS Ans. Floating Point Operating Per Second 8. SQL Ans. Sequential Query Language 9. QBE Ans. Query By Example 10. ALE Ans. Address Latch Enable 12. RPC Remote procedure call 11. What is lagging in DBMS? Ans. Reduced Redundancy. What is JAVA ? Java is a pure object oriented programming language, which has derived C syntax and C++ object oriented programming features. Is a compiled and interpreted language and is platform independent and Can do graphics, networking, multithreading. It was initially called as OAK. What are the four cornerstones of OOP ? Abstraction : Can manage complexity through abstraction. Gives the complete overview of a particular task and the details are handled by its derived classes. Ex : Car. Encapsulation : Nothing but data hiding, like the variables declared under private of a particular class are accessed only in that class and cannot access in any other the class. Inheritance : Is the process in which one object acquires the properties of another object, ie., derived object. Polymorphism : One method different forms, ie., method overriding and interfaces are the examples of polymorphism. what is downcasting ? Doing a cast from a base class to a more specific class. The cast does not convert the object, just asserts it actually is a more specific extended object.
e.g. Dalamatian d = (Dalmatian) aDog; Most people will stare blankly at you if you use the word downcast. Just use cast. What is Java Interpreter ? It is Java Virtual Machine. ie., a java program compiles the Unicode to intermediary code called as Bytecode which is not an executable code. that is executed by Java interpreter.
What are Java Buzzwords ? Simple : Easy to learn. Secure : Provided by firewalls between networked applications. Portable : Can be dynamically downloaded at various platforms connect to internet. OOP : Four Corner stones. Multithread : Can perform more than one task concurrently in a single program. Robust : overcomes problems of de-allocation of memory and exceptions. Interpreted : Convert into byte code and the executes by JVM. Distributed : Concept of RMI. Dynamic : Verifying and accessing objects at run time.
What are public static void main(String args[]) and System.out.println() ? Public keyword is an access specifier. Static allows main() to be called without having to instantiate a particular instance of class. Void does not return any value. main() is the method where java application begins. String args[] receives any command line arguments during runtime. System is a predefined class that provides access to the system. out is output stream connected to console.
println displays the output. What are identifiers and literals ? Identifiers are the variables that are declared under particular datatype. Literals are the values assigned to the Identifiers.
What is Typed language ? This means that the variables are at first must be declared by a particular datatype whereas this is not the case with javascript. Scope and lifetime of variables ? scope of variables is only to that particular block lifetime will be till the block ends. variables declared above the block within the class are valid to that inner block also. Casting Incompatible types ? Can be done either implicitly and explicitly. ie., int b = (int) c; where c is float. There are two types of castings related to classes : 1) unicast and 2)multicast. Declaration of Arrays ? int a[] = new int[10];
What does String define ? String is an array of characters, but in java it defines an object. and the variable of type string can be assigned to another variable of type String. What r bitwise operators and bitwise logical operators ? ~, &, |, ^, >>, >>>, <<, &=, != and ~, &, | How do you define break and Label ? We can declare as break <label name > and the label is declared as <label name> : { .. };
The break statement can be declared anywhere in the program ie either inside the label or outside the label. Define class ? A class is a one which defines new datatype, and is template of an object, and is a prototype. Types of Constructors ? Default Constructor, Parameterized Constructor, Copy Constructors Garbage collector takes the responsibility releasing the memory of object implicitly. Define this, finalize, and final(for variables, methods, classes) ? this is used inside any method to refer to the current object and is mostly avoided. finalize method is used to perform the actions specified in this method just before an object is destroyed. ie just before garbage collector process. final with variables is we cant change the literals of the variables i.e. nothing but const. final with method means we cant override that method. Final with class means we cannot have derived classes of that particular class. What is passed by reference ? Objects are passed by reference. In java we can create an object pointing to a particular location ie NULL location by specifying : <class name> <object name>; and also can create object that allocates space for the variables declared in that particular class by specifying : <object name > = new <class name>(); Explain about Static ? When a member is declared as static it can be accessed before any objects of its class are created and without any reference to any object. these are global variables, no copy of these variables can be made. static can also be declared for methods. and cannot refer to this or super. What r nested classes ? There are two types : static and non-static.
static class means the members in its enclosing class (class within class) can be accessed by creating an object and cannot be accessed directly without creating the object. non-static class means inner class and can be accessed directly with the object created for the outer class no need to create again an object like static class. Briefly about super() ? This is used to initialize constructor of base class from the derived class and also access the variables of base class like super.i = 10. Method overloading: same method name with different arguments. Method overriding: same method name and same number of arguments. What is Dynamic Method Dispatch ? this is the mechanism by which a call to an overridden function is resolved at runtime rather than at compile time. And this is how Java implements runtime polymorphism. What r abstract classes? To create a superclass that only defines generalized form that will be shared by all its subclasses, leaving it to each subclass to fill in the details. we cannot declare abstract constructors and abstract static methods. An abstract class contains at least one abstract method. And this abstract class is not directly instantiated with new operator. Can create a reference to abstract class and can be point to subclass object. What is Object class and java.lang ? Object class is the superclass of all the classes and means that reference variable of type object can refer to an object of any other class. and also defines methods like finalise,wait. java.lang contains all the basic language functions and is imported in all the programs implicitly. What r packages and why ? how to execute a program in a package ? Package is a set of classes, which can be accessed by themselves and cannot be accessed outside the package. and can be defined as package <pkg name>.
Package name and the directory name must be the same. And the execution of programs in package is done by : java mypack.account where mypack is directory name and account is program name. What does a java source file can contain ? specifying package name. importing more than one package specifying classes and there methods Why interface and what extends what ? Interface is similar to abstract classes. this define only method declarations and definitions are specified in the classes which implements these interfaces. and one interface multiple methods signifies the polymorphism concept. Here an interface can extend another interface. and a class implements more than one interface. How Exception handling is done in Java ? Is managed via 5 keywords : try : statements that you want to monitor the exceptions contain in try block. catch : the exception thrown by try is catched by this. throw : to manually throw exception we go for this. throws : Exception that is thrown out of a method must be specified by throws after the method declaration. finally : this block is executed whether or not an exception is thrown. and also it is executed just before the method returns. and this is optional block. What r checked and unchecked Exceptions ? * Unchecked Exceptions are those which r not included in throws list and are derived from RuntimeException which are automatically available and are in java.lang. * Checked Exceptions are those which cannot handle by itself. What is Thread and multithread ? How is thread created ?
Thread is a small unit of dispatchable code. ie., a single program can perform more than one task simultaneously. This is a light weight process and is of low cost. MultiThreading writes more efficient programs and make maximum use of CPU ie., it minimizes its idle time. A Thread is created in two ways : By implementing the runnable interface. By extending the Thread class itself. First way is used to update only run() method. ie we can use only run() method in this class. Second way is used to define several methods overridden by derived class. Generally we override only run() method so we go for runnable interface. What are the various states and methods of thread ? States : Running, Ready to run, Suspended, Resumed, blocked and terminated. Methods : getName, getPriority, isAlive, join, run, sleep, start. Thread priorities are MIN_PRIORITY, MAX_PRIORITY, NORM_PRIORITY. What is interprocess synchronization ? ( also called Monitor, Semaphore ) Consider a small box namely MONITOR that can hold only one thread. Once a thread enters a monitor, all other threads must wait until that thread exits the monitor. In this way, a monitor can be used to protect a shared asset from being manipulated by more than one thread at a time. Once a thread is inside a synchronized method, no other thread can call any other synchronized method on the same object. What is Stream ? It is an Abstraction that either produces or consumes information. Two types : Byte Stream and Character Stream. Print Writer is to Print output in Real World Programs. How to enter data in java ? First specify :
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); then say br.read(), and this is put in do while loop to receive as many as we require. Define Inline Functions ? In ordinary functions, during the program execution, at any function call the controller jumps to the function definition, performs operation and returns the value, then comes back to the program. whereas in Inline functions the controller copies the complete function definition into the program and performs operations. What are the four components in URL ? http:// www. yahoo .com : 8080 / index.html http: --- > is protocol www. yahoo .com --- is IP address 8080 -- port number and is a pointer to memory location. index.html -- file path to be loaded What is a StringTokenizer ? String Tokenizer provide parsing process in which it identifies the delimiters provided by the user , by default delimiters are spaces, tab, newline etc. and separates them from the tokens. Tokens are those which are separated by delimiters. What are macros and Inline functions ? Which is best and Difference ? Inline functions do Parameter passing, where as Macros do Text Substitution. Its better to go for Inline functions than macros, else you may get different results. How to Declare a pointer to function ? int func_name(float) //ordinary declaration of function. int (*func_name_ptr)(float) // Declaration of pointer. Assigning the Address can be done as : func_name_ptr = func_name. // Return type and Signatures must be Same.
int x = (*func_name_ptr)(values as
What is a file ? What is a Directory ? File : Describes the properties of file, like permissions, time, date, directory path, and to navigate subdirectory hierarchies. Directory : Is a file that contains list of other files and directories . What is Serialization ? The process of writing the state of an object to a byte stream. and can restore these objects by using deserialization. Is also need to implement RMI, which allows a java object of one machine to invoke java object of another machine. ie., the object is passed as an argument by serializing it and the receiving machine deserializes it.
Interfaces include by java.lang ? Java.lang is the package of all the classes. And is automatically imported into all Java programs. Intefaces : Cloneable, Comparable,
Runnable.
What is user defined exception? To handle situations specific to our applications we go for User Defined Exceptions. and are defined by User using throw keyword. What is the difference between process and threads? Process is a heavy weight task and is more cost. Thread is a light weight task which is of low cost. A Program can contain more than one thread. A program under execution is called as process. What is the difference between CGI and Servlet ? CGI suffered serious performance problems. servlets performance is better. CGI create separate process to handle client request. and Servlets do not.
CGI is platform dependent, whereas Servlet is platform-independent bcauz written in java. Servlets can communicate with applets, databases and RMI mechanisms. What is update method called? This method is called when your Applet has requested that a portion of its window to be redrawn. Default version of update() first fills an applet with the default background color and then calls paint(); This is a default method in the applet class to which we can extend it. What are Vector, Hashtable, LinkedList and Enumeration? Vector : The Vector class provides the capability to implement a growable array of objects. Hashtable : The Hashtable class implements a Hashtable data structure. A Hashtable indexes and stores objects in a dictionary using hash codes as the object's keys. Hash codes are integer values that identify objects. LinkedList: Removing or inserting elements in the middle of an array can be done using LinkedList. A LinkedList stores each object in a separate link whereas an array stores object references in consecutive locations. Enumeration: An object that implements the Enumeration interface generates a series of elements, one at a time. It has two methods, namely hasMoreElements( ) and nextElement( ). HasMoreElemnts( ) tests if this enumeration has more elements and nextElement method returns successive elements of the series. What are statements in Java (JDBC) ? Statement -- To be used createStatement() method for executing single SQL statement PreparedStatement -- To be used preparedStatement() method for executing same SQL statement over and over CallableStatement -- To be used prepareCall( ) method for multiple SQL statements over and over. What is a JAR file? Jar file allows to efficiently deploying a set of classes and their associated resources. The elements in a jar file are compressed, which
makes downloading a Jar file much faster than separately downloading several uncompressed files. The package java.util.zip contains classes that read and write jar files. What is JNI? java native interface : The machanism to integrate C code with a java program is called the Java Native Interface. What is the base class for all swing components? Jcomponent What is JFC? java foundation classes (i) Pluggable Look-and-Feel (ii) Accessibility API (iii) Java 2D/API(JDK 1.2). (iv) Drag and Drop Support(JDK 1.2)
Canvas
Its a component A rectangular area where the application and vertical can draw or trap input events.
ScrollPane
Its a container. Implements horizontal scrolling.
72) What is the difference between JDBC and ODBC? a) OBDC is for Microsoft and JDBC is for Java applications. b) ODBC can't be directly used with Java because it uses a C interface. c) ODBC makes use of pointers which have been removed totally from Java. d) ODBC mixes simple and advanced features together and has complex options for simple queries. But JDBC is designed to keep things simple while allowing advanced capabilities when required. e) ODBC requires manual installation of the ODBC driver manager and driver on all client machines. JDBC drivers are written in Java and JDBC code is automatically installable, secure, and portable on all platforms. f) JDBC API is a natural Java interface and is built on ODBC. JDBC retains some of the basic features of ODBC. 73) What are the types of JDBC Driver Models and explain them?
Two tier model: In this model, Java applications interact directly with the database. A JDBC driver is required to communicate with the particular database management system that is being accessed. SQL statements are sent to the database and the results are given to user. This model is referred to as client/server configuration where user is the client and the machine that has the database is called as the server. Three tier model: A middle tier is introduced in this model. The functions of this model are: a) Collection of SQL statements from the client and handing it over to the database, b) Receiving results from database to the client and c) Maintaining control over accessing and updating of the above. 74) What are the steps involved for making a connection with a database or how do you connect to a database? a) Loading the driver : To load the driver, Class.forName( ) method is used. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); When the driver is loaded, it registers itself with the java.sql.DriverManager class as an available database driver. b) Making a connection with database : To open a connection to a given database, DriverManager.getConnection( ) method is used. Connection con = DriverManager.getConnection ("jdbc:odbc:somedb", "user", "password"); c) Executing SQL statements : To execute a SQL query, java.sql.statements class is used. createStatement( ) method of Connection to obtain a new Statement object. Statement stmt = con.createStatement( ); A query that returns data can be executed using the executeQuery( ) method of Statement. This method executes the statement and returns a java.sql.ResultSet that encapsulates the retrieved data: ResultSet rs = stmt.executeQuery("SELECT * FROM some table"); d) Process the results : ResultSet returns one row at a time. Next( ) method of ResultSet object can be called to move to the next row. The getString( ) and getObject( ) methods are used for retrieving column values:
while(rs.next( ) ) {
String event =
77) What is stored procedure? Ans: Stored procedure is a group of SQL statements that forms a logical unit and performs a particular task. Stored Procedures are used to encapsulate a set of operations or queries to execute on database. Stored procedures can be compiled and executed with different parameters and results and may have any combination of input/output parameters. 78) How to create and call stored procedures? Ans: To create stored procedures: Create procedure procedurename (specify in, out and in out parameters) BEGIN Any multiple SQL statement; END; To call stored procedures: CallableStatement csmt = con.prepareCall("{call procedure name(?,?)}"); csmt.registerOutParameter(column no., data type); csmt.setInt(column no., column name) csmt.execute( ); 79) What is servlet? Ans: Servlets are modules that extend request/response-oriented servers, such as java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to update a company's order database. 81) What is the difference between an applet and a servlet? Servlets are to servers what applets are to browsers. Applets must have graphical user interfaces whereas servlets have no graphical user interfaces. 82) What is the difference between doPost and doGet methods?
a) doGet() method is used to get information, while doPost( ) method is used for posting information. b) doGet() requests can't send large amount of information and is limited to 240-255 characters. However, doPost( )requests passes all of its data, of unlimited length. c) A doGet( ) request is appended to the request URL in a query string and this allows the exchange is visible to the client, whereas a doPost() request passes directly over the socket connection as part of its HTTP request body and the exchange are invisible to the client. 83) What is the life cycle of a servlet? Ans: Each Servlet has the same life cycle: a) A server loads and initializes the servlet by init () method. b) The servlet handles zero or more client's requests through service( ) method. c) The server removes the servlet through destroy() method. 84) Who is loading the init() method of servlet? Ans: Web server 85) What are the different servers available for developing and deploying Servlets? Ans: a) Java Web Server b) JRun g) Apache Server h) Netscape Information Server i) Web Logic 86) How many ways can we track client and what are they? Ans: The servlet API provides two ways to track client state and they are: a) Using Session tracking and b) Using Cookies. 90) Is it possible to communicate from an applet to servlet and how many ways and how? Ans: Yes, there are three ways to communicate from an applet to servlet and they are: a) HTTP Communication(Text-based and object-based) b) Socket Communication
c)
RMI Communication
Steps involved for applet-servlet communication: 1) Get the server URL. URL url = new URL(); 2) Connect to the host URLConnection Con = url.openConnection(); 3) Initialize the connection Con.setUseCatches(false): Con.setDoOutput(true); Con.setDoInput(true); 4) Data will be written to a byte array buffer so that we can tell the server the length of the data. ByteArrayOutputStream byteout = new ByteArrayOutputStream(); 5) Create the OutputStream to be used to write the data to the buffer. DataOutputStream out = new DataOutputStream(byteout); 91) What is connection pooling? Ans: With servlets, opening a database connection is a major bottleneck because we are creating and tearing down a new connection for every page request and the time taken to create connection will be more. Creating a connection pool is an ideal approach for a complicated servlet. With a connection pool, we can duplicate only the resources we need to duplicate rather than the entire servlet. A connection pool can also intelligently manage the size of the pool and make sure each connection remains valid. A number of connection pool packages are currently available. Some like DbConnectionBroker are freely available from Java Exchange Works by creating an object that dispenses connections and connection Ids on request. The ConnectionPool class maintains a Hastable, using Connection objects as keys and Boolean values as stored values. The Boolean value indicates whether a connection is in use or not. A program calls getConnection( ) method of the ConnectionPool for getting Connection object it can use; it calls returnConnection( ) to give the connection back to the pool. 92) Why should we go for interservlet communication? Servlets running together in the same server communicate with each other in several ways.
The three major reasons to use interservlet communication are: a) Direct servlet manipulation - allows to gain access to the other currently loaded servlets and perform certain tasks (through the ServletContext object) b) Servlet reuse - allows the servlet to reuse the public methods of another servlet. c) Servlet collaboration - requires to communicate with each other by sharing specific information (through method invocation) 93) Is it possible to call servlet with parameters in the URL? Ans: Yes. You can call a servlet with parameters in the syntax as (?Param1 = xxx || m2 = yyy). 94) What is Servlet chaining? Servlet chaining is a technique in which two or more servlets can cooperate in servicing a single request. In servlet chaining, one servlet's output is piped to the next servlet's input. This process continues until the last servlet is reached. Its output is then sent back to the client. 95) How do servlets handle multiple simultaneous requests? The server has multiple threads that are available to handle requests. When a request comes in, it is assigned to a thread, which calls a service method (for example: doGet(), doPost( ) and service( ) ) of the servlet. For this reason, a single servlet object can have its service methods called by many threads at once. 96) What is the difference between TCP/IP and UDP? Ans: TCP/IP is a two-way communication between the client and the server and it is a reliable and there is a confirmation regarding reaching the message to the destination. It is like a phone call. UDP is a one-way communication only between the client and the server and it is not a reliable and there is no confirmation regarding reaching the message to the destination. It is like a postal mail. 97) What is Inet address? Ans: Every computer connected to a network has an IP address. An IP address is a number that uniquely identifies each computer on the Net. An IP address is a 32-bit number.
98) What is Domain Naming Service(DNS)? Ans: It is very difficult to remember a set of numbers(IP address) to connect to the Internet. The Domain Naming Service(DNS) is used to overcome this problem. It maps one particular IP address to a string of characters. For example, www.mascom.com implies com is the domain name reserved for US commercial sites, moscom is the name of the company and www is the name of the specific computer, which is mascom's server. 99) What is URL? Ans: URL stands for Uniform Resource Locator and it points to resource files on the Internet. URL has four components: http://www.Pentafour.com:80/index.html http - protocol name, Pentafour - IP address or host name, 80 - port number and index.html - file path. 100) What is RMI and steps involved in developing an RMI object? Ans: Remote Method Invocation (RMI) allows java object that executes on one machine and to invoke the method of a Java object to execute on another machine. The steps involved in developing an RMI object are: a) Define the interfaces b) Implementing these interfaces c) Compile the interfaces and their implementations with the java compiler d) Compile the server implementation with RMI compiler e) Run the RMI registry f) Run the application 101) What is RMI architecture? a) Application layer ---- contains the actual object definition b) Proxy layer ---- consists of stub and skeleton c) Remote Reference layer ---- gets the stream of bytes from the transport layer and sends it to the proxy layer d) Transportation layer ---- responsible for handling the actual machine-to-machine communication
102) what is UnicastRemoteObject? Ans: All remote objects must extend UnicastRemoteObject, which provides functionality that is needed to make objects available from remote machines.
103) Explain the methods, rebind( ) and lookup() in Naming class? Ans: rebind( ) of the Naming class(found in java.rmi) is used to update the RMI registry on the server machine. Naming. rebind("AddSever", AddServerImpl); lookup( ) of the Naming class accepts one argument, the rmi URL and returns a reference to an object of type AddServerImpl. 104) What is a Java Bean? Ans: A Java Bean is a software component that has been designed to be reusable in a variety of different environments. 106) What is BDK? Ans: BDK, Bean Development Kit is a tool that enables to create, configure and connect a set of set of Beans and it can be used to test Beans without writing a code. 107) What is JSP? Ans: JSP is a dynamic scripting capability for web pages that allows Java as well as a few special tags to be embedded into a web file (HTML/XML, etc). The suffix traditionally ends with .jsp to indicate to the web server that the file is a JSP files. JSP is a server side technology - you can't do any client side validation with it. The advantages are: a) The JSP assists in making the HTML more functional. Servlets on the other hand allow outputting of HTML but it is a tedious process. b) It is easy to make a change and then let the JSP capability of the web server you are using deal with compiling it into a servlet and running it. 108) What are JSP scripting elements? Ans: JSP scripting elements lets to insert Java code into the servlet that will be generated from the current JSP page. There are three forms:
a) Expressions of the form <%= expression %> that are evaluated and inserted into the output, b) Scriptlets of the form <% code %> that are inserted into the servlet's service method, and c) Declarations of the form <%! Code %> that are inserted into the body of the servlet class, outside of any existing methods. 109) What are JSP Directives? Ans: A JSP directive affects the overall structure of the servlet class. It usually has the following form: <%@ directive attribute="value" %> However, you can also combine multiple attribute settings for a single directive, as follows: <%@ directive attribute1="value1" attribute 2="value2" ... attributeN ="valueN" %> There are two main types of directive: page, which lets to do things like import classes, customize the servlet superclass, and the like; and include, which lets to insert a file into the servlet class at the time the JSP file is translated into a servlet 110) What are Predefined variables or implicit objects? Ans: To simplify code in JSP expressions and scriptlets, we can use eight automatically defined variables, sometimes called implicit objects. They are request, response, out, session, application, config, pageContext, and page.
5. What is Bootstrapping in RMI? Dynamic loading of stubs and skeletons is known as Boot Strapping. 6. What are different types of Exceptions?. Runtime exceptions, Errors, Program Exceptions 9. What is servlet tunnelling?. Used in applet to servlet communications, a layer over http is built so as to enable object serialization. 11.What is the frontend in Java?.Also what is Backend?. Frontend: Applet Backend : Oracle, Ms-Access(Using JDBC).
25. Which of the following attributes are compulsory with an <applet> tag?. code,height & width. 26. What does 'CODEBASE' in an applet tag specify?. Files absolute path. Access Modifiers: Which gives additional meaning to data, methods and classes. 28. Tools provided by JDK (i) javac - compiler (ii) java - interpretor (iii) jdb - debugger (iv) javap - Disassembles (v) appletviewer - Applets (vi) javadoc - documentation generator (vii) javah - 'C' header file generator 29.Hostile Applets:Its an applet which when downloaded attempts to exploit your system's resources in an inappropriate manner.It performs or causes you to perform an action which you would not otherwise care to perform. 30.RemoteObjects: Objects that have methods that can be called accross virtual machines are Remote Objects.An object becomes Remote by implementing Remote Interface. 31.Compiling: Conversion of Programmer-readable Text Bytecodes,which are platform independent,is known as Compiling. into
32.Java Primitive Data Types: Byte-8-bit, short-16-bit, int-32-bit, Long-64-bit, Float-32-bit floating point, Double-64-bit floating point, Char-16-bit Unicode 33.What is a unicode? Unicode is a standard that supports International Characters.
34. What are blocks?. They are statements appearing within braces {}. 35. What are types of Java applications?. (i) Standalone applications(No browser). (ii) Applets(Browser). 36. What is the method that gets invoked first in a stand alone application?. The main()method. 37. What is throwing an Exception?. The act of passing an Exception Object to the runtime system is called Throwing an Exception. 38. What are the packages in JDK?. There are 8 packages (i) java.lang(ii)java.util(iii)java.io(iv)java.applet(v) java.awt (vi) java.awt.image(vii)java.awt.peer(viii)java.awt.net 40. What is runnable?. Its an Interface through which Java implements Threads.The class can extend from any class but if it implements Runnable,Threads can be used in that particular application. 41. What is preemptive and Non-preemptive Time Scheduling?. Preemptive: Running tasks are given small portions of time to execute by using time-slicing. Non-Preemptive: One task doesn't give another task a chance to run until its finished or has normally yielded its time. 42. What is synchronization?. Two or more threads trying to access the same method at the same point of time leads to synchronization.If that particular method is declared as synchronized only one thread can access it at a time. Another thread can access it only if the first thread's task is complete. 47.executeQuery() returns ResultSet.
48.Throwable class is a sub-class of object and implements Serializable. 50. Skeletons are server side proxies and stubs are client side proxies. True 52. Netscape introduced JScript language - True 53. EventDelegation model was introduced by JDK 1.1 - False 54. StringTokenizer provides two constructors - False 55. java.applet is one of the smallest package in Java API - True
57. What is IP?. IP is Internet Protocol. It is the network protocol which is used to send information from one computer to another over the network over the internet in the form of packets. MIME(Multipurpose Internet Mail Extension) is a general method by which the content of different types of Internet objects can be identified. 61. What is an abstract class?. A class which cannot be Instantiated. 63.How many standard ports are available?. 1024. 65. What are different ways of Session-Tracking?. (i) User-Authorization (ii) Hidden Files (iii) Persistant Cookies (iv) URL Rewriting. 67. What is a Swing?. It is a GUI component with a plug gable look and feel. 68. What is default Look-and-Feel of a Swing Component?.
Java Look-and-Feel. 69. Awt Components and Swing Components can be inter-mingled in an Application - False 71. What does x mean in javax.swing?. Extension of java.
72. Images can be displayed on Swing Components - True 73. Borders can be changed or added for a LightWeight Components 74. Swing Components are always rectangular - False - True
75. When Swing components overlap with Heavyweight components, it is the latter that is on the top - True 77. What are invisible components?. They are light weight components that perform no painting, but can take space in the GUI. 79. What are the borders provided by Swing?. (i) Simple (ii) Matte iii) Titled 83. What is the superclass of exception?.
86. What are the restrictions imposed by a Security Manager on Applets?. i) cannot read or write files on the host that's executing it. ii) cannot load libraries or define native methods. iii) cannot make network connections except to the host that it came from iv) cannot start any program on the host that's executing it. v) cannot read certain system properties. vi) windows that an applet brings up look different than windows that an application brings up. 2)what is the difference between Procedural and OOPs?
Ans: a) In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOPs program, unit of program is object, which is nothing but combination of data and code. b) In procedural program,data is exposed to the whole program whereas in OOPs program,it is accessible within the object and which in turn assures the security of the code. 4)What is the difference between Assignment and Initialization? Ans: Assignment can be done as many times as desired whereas initialization can be done only once. 5)What are Class, Constructor and Primitive data types? Ans: Class is a template for multiple objects with similar features and it is a blue print for objects. It defines a type of object according to the data the object can hold and the operations the object can perform. Constructor is a special kind of method that determines how an object is initialized when created. Primitive data types are 8 types and they are: byte, short, int, long float, double boolean char 6)What is an Object and how do you allocate memory to it? Ans: Object is an instance of a class and it is a software unit that combines a structured set of data with a set of operations for inspecting and manipulating that data. When an object is created using new operator, memory is allocated to it. 7)What is the difference between constructor and method? Ans: Constructor will be automatically invoked when an object is created whereas method has to be called explicitly. 8)What are methods and how are they defined?
Ans: Methods are functions that operate on instances of classes in which they are defined. Objects can communicate with each other using methods and can call methods in other classes. Method definition has four parts. They are name of the method, type of object or primitive type the method returns, a list of parameters and the body of the method. A method's signature is a combination of the first three parts mentioned above. 9)What is the use of bin and lib in JDK? Ans: Bin contains all tools such as javac, appletviewer, awt tool, etc., whereas lib contains API and all packages. 10)What is casting? Ans: Casting is used to convert the value of one type to another. 12)What is the difference between an argument and a parameter? Ans: While defining method, variables passed in the method are called parameters. While using those methods, values passed to those variables are called arguments. 16)What is Garbage Collection and how to call it explicitly? Ans: When an object is no longer referred to by any variable, java automatically reclaims memory used by that object. This is known as garbage collection. System.gc() method may be used to call it explicitly. 17)What is finalize() method ? Ans: finalize () method is used just before an object is destroyed and can be called just prior to garbage collection. 18)What are Transient and Volatile Modifiers? Ans: Transient: The transient modifier applies to variables only and it is not stored as part of its object's Persistent state. Transient variables are not serialized. Volatile: Volatile modifier applies to variables only and it tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of the program.
19)What is method overloading and method overriding? Ans: Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding. 20)What is difference between overloading and overriding? Ans: a) In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method. b) Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass. c) In overloading, separate methods share the same name whereas in overriding,subclass method replaces the superclass. d) Overloading must have different method signatures whereas overriding must have same signature. 21) What is meant by Inheritance and what are its advantages? Ans: Inheritance is the process of inheriting all the features from a class. The advantages of inheritance are reusability of code and accessibility of variables and methods of the super class by subclasses. 22)What is the difference between this() and super()? Ans: this() can be used to invoke a constructor of the same class whereas super() can be used to invoke a super class constructor. 23)What is the difference between superclass and subclass? Ans: A super class is a class that is inherited whereas sub class is a class that does the inheriting. 24) What modifiers may be used with top-level class? Ans: public, abstract and final can be used for top-level class. 25)What are inner class and anonymous class? Ans: Inner class : classes defined in other classes, including those defined in methods are called inner classes. An inner class can have any accessibility including private.
Anonymous class : Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors. 26)What is a package? Ans: A package is a collection of classes and interfaces that provides a highlevel layer of access protection and name space management. 27) What is a reflection package? Ans: java.lang.reflect package has the ability to analyze itself in runtime. 28) What is interface and its use? Ans: Interface is similar to a class which may contain method's signature only but not bodies and it is a formal set of method and constant declarations that must be defined by the class that implements it. Interfaces are useful for: a) Declaring methods that one or more classes are expected to implement b) Capturing similarities between unrelated classes without forcing a class relationship. c) Determining an object's programming interface without revealing the actual body of the class. 30) What is the difference between Integer and int? Ans: a) Integer is a class defined in the java.lang package, whereas int is a primitive data type defined in the Java language itself. Java does not automatically convert from one to the other. b) Integer can be used as an argument for a method that requires an object, whereas int can be used for calculations. 32) What is the difference between abstract class and interface? Ans: a) All the methods declared inside an interface are abstract whereas abstract class must have at least one abstract method and others may be concrete or abstract. b) In abstract class, key word abstract must be used for the methods Whereas interface we need not use that keyword for the methods. c) Abstract class must have subclasses whereas interface can't have subclasses.
33) Can you have an inner class inside a method and what variables can you access? Ans: Yes, we can have an inner class inside a method and final variables can be accessed. 36) What is the difference between exception and error? Ans: The exception class defines mild error conditions that your program encounters. Ex: Arithmetic Exception, FilenotFound exception Exceptions can occur when -- try to open the file, which does not exist -- the network connection is disrupted -- operands being manipulated are out of prescribed ranges -- the class file you are interested in loading is missing The error class defines serious error conditions that you should not attempt to recover from. In most cases it is advisable to let the program terminate when such an error is encountered. Ex: Running out of memory error, Stack overflow error. 39) What is the class and interface in java to create thread and which is the most advantageous method? Ans: Thread class and Runnable interface can be used to create threads and using Runnable interface is the most advantageous method to create threads because we need not extend thread class here. 42) When you will synchronize a piece of your code? Ans: When you expect your code will be accessed by different threads and these threads may change a particular data causing data corruption. 44) What is daemon thread and which method is used to create the daemon thread? Ans: Daemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the java runtime system. setDaemon method is used to create a daemon thread. 45) Are there any global variables in Java, which can be accessed by other part of your program?
Ans: No, it is not the main method in which you define variables. Global variables are not possible because concept of encapsulation is eliminated here. 47)What is the difference between applications and applets? Ans: a)Application must be run on local machine whereas applet needs no explicit installation on local machine. b)Application must be run explicitly within a java-compatible virtual machine whereas applet loads and runs itself automatically in a java-enabled browser. d)Application starts execution with its main method whereas applet starts execution with its init method. e)Application can run with or without graphical user interface whereas applet must run within a graphical user interface. 48)How does applet recognize the height and width? Ans:Using getParameters() method. 49)When do you use codebase in applet? Ans:When the applet class file is not in the same directory, codebase is used. 51)How do you set security in applets? Ans: using setSecurityManager() method 52) What is an event and what are the models available for event handling? Ans: An event is an event object that describes a state of change in a source. In other words, event occurs when an action is generated, like pressing button, clicking mouse, selecting a list, etc. There are two types of models for handling events and they are: a) event-inheritance model and b) event-delegation model 54)What is source and listener ? Ans: source : A source is an object that generates an event. This occurs when the internal state of that object changes in some way. listener : A listener is an object that is notified when an event occurs. It has two major requirements. First, it must have been registered with one or more sources to receive notifications about specific types of events.
Second, it must implement methods to receive and process these notifications. 55) What is adapter class? Ans: An adapter class provides an empty implementation of all methods in an event listener interface. Adapter classes are useful when you want to receive and process only some of the events that are handled by a particular event listener interface. You can define a new class to act listener by extending one of the adapter classes and implementing only those events in which you are interested. 56)What is meant by controls and what are different types of controls in AWT? Ans: Controls are components that allow a user to interact with your application and the AWT supports the following types of controls: Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components. These controls are subclasses of Component. 57) What is the difference between choice and list? Ans: A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices and only one item may be selected from a choice. A List may be displayed in such a way that several list items are visible and it supports the selection of one or more list items. 59) What is a layout manager and what are different types of layout managers available in java.awt? Ans: A layout manager is an object that is used to organize components in a container. The different layouts are available are FlowLayout, BorderLayout, CardLayout, GridLayout and GridBagLayout. 61) Which containers use a Border layout as their default layout? Ans: Window, Frame and Dialog classes use a BorderLayout as their layout. 62) Which containers use a Flow layout as their default layout? Ans: Panel and Applet classes use the FlowLayout as their default layout.
63) What are wrapper classes? Ans: Wrapper classes are classes that allow primitive types to be accessed as objects. 65) What is the difference between set and list? Ans: Set stores elements in an unordered way but does not contain duplicate elements, whereas list stores elements in an ordered way but may contain duplicate elements. what 1. 2. 3. 4. is the basic difference in rmi & corba. both are distributed technologies. rmi is used when both client & server are in java. corba is used when client & server are written in different lang. IDL comes into picture. as it changes native calls to java or vice versa.
what does class.forName(driver) do? it requests for the driver & loads the driver. statement.execute() returns resultset. what type of resultset is it? ---> sql result set