Make your own free website on Tripod.com

Interview Type of Questions - 3

 

Object, Class, and Methods

  1. What is an object?
  2. What is a class?
  3. What is a method?
  4. What is the signature of a method?
  5. What is the difference between an instance variable and a class variable?
  6. What is the difference between an instance method and a class method?
  7. How do I create an instance of a class?
  8. What is an abstract method?
  9. What is an abstract class?
  10. What is an object reference?

 

Subclassing, Overloading, and Overriding

  1. What is a subclass?
  2. What is inheritance?
  3. What is an overloaded method?
  4. What does it mean to override a method?
  5. What is the difference between overloading and overriding?
  6. Can I override the equals method or clone method from class Object to take a parameter or return a value of the type that I specify?
  7. What is the super keyword used for?
  8. Does the Java language provide virtual methods, like C++?
  9. What is a final class?

 

Interfaces and Abstract Classes

  1. What is an interface?
  2. How does a class implement an interface?
  3. Can I instantiate an interface?
  4. Why does a method in an interface appear to be public even though I didn't declare it to be public?
  5. How is an abstract class different from an interface?
  6. Does the Java language allow multiple inheritance?
  7. What is the instanceof keyword, and what does it do?
  8. Why do I get the error message Can't access protected method clone... when I try to clone an object?
  9. How do I design a class so that it supports cloning?

 

Packages and Access Modifiers

  1. What are packages, and what are they used for?
  2. I've seen both java.applet.Applet and Applet used to refer to the Applet class -- what's the difference?
  3. Why can I get some simple class names "for free," without using an import declaration?
  4. Is there a default access modifier for classes and interfaces? For class members (methods, constructors, and fields)?
  5. What does protected access mean?
  6. What is the accessibility of a public method or field inside a nonpublic class or interface?

 

Constants and Expressions

  1. What is the difference between Integer and int in Java -- why do I get the following error: Can't convert java.lang.Integer to int?
  2. How do I treat all 8 bits of a byte as an unsigned quantity?
  3. How do I work around Java's lack of true enums?
  4. Why is goto a reserved keyword in Java -- shouldn't it be outlawed?
  5. What are some guidelines for using uppercase and lowercase letters in my identifiers?
  6. Is there any limit to the length of an identifier?
  7. Why doesn't Java have user-defined operator overloading?
  8. Why do I have to put an f after a floating point constant?
  9. How and when can I cast from one class to another?
  10. Can I use C-like data structures in Java?

Variables and Methods

  1. Are Java objects pointers?
  2. In a method invocation, does Java pass arguments by reference or by value?
  3. If the Java language lacks pointers, how do I implement classic pointer structures like linked lists?
  4. What does the following error message mean: Can't make a static reference to nonstatic variable?
  5. In a class method, how can I get the name of the class, or create a new instance of the class?
  6. Can I write a method that delivers dynamically (at run time) all public methods of an object?
  7. Can I invoke methods dynamically, from names (String instances) that are determined at run time?
  8. How can I accomplish the equivalent of function pointers in Java, for instance, for use in an array?

 

Arrays

  1. Can I allocate an array dynamically?
  2. How do I initialize an array of objects?
  3. If arrays are objects, why can't I use a length method to determine an array's size?

 

Exceptions

  1. What is an exception?
  2. Why does the compiler complain about InterruptedException when I try to use Thread's sleep method?
  3. Why do methods have to declare the exceptions they can throw?
  4. What's the difference between a runtime exception and a plain exception -- why don't runtime exceptions have to be declared?

 

Virtual Machine

  1. When, and by whom, is the main method of a class invoked?
  2. What are bytecodes?
  3. What is javap?
  4. What does it mean to say that Java is interpreted?
  5. What kind of garbage collection does the Java Virtual Machine use?
  6. Is finalization broken -- why does my finalize method never seem to get invoked?
  7. I'm having trouble invoking methods on the objects returned from Class's forName method -- how should I use Class.forName?
  8. Why do I get verifier errors when loading a class file produced by javac?
  9. How fast are Java programs compared to equivalent C or C++ programs?

 

Applets versus Applications

  1. What is an applet?
  2. How do applets differ from applications?
  3. Can I write Java code that works both as an applet and as a stand-alone application?

 

