InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 101. |
How To Optimize The Javac Output? |
|
Answer» When you compare the performance of a Java program against that of a C/C++ program, you will find that the current generation of Java programs can be as much as twenty times slower than their C/C++ counterparts. This performance loss is mostly due to the FACT that the browser musf interpret the Java bytecode and convert it into the computer's native code (such as a Pentium or Motorola-specific code) before the code can run. In C/C++, the code is in the processor's native format to begin with, so this time-consuming translation step is not required. Remember, however, that Java's generic bytecode allows the same Java code to run on multiple platforms. When you compare the performance of a Java program against that of a C/C++ program, you will find that the current generation of Java programs can be as much as twenty times slower than their C/C++ counterparts. This performance loss is mostly due to the fact that the browser musf interpret the Java bytecode and convert it into the computer's native code (such as a Pentium or Motorola-specific code) before the code can run. In C/C++, the code is in the processor's native format to begin with, so this time-consuming translation step is not required. Remember, however, that Java's generic bytecode allows the same Java code to run on multiple platforms. |
|
| 102. |
What Is Javac_g? |
|
Answer» As you have learned, the javac compiler examines your source-CODE files and produces the bytecode .class files. As your JAVA applets become more complex, it may become difficult for you to locate errors (bugs) within your code. To help you locate such errors, most Java development environments provide a special debugger program. In the CASE of the Sun's Java DEVELOPER's KIT, the debugger program is named jdb (for Java debugger). To provide jdb with more information to work with, the Sun's JDK provides special version of the compiler named javac__g. Sun designed the javac _g compiler for use with debuggers. Essentially, javacjg is a non-optimized version of the javac compiler which place tables of information within the bytecode that the debugger can use to track down errors. To compile a Java applet using the javac__g compiler, you simply specify the applet source-file named within the javac^g command line, as shown here: C:JAVACODE> javac „ g SomeFile.Java <Enter>As you have learned, the javac compiler examines your source-code files and produces the bytecode .class files. As your Java applets become more complex, it may become difficult for you to locate errors (bugs) within your code. To help you locate such errors, most Java development environments provide a special debugger program. In the case of the Sun's Java Developer's Kit, the debugger program is named jdb (for Java debugger). To provide jdb with more information to work with, the Sun's JDK provides special version of the compiler named javac__g. Sun designed the javac _g compiler for use with debuggers. Essentially, javacjg is a non-optimized version of the javac compiler which place tables of information within the bytecode that the debugger can use to track down errors. To compile a Java applet using the javac__g compiler, you simply specify the applet source-file named within the javac^g command line, as shown here: |
|
| 103. |
What Is The File Type? |
Answer»
|
|
| 104. |
What Is The Program Development Process? |
Answer»
|
|
| 105. |
Explain, Java Is Compatible With All Servers But Not All Browsers? |
|
Answer» When a Java applet runs over a network, two sides are working. One is the server, which is RESPONSIBLE for maintaining and handling browser requests for the various files it CONTROLS. On the server side, a Java applet is just a FILE like any other file an HTTP server ALREADY handles. You do not need any special server software for Java since the real work of executing the Java applet is performed by the browser, not the server. On the other side is the client, or browser, which request, receives, and interprets files from the server. The browser is responsible for displaying the Web page, playing sounds, running animations and. in general, determining the type of data the server is sending and handling that data accordingly. When a Web page contains a Java applet, the page's HTML file will contain an <APPLET> entry. If the browser is Java-enabled, the browser will request the applet file from the server. The server, in turn, will send the applet's bytecode to the browser, which will start its Java INTERPRETER to execute the code. When a Java applet runs over a network, two sides are working. One is the server, which is responsible for maintaining and handling browser requests for the various files it controls. On the server side, a Java applet is just a file like any other file an HTTP server already handles. You do not need any special server software for Java since the real work of executing the Java applet is performed by the browser, not the server. On the other side is the client, or browser, which request, receives, and interprets files from the server. The browser is responsible for displaying the Web page, playing sounds, running animations and. in general, determining the type of data the server is sending and handling that data accordingly. When a Web page contains a Java applet, the page's HTML file will contain an <APPLET> entry. If the browser is Java-enabled, the browser will request the applet file from the server. The server, in turn, will send the applet's bytecode to the browser, which will start its Java interpreter to execute the code. |
|
| 106. |
What Is Appletviewer? |
|
Answer» Most Java development environments include a special program called an appletviewer. using the appletviewer, you can execute your applet just as if it were running within a Web page DISPLAYED a browser. In most cases, the appletviewer can run your applet faster than a browser, making the appletviewer convenient for testing your applet. As you develop your applet, you will want to run it each time you add features. By using the appletviewer, you can quickly TRY out your applet WITHOUT starting your Java-enabled Web browser. You run the appletviewer that accompanies Sun's Java Developer's Kit from the command line, specifying the name of the HTML file that contains the <APPLET> entry for applet you want to VIEW: C:> appletviewer SomeFileName.HTML <ENTER>Most Java development environments include a special program called an appletviewer. using the appletviewer, you can execute your applet just as if it were running within a Web page displayed a browser. In most cases, the appletviewer can run your applet faster than a browser, making the appletviewer convenient for testing your applet. As you develop your applet, you will want to run it each time you add features. By using the appletviewer, you can quickly try out your applet without starting your Java-enabled Web browser. You run the appletviewer that accompanies Sun's Java Developer's Kit from the command line, specifying the name of the HTML file that contains the <APPLET> entry for applet you want to view: |
|
| 107. |
What Is Codebase? |
|
Answer» The Java applets your browser executes reside in a file with the .class extension. When you create a Web page, you can STORE you Java .class files in a directory which is different from the directory that contains the page's HTML files. Within the HTML <APPLET> tag, you can use the CODEBASE attribute to specify the directory within which the applet's .class files reside. The CODEBASE location can be a directory on the same COMPUTER or a directory at ANOTHER computer. The CODEBASE attribute specifies (to the browser) the base URL (relative or specifies) of the directory that contain the .class files. If an <APPLET> tag does not use the CODEBASE attribute, the browser uses the current directory (the one containing the HTML file) to locate the .class files. The following <APPLET> tag directs the browser to look for the applet files in the directory called /server_a/applets. <APPLET CODE="MyFirst.class"CODEBASE^"/server_a/applets" WIDTH=300 HEIGHT=300>.</APPLET>The Java applets your browser executes reside in a file with the .class extension. When you create a Web page, you can store you Java .class files in a directory which is different from the directory that contains the page's HTML files. Within the HTML <APPLET> tag, you can use the CODEBASE attribute to specify the directory within which the applet's .class files reside. The CODEBASE location can be a directory on the same computer or a directory at another computer. The CODEBASE attribute specifies (to the browser) the base URL (relative or specifies) of the directory that contain the .class files. If an <APPLET> tag does not use the CODEBASE attribute, the browser uses the current directory (the one containing the HTML file) to locate the .class files. The following <APPLET> tag directs the browser to look for the applet files in the directory called /server_a/applets. |
|
| 108. |
How Can You Set An Applet's Height And Width As A Percentage? |
|
Answer» You use the <APPLET> tag WIDTH and HEIGHT attributes to SPECIFY the pixel size of an applet WINDOW. In ADDITION to letting you specify the applet window size in TERMS of pixels, many browsers LET you specify the applet window's size as a percentage of the browser's window's size. You do this by specifying a percentage value for the HEIGHT and WIDTH attributes within the <APPLET> tag. For example, the following <APPLET> entry creates an applet window based on 50% of the height and 100% of the width of the browser's window: <applet code=test.class width=100% height=50%> </applet>.You use the <APPLET> tag WIDTH and HEIGHT attributes to specify the pixel size of an applet window. In addition to letting you specify the applet window size in terms of pixels, many browsers let you specify the applet window's size as a percentage of the browser's window's size. You do this by specifying a percentage value for the HEIGHT and WIDTH attributes within the <APPLET> tag. For example, the following <APPLET> entry creates an applet window based on 50% of the height and 100% of the width of the browser's window: |
|
| 109. |
How Can You Set The Applet Size? |
|
Answer» Java applets run within their own WINDOW: Within your HTML file, you set the size of an applet window, using the <APPLET> tag's WIDTH and HEIGHT attributes. The size values you specify for each attribute are in PIXELS. For example, the following <APPLET> entry creates applet window that is 30 pixels tall by 100 pixels wide: <APPLET CODE=clock.class WIDTH=100 HEIGHT=30> </APPLET>Java applets run within their own window: Within your HTML file, you set the size of an applet window, using the <APPLET> tag's WIDTH and HEIGHT attributes. The size values you specify for each attribute are in pixels. For example, the following <APPLET> entry creates applet window that is 30 pixels tall by 100 pixels wide: |
|
| 110. |
Why Java Applets Are More Useful For Intranets As Compared To Internet? |
|
Answer» An intranet is an in-house version of the Internet. An intranet uses the same technologies, software, and equipment that the Internet uses (PRIMARILY TCP/IP). Whereas the Internet has information servers MILES away controlled by other organizations, your company controls the servers and client computers inside your office in an intranet. During the past YEAR, intranets have experienced explosive popularity growth because they offer a very low cost way for companies to maintain and distribute internal information in an easy-to-use format. An intranet is an in-house version of the Internet. An intranet uses the same technologies, software, and equipment that the Internet uses (primarily TCP/IP). Whereas the Internet has information servers miles away controlled by other organizations, your company controls the servers and client computers inside your office in an intranet. During the past year, intranets have experienced explosive popularity growth because they offer a very low cost way for companies to maintain and distribute internal information in an easy-to-use format. |
|
| 111. |
What's The Difference Between Applets And Standalone Program? |
|
Answer» Sun designed Java from the start to fit hand-in-glove on the Internet. Applets are special Java PROGRAMS that execute from within a Web browser. In contrast, a Java application (an application PROGRAM as opposed to an applet) does not run within a browser. As it turns out, Java applets are not much different from standalone Java application. You can start developing your Java program from either an applet or an application and cross over any time. For example, assume that you are writing a new Java-based application that is initially designed as a standalone (non-Internet) GAME for Mac COMPUTERS. At the end of your program's development CYCLE, you decide that you want it to run on Web browsers. Your task to make it into a Web-based applet involves very trivial changes, and the addition of some simple HTML code. At the same time, you will find that the game will also run on computers other than Macs! The point you should remember is that Java applets run within browsers across the Web, whereas Java application programs do not. Sun designed Java from the start to fit hand-in-glove on the Internet. Applets are special Java programs that execute from within a Web browser. In contrast, a Java application (an application program as opposed to an applet) does not run within a browser. As it turns out, Java applets are not much different from standalone Java application. You can start developing your Java program from either an applet or an application and cross over any time. For example, assume that you are writing a new Java-based application that is initially designed as a standalone (non-Internet) game for Mac computers. At the end of your program's development cycle, you decide that you want it to run on Web browsers. Your task to make it into a Web-based applet involves very trivial changes, and the addition of some simple HTML code. At the same time, you will find that the game will also run on computers other than Macs! The point you should remember is that Java applets run within browsers across the Web, whereas Java application programs do not. |
|
| 112. |
How Java Is Similar To C? |
|
Answer» If you are already familiar with C/C++, you will find that Java is actually a SIMPLER language to master. Java incorporates the basic tenets of object-oriented design, yet it eliminates some of the more COMPLICATED of the other language, such as multiple inheritance and templates. Many of the language keywords are the same or have only minor differences, which increases portability. If you are already familiar with C/C++, you will find that Java is actually a simpler language to master. Java incorporates the basic tenets of object-oriented design, yet it eliminates some of the more complicated of the other language, such as multiple inheritance and templates. Many of the language keywords are the same or have only minor differences, which increases portability. |
|
| 113. |
Why Do People Says "java Is Robust"? |
|
Answer» When PEOPLE talk about code being robust, they are referring to the code's reliability. Although Java has not eliminated unreliable code, it has made writing high-quality software easier. To begin, Java eliminates many of the memory problems that are common in languages such as C and C++. Java does not support direct access to pointers to memory. As a result, a Java applet cannot corrupt your computer's memory. Also, Java performs run-time CHECKS (while the applet is RUNNING) to make sure that all array and string references are within each items's bounds. In other programming languages, many software bugs result from the PROGRAM not freeing memory that ought to be freed or freeing the same memory more than once. Java, on the other hand, performs automatic garbage collection (which releases unused memory), eliminating the program's need to free unused memory. When people talk about code being robust, they are referring to the code's reliability. Although Java has not eliminated unreliable code, it has made writing high-quality software easier. To begin, Java eliminates many of the memory problems that are common in languages such as C and C++. Java does not support direct access to pointers to memory. As a result, a Java applet cannot corrupt your computer's memory. Also, Java performs run-time checks (while the applet is running) to make sure that all array and string references are within each items's bounds. In other programming languages, many software bugs result from the program not freeing memory that ought to be freed or freeing the same memory more than once. Java, on the other hand, performs automatic garbage collection (which releases unused memory), eliminating the program's need to free unused memory. |
|
| 114. |
Why Java Is Secure? Explain. ? |
|
Answer» A computer virus is a program written by someone who to maliciously damage the FILES you have stored on your disks or your computer's disk itself. To encounter a virus from across the Internet, you MUST download and run a program. Unfortunately, with Java applets, a remote sever downloads the applet to a browser on your system which, in turn, runs the applet. At first glance these downloaded Java applets are an ideal way for MALICIOUS programmers to create viruses. Luckily, the Java developers designed Java with networking in mind. Therefore, Java has several built-in security defenses which reduce a programmer's ability to use Java to create a virus. A computer virus is a program written by someone who to maliciously damage the files you have stored on your disks or your computer's disk itself. To encounter a virus from across the Internet, you must download and run a program. Unfortunately, with Java applets, a remote sever downloads the applet to a browser on your system which, in turn, runs the applet. At first glance these downloaded Java applets are an ideal way for malicious programmers to create viruses. Luckily, the Java developers designed Java with networking in mind. Therefore, Java has several built-in security defenses which reduce a programmer's ability to use Java to create a virus. |
|
| 115. |
Why Java Is Platform Independent? Explain. ? |
|
Answer» When you write and COMPILE a Java applet, you end up with a platform-independent FILE called a bytecode. Like a standard program, a bytecode consists of ones and zeros. Unlike a standard program, however, the bytecode is not processor specific. In other words, the bytecode does not correspond to an Intel Pentium or a Motorola processor. Instead, after the server DOWNLOADS the bytecode to your browser, special code within the browser reads and interprets the bytecode, in turn running the applet. To run the bytecode in this way, the interpreter translates the platform independent ones and zeros into ones and zeros your computer's processor understands. In other words, it maps the bytecode to ones and zeros that correspond to the current processor, such as a Pentium. When you write and compile a Java applet, you end up with a platform-independent file called a bytecode. Like a standard program, a bytecode consists of ones and zeros. Unlike a standard program, however, the bytecode is not processor specific. In other words, the bytecode does not correspond to an Intel Pentium or a Motorola processor. Instead, after the server downloads the bytecode to your browser, special code within the browser reads and interprets the bytecode, in turn running the applet. To run the bytecode in this way, the interpreter translates the platform independent ones and zeros into ones and zeros your computer's processor understands. In other words, it maps the bytecode to ones and zeros that correspond to the current processor, such as a Pentium. |
|
| 116. |
How Can You Say Java Is Object Oriented? |
|
Answer» Java is an object-oriented programming language which means you can use Java to develop your programs in terms of data and the methods (functions) that operate on the data. In Java, a class is a COLLECTION of the data and methods which describe an object with which your program works. Think of an object as a "THING," such as a graphics IMAGE, a dialog box, or a file. Java is an object-oriented programming language which means you can use Java to develop your programs in terms of data and the methods (functions) that operate on the data. In Java, a class is a collection of the data and methods which describe an object with which your program works. Think of an object as a "thing," such as a graphics image, a dialog box, or a file. |
|
| 117. |
What Is Hotjava? |
|
Answer» Programmers often mention the name "HotJava" in the same BREATH as Java. Whereas Java is a programming language, HotJava was the first Web browser that could download and play (execute) Java applets. HotJava, created by SUN, is simply a browser, much like the Netscape Navigator or Microsoft's INTERNET Explorer. Programmers often mention the name "HotJava" in the same breath as Java. Whereas Java is a programming language, HotJava was the first Web browser that could download and play (execute) Java applets. HotJava, created by Sun, is simply a browser, much like the Netscape Navigator or Microsoft's Internet Explorer. |
|
| 118. |
What Is Java And Their Uses? |
|
Answer» Java is an object-programming language that was designed to be portable across multiple platforms and operating systems. Developed by SUN Microsystems, Java is modeled after the C++ programming language and includes special features that make it ideal for PROGRAMS on the Internet. STILL, you may be wondering why Java is suddenly receiving so much hype, and what possible improvements could have been made to this new language so as to push aside a well-established language such as C++. Java is an object-programming language that was designed to be portable across multiple platforms and operating systems. Developed by Sun Microsystems, Java is modeled after the C++ programming language and includes special features that make it ideal for programs on the Internet. Still, you may be wondering why Java is suddenly receiving so much hype, and what possible improvements could have been made to this new language so as to push aside a well-established language such as C++. |
|
| 119. |
Is It Possible To Specify Multiple Jndi Names When Deploying An Ejb? |
|
Answer» No. To achieve this you have to DEPLOY your EJB MULTIPLE times each SPECIFYING a DIFFERENT JNDI name. No. To achieve this you have to deploy your EJB multiple times each specifying a different JNDI name. |
|
| 120. |
Is A Class Subclass Of Itself? |
|
Answer» No. A CLASS is not a SUBCLASS of itself. No. A class is not a subclass of itself. |
|
| 121. |
Wha Is The Output From System.out.println("hello"+null); ? |
|
Answer» Hellonull. Hellonull. |
|
| 122. |
What Gives Java It's "write Once And Run Anywhere" Nature? |
|
Answer» Java is compiled to be a byte code which is the intermediate language between SOURCE code and machine code. This byte code is not PLATORM SPECIFIC and hence can be fed to any platform. After being fed to the JVM, which is specific to a particular operating system, the code platform specific machine code is generated THUS making java platform INDEPENDENT. Java is compiled to be a byte code which is the intermediate language between source code and machine code. This byte code is not platorm specific and hence can be fed to any platform. After being fed to the JVM, which is specific to a particular operating system, the code platform specific machine code is generated thus making java platform independent. |
|
| 123. |
What Are The Four Corner Stones Of Oop? |
|
Answer» ABSTRACTION, ENCAPSULATION, POLYMORPHISM and INHERITANCE. Abstraction, Encapsulation, Polymorphism and Inheritance. |
|
| 124. |
Difference Between A Class And An Object ? |
|
Answer» A class is a definition or prototype WHEREAS an object is an INSTANCE or LIVING representation of the prototype. A class is a definition or prototype whereas an object is an instance or living representation of the prototype. |
|
| 125. |
What Is A "stateless" Protocol ? |
|
Answer» Without getting into LENGTHY debates, it is generally accepted that protocols like HTTP are STATELESS i.e. there is no retention of STATE between a TRANSACTION which is a single REQUEST response combination. Without getting into lengthy debates, it is generally accepted that protocols like HTTP are stateless i.e. there is no retention of state between a transaction which is a single request response combination. |
|
| 126. |
What Is Passed By Reference And Pass By Value ? |
|
Answer» All Java method arguments are passed by VALUE. HOWEVER, Java does manipulate objects by REFERENCE, and all OBJECT VARIABLES themselves are references. All Java method arguments are passed by value. However, Java does manipulate objects by reference, and all object variables themselves are references. |
|
| 127. |
Can Rmi And Corba Based Applications Interact ? |
|
Answer» YES they can. RMI is AVAILABLE with IIOP as the transport PROTOCOL instead of JRMP. Yes they can. RMI is available with IIOP as the transport protocol instead of JRMP. |
|
| 128. |
You Can Create A String Object As String Str = "abc"; Why Cant A Button Object Be Created As Button Bt = "abc";? Explain |
|
Answer» The MAIN reason you cannot create a button by Button BT= "abc"; is because "abc" is a literal string (something slightly DIFFERENT than a String object, by-the-way) and bt is a Button object. The only object in JAVA that can be ASSIGNED a literal String is java.lang.String. Important to note that you are NOT calling a java.lang.String constuctor when you type String s = "abc"; The main reason you cannot create a button by Button bt= "abc"; is because "abc" is a literal string (something slightly different than a String object, by-the-way) and bt is a Button object. The only object in Java that can be assigned a literal String is java.lang.String. Important to note that you are NOT calling a java.lang.String constuctor when you type String s = "abc"; |
|
| 129. |
What Does The "abstract" Keyword Mean In Front Of A Method? A Class? |
|
Answer» Abstract keyword DECLARES either a method or a class. If a method has a abstract keyword in FRONT of it,it is called abstract method.Abstract method has no body.It has only arguments and return type.Abstract methods act as placeholder methods that are implemented in the subclasses. Abstract classes can’t be instantiated.If a class is declared as abstract,no objects of that class can be created.If a class CONTAINS any abstract method it must be declared as abstract. Abstract keyword declares either a method or a class. If a method has a abstract keyword in front of it,it is called abstract method.Abstract method has no body.It has only arguments and return type.Abstract methods act as placeholder methods that are implemented in the subclasses. Abstract classes can’t be instantiated.If a class is declared as abstract,no objects of that class can be created.If a class contains any abstract method it must be declared as abstract. |
|
| 130. |
How Many Methods Do U Implement If Implement The Serializable Interface? |
|
Answer» The Serializable INTERFACE is just a "marker" interface, with no METHODS of its own to implement. Other ’marker’ INTERFACES are The Serializable interface is just a "marker" interface, with no methods of its own to implement. Other ’marker’ interfaces are |
|
| 131. |
What Are The Practical Benefits, If Any, Of Importing A Specific Class Rather Than An Entire Package (e.g. Import Java.net.* Versus Import Java.net.socket)? |
|
Answer» It makes no difference in the generated class files since only the CLASSES that are actually used are referenced by the generated class FILE. There is another practical BENEFIT to importing single classes, and this arises when two (or more) packages have classes with the same name. Take java.util.Timer and javax.swing.Timer, for example. If I import java.util.* and javax.swing.* and then try to use "Timer", I get an error while compiling (the class name is ambiguous between both packages). Let’s say what you really wanted was the javax.swing.Timer class, and the only classes you plan on using in java.util are Collection and HashMap. In this case, some people will prefer to import java.util.Collection and import java.util.HashMap instead of importing java.util.*. This will now ALLOW them to use Timer, Collection, HashMap, and other javax.swing classes without using fully qualified class NAMES in. It makes no difference in the generated class files since only the classes that are actually used are referenced by the generated class file. There is another practical benefit to importing single classes, and this arises when two (or more) packages have classes with the same name. Take java.util.Timer and javax.swing.Timer, for example. If I import java.util.* and javax.swing.* and then try to use "Timer", I get an error while compiling (the class name is ambiguous between both packages). Let’s say what you really wanted was the javax.swing.Timer class, and the only classes you plan on using in java.util are Collection and HashMap. In this case, some people will prefer to import java.util.Collection and import java.util.HashMap instead of importing java.util.*. This will now allow them to use Timer, Collection, HashMap, and other javax.swing classes without using fully qualified class names in. |
|
| 132. |
What Is The Difference Between Logical Data Independence And Physical Data Independence? |
|
Answer» Logical Data Independence - MEANING IMMUNITY of EXTERNAL SCHEMAS to changed in conceptual SCHEMA. Physical Data Independence - meaning immunity of conceptual schema to changes in the internal schema. Logical Data Independence - meaning immunity of external schemas to changed in conceptual schema. Physical Data Independence - meaning immunity of conceptual schema to changes in the internal schema. |
|
| 133. |
What Is User Defined Exception? |
|
Answer» APART from the exceptions already defined in Java package libraries, user can define his own exception CLASSES by extending Exception class. Apart from the exceptions already defined in Java package libraries, user can define his own exception classes by extending Exception class. |
|
| 134. |
Can An Interface Have An Inner Class? |
|
Answer» Yes. public INTERFACE abc {static int i=0; void dd(); CLASS A1 { a1() { int J; System.out.println("in interfia"); }; public static void MAIN(String a1[]) { System.out.println("in interfia"); } } } Yes. |
|
| 135. |
Can There Be An Abstract Class With No Abstract Methods In It? |
|
Answer» Yes. Yes. |
|
| 136. |
What Is Garbage Collection? What Is The Process That Is Responsible For Doing That In Java? |
|
Answer» Reclaiming the unused MEMORY by the INVALID OBJECTS. Garbage COLLECTOR is responsible for this process. Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process. |
|
| 137. |
Can We Define Private And Protected Modifiers For Variables In Interfaces? |
|
Answer» No. No. |
|
| 138. |
Can There Be An Abstract Class With No Abstract Methods In It? |
|
Answer» Yes. Yes. |
|
| 139. |
Explain About The Select Method With An Example? |
|
Answer» Select part is useful in selecting text or part of the text. Arguments specified for the select command are the same as applicable to substring. First index is usually represents the START of the index. END of line makers are counted as ONE CHARACTER. EXAMPLE t.select (10,15) . Select part is useful in selecting text or part of the text. Arguments specified for the select command are the same as applicable to substring. First index is usually represents the start of the index. End of line makers are counted as one character. Example t.select (10,15) . |
|
| 140. |
What Are Different Type Of Exceptions In Java? |
|
Answer» There are two TYPES of exceptions in java. CHECKED exceptions and Unchecked exceptions. Any exception that is is derived from Throwable and Exception is called checked exception except RuntimeException and its sub classes. The COMPILER will check whether the exception is caught or not at COMPILE time. We need to catch the checked exception or declare in the throws clause. Any exception that is derived from Error and RUNTIME Exception is called unchecked exception. We don't need to explicitly catch a unchecked exception. There are two types of exceptions in java. Checked exceptions and Unchecked exceptions. Any exception that is is derived from Throwable and Exception is called checked exception except RuntimeException and its sub classes. The compiler will check whether the exception is caught or not at compile time. We need to catch the checked exception or declare in the throws clause. Any exception that is derived from Error and Runtime Exception is called unchecked exception. We don't need to explicitly catch a unchecked exception. |
|
| 141. |
What Is The Difference Between Notify And Notifyall Method? |
|
Answer» notify wakes up a single thread that is waiting for object's monitor. If any threads are waiting on this object, one of them is CHOSEN to be AWAKENED. The choice is ARBITRARY and occurs at the discretion of the implementation. NOTIFYALL Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by CALLING one of the wait methods. notify wakes up a single thread that is waiting for object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. notifyAll Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods. |
|
| 142. |
What Is The Difference Between Static And Non Static Variables ? |
|
Answer» A static variable is ASSOCIATED with the CLASS as a whole rather than with SPECIFIC instances of a class. There will be only one value for static variable for all instances of that class. Non-static VARIABLES take on unique values with each object instance. A static variable is associated with the class as a whole rather than with specific instances of a class. There will be only one value for static variable for all instances of that class. Non-static variables take on unique values with each object instance. |
|
| 143. |
What Are The Different Ways In Which A Thread Can Enter Into Waiting State? |
|
Answer» There are three ways for a thread to enter into waiting STATE. By invoking its SLEEP() method, by blocking on I/O, by unsuccessfully ATTEMPTING to acquire an OBJECT's LOCK, or by invoking an object's wait() method. There are three ways for a thread to enter into waiting state. By invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. |
|
| 144. |
What Is The Difference Between A Switch Statement And An If Statement? |
|
Answer» If statement is used to select from two alternatives. It uses a boolean expression to DECIDE which alternative should be executed. The expression in if must be a boolean VALUE. The SWITCH statement is used to select from multiple alternatives. The case values must be promoted to an to INT value. If statement is used to select from two alternatives. It uses a boolean expression to decide which alternative should be executed. The expression in if must be a boolean value. The switch statement is used to select from multiple alternatives. The case values must be promoted to an to int value. |
|
| 145. |
What Are The Access Modifiers Available In Java? |
|
Answer» Access modifier specify where a METHOD or ATTRIBUTE can be USED.
Access modifier specify where a method or attribute can be used. |
|
| 146. |
Why Java Is Said To Be Pass-by-value ? |
|
Answer» When assigning an object to a VARIABLE, we are ACTUALLY assigning the memory address of that object to the variable. So the value passed is actually the memory LOCATION of the object. This RESULTS in object aliasing, meaning you can have many variables referring to the same object on the heap. When assigning an object to a variable, we are actually assigning the memory address of that object to the variable. So the value passed is actually the memory location of the object. This results in object aliasing, meaning you can have many variables referring to the same object on the heap. |
|
| 147. |
What Are The Advantages And Disadvantages Of Reference Counting In Garbage Collection? |
|
Answer» An advantage of this SCHEME is that it can run in small chunks of time CLOSELY linked with the execution of the PROGRAM. These characteristic makes it particularly suitable for real-time environments where the program can't be interrupted for very long time. A DISADVANTAGE of reference counting is that it does not detect cycles. A cycle is two or more objects that REFER to one another. Another disadvantage is the overhead of incrementing and decrementing the reference count each time. Because of these disadvantages, reference counting currently is out of favor. An advantage of this scheme is that it can run in small chunks of time closely linked with the execution of the program. These characteristic makes it particularly suitable for real-time environments where the program can't be interrupted for very long time. A disadvantage of reference counting is that it does not detect cycles. A cycle is two or more objects that refer to one another. Another disadvantage is the overhead of incrementing and decrementing the reference count each time. Because of these disadvantages, reference counting currently is out of favor. |
|
| 148. |
How Would You Implement A Thread Pool? |
|
Answer» The ThreadPool class is a GENERIC implementation of a thread pool, which takes the following input SIZE of the pool to be constructed and name of the class which implements RUNNABLE (which has a visible default constructor) and constructs a thread pool with active threads that are waiting for activation. once the threads have FINISHED processing they come back and wait once again in the pool. The ThreadPool class is a generic implementation of a thread pool, which takes the following input Size of the pool to be constructed and name of the class which implements Runnable (which has a visible default constructor) and constructs a thread pool with active threads that are waiting for activation. once the threads have finished processing they come back and wait once again in the pool. |
|
| 149. |
What Is The Difference Between An Argument And A Parameter? |
|
Answer» While DEFINING method, VARIABLES passed in the method are CALLED parameters. While using those methods, VALUES passed to those variables are called ARGUMENTS. While defining method, variables passed in the method are called parameters. While using those methods, values passed to those variables are called arguments. |
|
| 150. |
How Many Ways Can An Argument Be Passed To A Subroutine And Explain Them? |
|
Answer» An argument can be passed in TWO ways. Passing by value: This method copies the value of an argument into the FORMAL parameter of the SUBROUTINE. Passing by REFERENCE: In this method, a reference to an argument (not the value of the argument) is passed to the parameter. An argument can be passed in two ways. Passing by value: This method copies the value of an argument into the formal parameter of the subroutine. Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed to the parameter. |
|