aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JQ+:Question ID :954959231549 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JQ+:Question ID :954959231549" Watch "JQ+:Question ID :954959231549" New topic
Author

JQ+:Question ID :954959231549

Rahul Ramachandran
Ranch Hand

Joined: Feb 27, 2001
Posts: 48
Which of the following will add a Component 'comp' to a container 'c', if it's layout is governed by GridLayout 'g'?
1) c.add(comp);
2) c.add("Center", comp);
3) g.add(comp);
4) g.addLayoutComponent("Component Name", comp);
5) c.add(comp,-1);
The correct answers are given as 1,4 and 5.
I felt 2) should also be among the correct answers.
(I am quoting the Java API documentation)(look at (e))
a)Component add(Component comp)
Adds the specified component to the end of this container.
b)Component add(Component comp, int index)
Adds the specified component to this container at the given position.
c)void add(Component comp, Object constraints)
Adds the specified component to the end of this container.
d)void add(Component comp, Object constraints, int index)
Adds the specified component to this container with the specified constraints at the specified index.
e)Component add(String name, Component comp)
Adds the specified component to this container.
jeena jose
Ranch Hand

Joined: May 06, 2001
Posts: 69
the following code working fine.
i feel answer is 1,2,4,5.
import java.awt.*;
public class CompLay extends Frame{
public static void main(String argv[]) {
CompLay cl = new CompLay(); }
CompLay() {
Panel p = new Panel();
p.setLayout(new GridLayout());
p.add("Center",new Button("One"));
add("South",p);
setSize(300,300);
setVisible(true);
}}
Panel p = new Panel();
p.setLayout(new GridLayout());
p.setBackground(Color.pink);
p.add("Center",new Button("One"));
add("South",p);
setSize(300,300);
setVisible(true);
}}
jeena jose
Ranch Hand

Joined: May 06, 2001
Posts: 69
the following code working fine.
i feel answer is 1,2,4,5.
import java.awt.*;
public class CompLay extends Frame{
public static void main(String argv[]) {
CompLay cl = new CompLay(); }
CompLay() {
Panel p = new Panel();
p.setLayout(new GridLayout());
p.add("Center",new Button("One"));
add("South",p);
setSize(300,300);
setVisible(true);
}}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JQ+:Question ID :954959231549