Eclipse Interview Preparation Guide
Download PDF

Eclipse Interview Questions and Answers will guide us now that Eclipse is a multi-language software development environment comprising an integrated development environment (IDE) and an extensible plug-in system. It is written primarily in Java and can be used to develop applications in Java and, by means of the various plug-ins, in other languages as well, including C, C++, COBOL, Python, Perl, PHP. So learn Eclipse by this Eclipse Interview Questions with Answers guide

16 Eclipse Questions and Answers:

1 :: When does a plugin get started?

Each plug-in can be viewed as having a declarative section and a code section. The declarative part is contained in the plugin.xml file. This file is loaded into a registry when the platform starts up and so is always available, regardless of whether a plug-in has started. The code section are laze loaded by default. They are activated only when their functionality has been explicitly invoked by the user.

2 :: What are extensions and extension points?

Loose coupling in Eclipse is achieved partially through the mechanism of extensions and extension points. When a plug-in wants to allow other plug-ins to extend or customize portions of its functionality, it will declare an extension point. The extension point declares a typically a combination of XML markup and Java interfaces, that extensions must conform to. Plug-ins that want to connect to that extension point must implement that contract in their extension.

3 :: How to access UI objects from a non-ui thread?

Use Display.getDefault().asyncExec(new Runnable()...) Display.asyncExec causes the run() method of the runnable to be invoked by the user-interface thread at the next reasonable opportunity. The caller of this method continues to run in parallel, and is not notified when the runnable has completed.

4 :: How to fire a key event in my test code to make the program act as if a user pressed a key?

Two ways to implement it in code: generating OS level key event use or use Widge.notifyListeners(...) to just notify a widget's listeners.

5 :: Why do I get the error "org.eclipse.swt.SWTException: Invalid thread access"?

SWT implements a single-threaded UI model often called apartment threading. In this model, only the UI-thread can invoke UI operations. SWT strictly enforces this rule. If you try and access an SWT object from outside the UI-thread, you get the exception "org.eclipse.swt.SWTException: Invalid thread access". The following code sets the text of a label from a background thread and waits for the operation to complete: display.syncExec( new Runnable() { public void run(){ label.setText(text); } });

6 :: How to config a plugin to start automatically during platform starts up?

Define the 'Eclipse-AutoStart=true' header in Manifest file.

7 :: What is the classpath of a plug-in?

The OSGi parent class loader. (Java boot class loader by default); The exported libraries of all imported plug-ins; The declared libraries of the plug-in and all its fragments.

8 :: Do we need to explicitly invoke

Application code must explicitly invoke the Image.dispose() method to release the operating system resources managed by each instance when those instances are no longer required. This is because that the Java finalization is too weak to reliably support management of operating system resources.

9 :: What is Display, what is Shell?

The Display class respresents the GUI process(thread), the Shell class represents windows.

10 :: How to resize my shell to get my changed widgets to lay out again?

A layout is only performed automatically on a Composite's children when the Composite is resized, including when it is initially shown. To make a Composite lay out its children under any other circumstances, such as when children are created or disposed, its layout() method must be called.