The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Seeing is believing

Posted by richard on January 27, 2001 at 4:50 AM

> .State which of the following statements are True
> (1) Java language support multi-dimentional arrays

Sure it does:

static final int ROWS = 5;
static final int COLS = 5;
Button square [][] = new Button[ROWS][COLS]; // button grid;

// now add them to a panel (theSquare), applet or whatever:

// for each array element

for (int c = 0; c < COLS; c++)
for (int r = 0; r < ROWS; r++)
square[r][c] = new Button("some label - another 2D array, say");

theSquare.add( square[r][c] ); // add the element
square[r][c].addActionListener(this); // add action listener

now you have an array of buttons to press!

> (2) StringBuffer class is alternative to String class

here's a quote from

"public final class StringBuffer
extends Object
implements Serializable
A string buffer implements a mutable sequence of characters. A string buffer is like a String, but can be modified...."

> (4) You cannot instantiate objects of interfaces or abstract classes.

> we can even instantiate interface.(BILL BROGDEN EXAM CRAM)

'fraid not. Consider the common interface ActionListener, you cannot have a new ActionListener() ie instantiate an ActionerListener object becuase it has no constructor. On the other hand you MUST implement its abstract methods if you use the interface and don't have an actionPerformed(ActionEvent e) method it won't compile.

Hope this helps. As to your later submission about true and false... true is true and false is false!! No further help available... (not here anyway)

best wishes and good luck on future tests



Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us