Installing Applets

  1. How do I put an applet into a web page?
  2. Can I put more than one applet in a web page?
  3. How do I use the APPLET tag if I want to show users of non-Java-enabled browsers what they're missing?
  4. What is the complete syntax for using the APPLET tag?
  5. What are the different pieces that can make up an applet, and how do I install them?
  6. Where can I put my applet's class files, and how do I indicate their location using the APPLET tag?
  7. Can I put my reusable custom classes in a special place so that many different applets can use them?

  

Applet User Interface

  1. How do I determine the width and height of my applet?
  2. How do I set the background color within the applet area?
  3. How can I create a transparent background for my applet?
  4. Can I put menus and a menu bar on my applet?
  5. I know that cursors can be changed from within frames, but how do I change the cursor in my applet?

 

Applet Program Structure

  1. Several applet methods seem special, in that I need to define them even if my own code doesn't invoke them -- what are the methods, and when (and by whom) are they invoked?
  2. Should applets have constructors?
  3. How can my applet tell when a user leaves or returns to the web page containing my applet?
  4. How do I read number information from my applet's parameters, given that Applet's getParameter method returns a String?

 

 

Applet Communication

  1. How can I arrange for different applets on a web page to communicate with each other?
  2. How do I select a URL from my applet and send the browser to that page?
  3. Can applets on different pages communicate with each other?

 

Miscellaneous

  1. Can I load an applet dynamically into a Java application, and if so, how does the applet get the parameter information it would normally get from the APPLET tag?
  2. Do I need any special server software or setup to deliver applets?

  

Components, Containers, and Peers

  1. What are the Component and Container classes?
  2. How do I control the positioning of my interface components?
  3. What are inset values, and how do I set them?
  4. Can I exert complete control over the size and placement of components in my interface?
  5. What do the invalidate and validate methods do?
  6. Can I add new AWT components to objects already visible on the screen?
  7. Can I add the same component to more than one container?
  8. How can I place an outline around a group of components to show explicitly how the components are grouped?
  9. What are AWT peers?

 

Windows, Frames, and Dialogs

  1. How do I specify where a window is to be placed?
  2. How can I draw at the top-left corner of a frame without it being covered by the frame's border?
  3. How do I create a borderless window?
  4. Several operations in the AWT, such as setting the cursor (in JDK 1.0.2) or creating a dialog box, require specifying a Frame instance -- how do I determine the Frame instance containing the current component?
  5. How do I use a FileDialog object in my applet or application?
  6. Can I create nonresizable windows?

 

Miscellaneous

  1. What does Component's requestFocus method do?
  2. Does the AWT allow you to control the mouse location from within an application?
  3. Does the AWT provide a standard way to signal a user error by flashing, beeping, or some other means?
  4. What fonts are available to my AWT program?
  5. How can I dynamically change font attributes, for instance, rendering a string in successively larger font sizes?

 

Events -- JDK 1.0.2

  1. What information can be carried in the JDK 1.0.2 by an Event object?
  2. What information do specific event types in the JDK 1.0.2 carry?
  3. What is the general model in the JDK 1.0.2 for distributing and handling events?
  4. What methods should I use in the JDK 1.0.2 to handle events?
  5. What is an action event?
  6. How does the JDK 1.0.2 handle events for function keys, arrow keys, and so on?
  7. My frame doesn't close when I click on Quit/Close in the main menu -- how do I fix this using JDK 1.0.2?
  8. How is my program notified when a menu item is selected?
  9. MenuItemEventExample.html
  10. How is my program notified in the JDK 1.0.2 when a list item is selected or deselected?
  11. How do I hook up a scroll bar in the JDK 1.0.2 so that it controls the scrolling of some other component?
  12. Does the AWT in the JDK 1.0.2 distinguish between mouse clicks made with different buttons on a two- or three-button mouse?

 

Event Classes, Listeners, and Methods

  1. What information do specific event types in the JDK 1.1 carry?
  2. How do I catch events in the JDK 1.1 event model?
  3. What are the different kinds of event listeners, and what are their methods?
  4. When should I use an event adapter class?
  5. Do events propagate in the JDK 1.1 as they did in the older AWT event model?
  6. Will my code written for the older JDK 1.0.2 event model still run in the JDK 1.1?

 

