How To Exam?

a knowledge trading engine...


Andhra University 2007 B.E Computer Science s - exam paper

Wednesday, 01 May 2013 05:55Web
ques. 6:

How is the ButtonGroup class used?
Answer:

A ButtonGroup object is used with a set of radio buttons (or radio button menu items), to make sure that at most 1 of the radio buttons in the group can be opted at any provided time. To use the ButtonGroup class, you have to create a ButtonGroup object, grp. Then every radio button, rb, that is supposed to be part of the group is added to the group by calling grp.add(rb). Nothing further needs to be done with the ButtonGroup object.
ques. 7:

What does the acronym MVC stand for, and how does it apply to the JTable class?
Answer:

MVC stands for "Model-View-Controller." In a JTable, the view is the true visible component on the screen. The model is the collection of data that specifies, among other things, what appears in every cell of the table and in the column headings. The model is represented by a separate object from the object that represents the view. The controller is responsible for interaction with the user. It consists mostly of a bunch of listener objects that listen for events generated when the user interacts with the table. The listeners respond by making modifications in the model, which will in turn reason a change in the view.
ques. 8:

define the picture that is produced by the subsequent paintComponent() method:

public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.translate( getWidth()/2, getHeight()/2 );
g2.rotate( 30 * Math.PI / 180 );
g2.fillRect(0,0,100,100);
}

Answer:

This indicates a filled black square that is 100-by-100 pixels in size. The corner of the square is at the center of the component that is being painted, and the top side of the square descends at a 30 degree angle from that point. (The translate command moves the origin, (0,0) to the point (getWidth()/2,getHeight()/2), so that when the fillRect command places the corner of the square at (0,0), the corner truly appears at the center of the component. Furthermore, the rotate command rotates the picture by 30 degrees in a clockwise direction about the origin. This means that the top of the square is rotated from the horizontal position onto a line that is 30 degrees clockwise of the horizontal. That line descends at a 30 degree angle.
ques. 9:

What is meant by Internationalization of a program?
Answer:

Internationalization refers to writing the program in a way that will make it easy to adapt the program for use in a variety of "locales." For example, it should be easy to translate all the strings that are used in the program into other languages. To make this possible the strings should not be hard coded into the program itself. Instead, they are placed in a separate resource file, so that the program can be translated into a different language simply by writing a resource file for that language. Internationalization also applies to the format that is used for dates and numbers.)
ques. 10:

Suppose that the class that you are writing has an instance method doOpen() (with no parameters) that is meant to be used to open a file opted by the user. Write a code segment that creates an Action that represents the action of opening a file. Then show how to create a button and a menu item from that action.
Answer:

Here is the code for the 3 parts of the problem:

Action openAction = new AbstractAction( "Open..." ) {
public void actionPerformed( ActionEvent e ) {
doOpen();
}
};

JButton openButton = new JButton( openAction );

JMenuItem openCommand = new JMenuItem( openAction );

(Since Action is only an interface, the class AbstractAction has to be used to create the action object. The most natural way to write the code is to create an anonymous inner class that as a subclass of AbstractAction. This subclass must describe the actionPerformed() method -- which in this case only has to call the doOpen() method. As an option to createing the JMenuItem, the action could have simply been added directly to a JMenu. By the way, the "..." in the name of the action is there, by convention, to tell the user that selecting this command will reason a dialog box to pop up.)




( 0 Votes )

Add comment


Security code
Refresh

Earning:   Approval pending.
You are here: PAPER Andhra University 2007 B.E Computer Science s - exam paper