File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes IBM Mock test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "IBM Mock test " Watch "IBM Mock test " New topic
Author

IBM Mock test

Vegad Arvind
Ranch Hand

Joined: Jan 10, 2001
Posts: 42

Hi
Two question from IBM mock

1)
Based upon the code below, what is true about the Frame constructed:

public LayoutFrame() {
2. super();
3. Button b = new Button("What is my location?");
4. Panel p1 = new Panel();
5. p1.add(b);
6. add(p1);
7. }
a) The push button is located in the center of the Frame and will expand to all sides.

b) The push button is located at the top of the Frame and centered.

c) The code does compile successfully because the superclass constructor is called.

d) The size of the push button is just larger than the label.

e) The push button is located in the upper-left hand corner of the Frame.


Multiple Select - Please select all of the correct answers (this question has 2 correct choices).

2)
Assuming the code below is part of a Frame subclass, which are true?

1.public LayoutFrame() {
2. setLayout(new GridLayout(1, 3));
3. Button b = new Button("What is b location?");
4. Button a = new Button("What is a location?");
5. Panel p1 = new Panel();
6. p1.setLayout(new GridLayout(2, 1));
7. p1.add(a);
8. p1.add(b);
9. add(p1);
10. }
a) Two push buttons are added. Each is half the size of the entire Frame vertically and the entire width, with a above b.

b) Two push buttons are added. Each is half the width of the Frame and the entire length vertically, with a above b.

c) There is a compile error since there is no receiving object specified for the methods in lines 2 and 9.

d) There is a compile error since the superclass constructor is not called.

Single Select - Please select the best answer (one and only one choice must be selected).

According to me Answer is :
Ans 1: code compile successfully and there is no output becoz no setvisible,setsize method in code.
Ans 2: Compile successfully - no output.

Que 1 say there is two correct choice.
Que 1 say there is only one correct choice.

pls clarify.
Best Regards
Avi
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

I see answer "a" as being the only correct answer to both questions. Two points on question one. The superclass constructer will be called anyway without the specific call so answer "c" is "wrong"(the new test tells you how many answers are correct). Point2 this is important! on the real test in the instructions they tell you to assume that all other code for the class is complete and correct. So in the case of question one you should assume that a LayoutFrame object was created and set visible in the main() method. Im not sure what your question was about Question 2.


SCJP
Visit my download page
greg clarke
Greenhorn

Joined: Oct 06, 2000
Posts: 25
Avi
These 2 questions show only the relevant constructors and you can safely assume that the surrounding code will do all necessary basic operations, like setting size and making visible.
The first question does have 2 correct choices. It is asking you about the default layout manager for a Panel and what happens when you add components to one container and then add that container to another container.
The second question does indeed have a single correct answer. You need to understand GridLayout constructors and behaviour to answer this one.
I you get stuck, try running the sample code as part of a program. Here's a sample.

Hope this helps.
greg clarke
Greenhorn

Joined: Oct 06, 2000
Posts: 25
Originally posted by Randall Twede:
I see answer "a" as being the only correct answer to both questions. Two points on question one. The superclass constructer will be called anyway without the specific call so answer "c" is "wrong"(the new test tells you how many answers are correct). Point2 this is important! on the real test in the instructions they tell you to assume that all other code for the class is complete and correct. So in the case of question one you should assume that a LayoutFrame object was created and set visible in the main() method. Im not sure what your question was about Question 2.

Randal
"a" is not the correct answer in the first case. There are 2 correct answers and "a" is not one of them. Try the code.
Avi
If you don't yet understand the questions, run the code to see what they produce. You might still have questions at that point, and I suggest you post them then.
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
The answer to one is b and d in my opinion. And the aswer to number two is a in my opinion.
natarajan meghanathan
Ranch Hand

Joined: Feb 01, 2001
Posts: 130
I too think the answer to one is b and d. The answer to two is a.

Sun Certified Programmer for Java 2 Platform
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IBM Mock test
 
Similar Threads
layout
Mystery GridBagLayout
Frames
IBM Mock question
About GridLayout