SEMANTIC EVENTS

  1. How do I handle action events in the JDK 1.1?
  2. How do I catch menu item events in the 1.1 AWT event model?
  3. In the JDK 1.1 AWT event model, how is my program notified when a list item is selected or deselected?
  4. How do I control scrolling in the 1.1 AWT?

 

LOW-LEVEL EVENTS

  1. My frame doesn't close when I click on Quit/Close in the main menu -- how do I fix this using the JDK 1.1?
  2. Is there an event type that signals when a window is resized?
  3. How do I handle events for function keys, arrow keys, and so on in the JDK 1.1 event model?
  4. How does the JDK 1.1 distinguish between mouse clicks made with different buttons on a two- or three-button mouse?

 

Drawing AWT Components

  1. What is the paint method for, when is it invoked, and by whom?
  2. What should I put in my paint method?
  3. What is repaint for, when is it invoked, and by whom?
  4. Why do my repeated calls to repaint not have any effect?
  5. What is update for, when is it invoked, and by whom?
  6. What drawing occurs if my applet or other component reappears after being covered by some other window?
  7. Can I implement an invisible or partly transparent component?
  8. How does the XOR drawing mode work?

 

Loading and Drawing Images

  1. How do I load an image from the net into my applet?
  2. How do I load an image from a file in a stand-alone Java application, rather than in an applet?
  3. When is an image actually loaded -- why not immediately?
  4. How can I make sure that my images are completely loaded before I check for their data or parameters?
  5. Why does my call to Graphics's drawImage method fail to show the image?
  6. Can I force Applet's getImage method to make a new connection for each image rather than reusing a cached version of the image?
  7. How do I draw text over a background image?
  8. How do I load and display a transparent GIF image over a background image?
  9. How can I create an image from a buffer of raw image data (red, green, and blue values for each pixel)?
  10. What is double buffering -- how can I create and draw to an offscreen image?
  11. How can I get at the raw data of an image, such as the pixel value at a given coordinate?

 

Images -- JDK 1.0.2

  1. Using the JDK 1.0.2, can I clear or reset a clipping rectangle that either I or the system has created?
  2. Using the JDK 1.0.2, can I copy a subarea of one image into another image?

 

Images -- JDK 1.1

  1. How do I control animation with MemoryImageSource?
  2. Using the JDK 1.1, how do I reset a clipping rectangle?
  3. What's the best way in JDK 1.1 to draw just a subarea of an image?

 

Creating and Controlling Threads

  1. What is a thread?
  2. How do I create a thread and start it running?
  3. How does Thread's stop method work -- can I restart a stopped thread?
  4. How should I stop a thread so that I can start a new thread later in its place?
  5. How do I specify pause times in my program?

 

Thread Interactions

  1. Why is thread synchronization important for multithreaded programs?
  2. What is a monitor?
  3. How does the synchronized keyword work?
  4. What objects do static synchronized methods use for locking?
  5. How do the wait and notifyAll/notify methods enable cooperation between threads?
  6. How do I achieve the effect of condition variables if the Java platform provides me with only wait and notifyAll/notify methods?
  7. How do I make one thread wait for one or more other threads to finish?
  8. What do I use the yield method for?
  9. Does the Java Virtual Machine protect me against deadlocks?

 

User Threads versus System Threads

  1. Why does my multithreaded program run fine on Windows NT/95 but block on Solaris?
  2. Why do so many applets run a copy of themselves in a separate thread rather than just running as they are?
  3. How can it be that putting an applet thread to sleep in the wrong place can block other applets from running?
  4. Can I have a thread wait on an event from the operating system?

 

Basic Input and Output

  1. How do I read a line of input at a time?
  2. Why doesn't String's replace method have any effect when I apply it to a string?
  3. How can I access native operating system calls from my Java program?
  4. Does Java provide standard iterator functions for inspecting a collection of objects?
  5. The Math.random method is too limited for my needs -- how can I generate random numbers more flexibly?

 

Audio

  1. How do I play sounds in an applet?
  2. How do I play several audio clips simultaneously?
  3. Can I tell when an audio clip has finished playing?
  4. How can I play audio in a stand-alone application?
  5. What audio formats does the JDK

 

Author & Copyrights 2004: Narayanaswami Banukumar