Saturday, November 2, 2013

SCJP/OCJP IZO-851 Java Dumps - Nine

Q1. Given:
1. class Exc0 extends Exception { }
2. class Exc1 extends Exc0 { }
3. public class Test {
4. public static void main(String args[]) {
5. try {
6. throw new Exc1();
7. } catch (Exc0 e0) {
8. System.out.println(“Ex0 caught”);
9. } catch (Exception e) {
10. System.out.println(“exception caught”);
11. }
12. }
13. }
What is the result?
A. Ex0 caught
B. exception caught
C. Compilation fails because of an error at line 2.
D. Compilation fails because of an error at line 6.
Answer: A
Q2. Given:
20. public float getSalary(Employee e) {
21. assert validEmployee(e);
22. float sal = lookupSalary(e);
23. assert (sal>0);
24. return sal;
25. }
26. private int getAge(Employee e) {
27. assert validEmployee(e);
28. int age = lookupAge(e);
29. assert (age>0);
30. return age;
31. }
Which line is a violation of appropriate use of the assertion mechanism?
A. line 21
B. line 23
C. line 27
D. line 29
Answer: A
Q3. Given:
1. public class A {
2. void A() {
3. System.out.println(“Class A”);
4. }
5. public static void main(String[] args) {
6. new A();
7. }
8. }
What is the result?
A. Class A
B. Compilation fails.
C. An exception is thrown at line 2.
D. An exception is thrown at line 6.
E. The code executes with no output.
Answer: E
Q4. Given:
1. class Bar { }
1. class Test {
2. Bar doBar() {
3. Bar b = new Bar();
4. return b;
5. }
6. public static void main (String args[]) {
7. Test t = new Test();
8. Bar newBar = t.doBar();
9. System.out.println(“newBar”);
10. newBar = new Bar();
11. System.out.println(“finishing”);
12. }
13. }
At what point is the Bar object, created on line 3, eligible for garbage collection?
A. After line 8.
B. After line 10.
C. After line 4, when doBar() completes.
D. After line 11, when main() completes.
Answer: C
Q5. Given:
1. interface Beta {}
2.
3. class Alpha implements Beta {
4. String testIt() {
5. return “Tested”;
6. }
7. }
8.
9. public class Main1 {
10. static Beta getIt() {
11. return new Alpha();
12. }
13. public static void main( String[] args ) {
14. Beta b = getIt();
15. System.out.println( b.testIt() );
16. }
17. }
What is the result?
A. Tested
B. Compilation fails.
C. The code runs with no output.
D. An exception is thrown at runtime.
Answer: B
Q6. Given:
11. public class Test {
12. public void foo() {
13. assert false;
14. assert false;
15. }
16. public void bar(){
17. while(true){
18. assert false;
19. }
20. assert false;
21. }
22. }
What causes compilation to fail?
A. Line 13
B. Line 14
C. Line 18
D. Line 20
Answer: D
Q7. Which statement is true?
A. Programs will not run out of memory.
B. Objects that will never again be used are eligible for garbage collection.
C. Objects that are referred to by other objects will never be garbage collected.
D. Objects that can be reached from a live thread will never be garbage collected.
E. Objects are garbage collected immediately after the system recognizes they are
eligible.
Answer: D
Q8. In which two cases does the compiler supply a default constructor for class A? (Choose
two)
A. class A {
}
B. class A {
public A() {}
}
C. class A {
public A(int x) {}
}
D. class Z {}
class A extends Z {
void A() {}
}
Answer: A, D
Q9. Given:
1. public class ReturnIt {
2. return Type methodA(byte x, double y) {
3. return (short)x / y * 2;
4. }
5. }
What is the narrowest valid returnType for methodA in line2?
A. int
B. byte
C. long
D. short
E. float
F. double
Answer: F

SCJP/OCJP IZO-851 Java Dumps - Eight

Q1. Given:
1. public abstract class Test {
2. public abstract void methodA();
3.
4. public abstract void methodB()
5. {
6. System.out.println(“Hello”);
7. }
8. }
Which two changes, independently applied, allow this code to compile? (Choose two)
A. Add a method body to methodA.
B. Replace lines 5 – 7 with a semicolon (“;”).
C. Remove the abstract qualifier from the declaration of Test.
D. Remove the abstract qualifier from the declaration of methodA.
E. Remove the abstract qualifier from the declaration of methodB.
Answer: B, E
Q2. Given:
1. public class Test {
2. public static void main(String Args[]) {
3. int i =1, j = 0;
4. switch(i) {
5. case 2: j +=6;
6. case 4: j +=1;
7. default: j +=2;
8. case 0: j +=4;
9. }
10. System.out.printIn(“j =” +j);
11. }
12. }
What is the result?
A. 0
B. 2
C. 4
D. 6
E. 9
F. 13
Answer: D
Q3. Given:
1. class A {
2. }
3. class Alpha {
4. private A myA = new A();
5.
6. void dolt( A a ) {
7. a = null;
8. }
9. void tryIt() {
10. dolt( myA );
11. }
12. }
Which two statements are correct? (Choose two)
A. There are no instanced of A that will become eligible for garbage collection.
B. Explicitly setting myA to null marks that instance to be eligible for garbage collection.
C. Any call on tryIt() causes the private instance of A to be marked for garbage
collection.
D. Private instances of A become eligible for garbage collection when instances of Alpha
become eligible for garbage collection.
Answer: B, D
Q4. Given:
1. class Super {
2. public int i = 0;
3.
4. public Super(String text) {
5. i = 1;
6. }
7. }
8.
9. public class Sub extends Super {
10. public Sub(String text) {
11. i = 2;
12. }
13.
14. public static void main(String args[]) {
15. Sub sub = new Sub(“Hello”);
16. System.out.println(sub.i);
17. }
18. }
What is the result?
A. 0
B. 1
C. 2
D. Compilation fails.
Answer: D
Q5. Given:
11. int i = 1,j = 10;
12. do{
13. if (i>j) {
14. continue;
15. }
16. j--;
17. } while (++i <6);
18. System.out.println(“i = “ +i+” and j = “+j);
What is the result?
A. i = 6 and j = 5
B. i = 5 and j = 5
C. i = 6 and j = 4
D. i = 5 and j = 6
E. i = 6 and j = 6
Answer: D
Q6.  Which fragment is an example of inappropriate use of assertions?
A. assert (!(map.contains(x)));
map.add(x);
B. if (x > 0) {
} else {
assert (x==0);
}
C. public void aMethod(int x) {
assert (x > 0);
}
D. assert (invariantCondition());
return retval;
E. switch (x) {
case 1: break;
case 2: creak;
default: assert (x == 0);
Answer: C
Q7. Given:
1. public class X {
2. public X aMethod() { return this;}
3. }
1. public class Y extends X {
2.
3. }
Which two methods can be added to the definition of class Y? (Choose two)
A. public void aMethod() {}
B. private void aMethod() {}
C. public void aMethod(String s) {}
D. private Y aMethod() { return null; }
E. public X aMethod() { return new Y(); }
Answer: C, E
Q8. Given:
1. public class X {
2. public static void main(String [] args) {
3. try {
4. badMethod();
5. System.out.print(“A”);
6. }
7. catch (Exception ex) {
8. System.out.print(“B”);
9. }
10. finally {
11. System.out.print(“B”);
12. }
13. System.out.print(“D”);
14. }
15. public static void badMethod() {
16. throw new Error();
17. }
18. }
What is the result?
A. ABCD
B. Compilation fails.
C. C is printed before exiting with an error message.
D. BC is printed before exiting with an error message.
E. BCD is printed before exiting with an error message.
Answer: C
Q9. You want subclasses in any package to have access to members of a superclass. Which is
the most restrictive access that accomplishes this objective?
A. public
B. private
C. protected
D. transient
E. default access
Answer: C

SCJP/OCJP IZO-851 Java Dumps - Seven

Q1.Given:
11. switch(x) {
12. default:
13. System.out.printIn(“Hello”);
14. }
Which two are acceptable types for x? (Choose two)
A. byte
B. long
C. char
D. float
E. Short
F. Long
Answer: A, C
Q2. Given:
1. public class X {
2. public static void main(String [] args) {
3. try {
4. badMethod();
5. System.out.print(“A”);
6. }
7. catch (RuntimeException ex) {
8. System.out.print(“B”);
9. }
10. catch (Exception ex1) {
11. System.out.print(“C”);
12. }
13. finally {
14. System.out.print(“D”);
15. }
16. System.out.print(“E”);
17. }
18. public static void badMethod() {
19. throw new RuntimeException();
20. }
21. }
What is the result?
A. BD
B. BCD
C. BDE
D. BCDE
E. ABCDE
F. Compilation fails.
Answer: C
Q3. Given:
1. public class Test {
2. public static void main(String[] args) {
3. int x = 0;
4. assert (x > 0) ? “assertion failed” : “assertion passed”;
5. System.out.println(“Finished”);
6. }
7. }
What is the result?
A. finished
B. Compilation fails.
C. An AssertionError is thrown and finished is output.
D. An AssertionError is thrown with the message “assertion failed”.
E. An AssertionError is thrown with the message “assertion passed”.
Answer: B
Q4. Given:
1. public class ReturnIt {
2. return Type methodA(byte x, double y) {
3. return (long)x / y * 2;
4. }
5. }
What is the narrowest valid returnType for methodA in line2?
A. int
B. byte
C. long
D. short
E. float
F. double
Answer: F
Q5. Given:
1. public class OuterClass {
2. private double d1 = 1.0;
3. // insert code here
4. }
Which two are valid if inserted at line 3? (Choose two)
A. static class InnerOne {
public double methoda() { return d1; }
}
B. static class InnerOne {
static double methoda() { return d1; }
}
C. private class InnerOne {
public double methoda() { return d1; }
}
D. protected class InnerOne {
static double methoda() { return d1; }
}
E. public abstract class InnerOne {
public abstract double methoda();
}
Answer: C, E
Q6. Given:
1. public class Foo {
2. public void main( String[] args ) {
3. System.out.printIn( “Hello” + args[0] );
4. }
5. }
What is the result if this code is executed with the command line?
java Foo world
A. Hello
B. Hello Foo
C. Hello world
D. Compilation fails.
E. The code does not run.
Answer: E
Q7. Given:
11. public void foo( boolean a, boolean b ){
12. if( a ) {
13. System.out.println( “A” );
14. } else if ( a && b ) {
15. System.out.println( “A&&B” );
16. } else {
17. if ( !b ) {
18. System.out.println( “notB” );
19. } else {
20. System.out.println( “ELSE” );
21. }
22. }
23. }
What is correct?
A. If a is true and b is true then the output is “A&&B”.
B. If a is true and b is false then the output is “notB”.
C. If a is false and b is true then the output is “ELSE”.
D. If a is false and b is false then the output is “ELSE”.
Answer: C
Q8. Which two cause a compiler error? (Choose two)
A. int[] scores = {3, 5, 7};
B. int [][] scores = {2,7,6}, {9,3,45};
C. String cats[] = {“Fluffy”, “Spot”, “Zeus”};
D. boolean results[] = new boolean [3] {true, false, true};
E. Integer results[] = {new Integer(3), new Integer(5), new
Integer(8)};
F. String[] dogs = new String[]{new String(“Fido”),new
String(“Spike”), new String(“Aiko”)};
Answer: B, D
Q9. Given:
11. int i = 0, j = 5;12. tp; for (;;) {
12. i++;
13. for(;;) {
14. if (i> --j) {
15. break tp;
16. break tp;
17. }
18. }
19. System.out.printIn(“i=” +i “,j =”+j);
What is the result?
A. i = 1, j = 0
B. i = 1, j = 4
C. i = 3, j = 4
D. i = 3, j = 0
E. Compilation fails.
Answer: E

Thursday, October 17, 2013

Spring Interview Questions - Three

Q1: What are types of IoC containers? Explain them.

Ans: There are two types of IoC containers:

  • Bean Factory container: This is the simplest container providing basic support for DI .The BeanFactory is usually preferred where the resources are limited like mobile devices or applet based applications
  • Spring ApplicationContext Container: This container adds more enterprise-specific functionality such as the ability to resolve textual messages from a properties file and the ability to publish application events to interested event listeners.
·     Q2: Give an example of BeanFactory implementation.

·    Ans: The most commonly used BeanFactory implementation is the XmlBeanFactory class. This container reads the configuration metadata from an XML file and uses it to create a fully configured system or application.

·     Q3: What are the common implementations of the ApplicationContext?

·     Ans: The three commonly used implementation of 'Application Context' are:

  • FileSystemXmlApplicationContext: This container loads the definitions of the beans from an XML file. Here you need to provide the full path of the XML bean configuration file to the constructor.
  • ClassPathXmlApplicationContext: This container loads the definitions of the beans from an XML file. Here you do not need to provide the full path of the XML file but you need to set CLASSPATH properly because this container will look bean configuration XML file in CLASSPATH.
  • WebXmlApplicationContext: This container loads the XML file with definitions of all beans from within a web application. 
Q4: What is the difference between Bean Factory and ApplicationContext?

A: Following are some of the differences:
  1. Application contexts provide a means for resolving text messages, including support for i18n of those messages.
  2. Application contexts provide a generic way to load file resources, such as images.
  3. Application contexts can publish events to beans that are registered as listeners.
  4. Certain operations on the container or beans in the container, which have to be handled in a programmatic fashion with a bean factory, can be handled declaratively in an application context.
  5. The application context implements MessageSource, an interface used to obtain localized messages, with the actual implementation being pluggable.

Q5: What are Spring beans?

Ans: The objects that form the backbone of your application and that are managed by the Spring IoC container are called beans. A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC container. These beans are created with the configuration metadata that you supply to the container, for example, in the form of XML <bean/> definitions.

Q6: What does a bean definition contain?

Ans: The bean definition contains the information called configuration metadata which is needed for the container to know the followings:
  •          How to create a bean
  •          Bean's lifecycle details
  •          Bean's dependencies

Q7: How do you provide configuration metadata to the Spring Container?

Ans: There are following three important methods to provide configuration metadata to the Spring Container:
  •          XML based configuration file.
  •          Annotation-based configuration
  •          Java-based configuration

Q8: How do add a bean in spring application?

Ans: Check the following example:
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

   <bean id="helloWorld" class="com.tutorialspoint.HelloWorld">
       <property name="message" value="Hello World!"/>
   </bean>

</beans>

Q9: How do you define a bean scope?

Ans: When defining a <bean> in Spring, you have the option of declaring a scope for that bean. For example, to force Spring to produce a new bean instance each time one is needed, you should declare the bean's scope attribute to be prototype. Similar way if you want Spring to return the same bean instance each time one is needed, you should declare the bean's scope attribute to besingleton. 

Hibernate Interview Questions - Three

Q1. Should all the mapping files of hibernate have .hbm.xml extension to work properly?
Ans: No, having .hbm.xml extension is a convention and not a requirement for hibernate mapping file names. We can have any extension for these mapping files. But this is the best practice to follow this extension.
Q2. How do we create session factory in hibernate?

Ans: To create a session factory in hibernate, an object of configuration is created first which refers to the path of configuration file and then for that configuration, session factory is created as given in the example below:
Configuration config = new Configuration();
config.addResource(&amp;quot;myinstance/configuration.hbm.xml&amp;quot;);
config.setProperties( System.getProperties() );
SessionFactory sessions = config.buildSessionFactory();
Q3. What is meant by Method chaining?
Ans: Method chaining is a programming technique that is supported by many hibernate interfaces. This is less readable when compared to actual java code. And it is not mandatory to use this format. Look how a SessionFactory is created when we use method chaining.
SessionFactory sessions = new Configuration()
.addResource(“myinstance/MyConfig.hbm.xml”)
.setProperties( System.getProperties() )
.buildSessionFactory();
Q4. What does hibernate.properties file consist of?
Ans: This is a property file that should be placed in application class path. So when the Configuration object is created, hibernate is first initialized. At this moment the application will automatically detect and read this hibernate.properties file.
hibernate.connection.datasource = java:/comp/env/jdbc/AuctionDB
hibernate.transaction.factory_class = net.sf.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class = net.sf.hibernate.transaction.JBossTransactionManagerLookup
hibernate.dialect = net.sf.hibernate.dialect.PostgreSQLDialect
Q5. What should SessionFactory be placed so that it can be easily accessed?
Ans: As far as it is compared to J2EE environment, if the SessionFactory is placed in JNDI then it can be easily accessed and shared between different threads and various components that are hibernate aware. You can set the SessionFactory to a JNDI by configuring a property hibernate.session_factory_name in the hibernate.properties file.
Q6. What are POJOs and what’s their significance?
Ans: POJO stands for plain old java objects. These are just basic JavaBeans that have defined setter and getter methods for all the properties that are there in that bean. Besides they can also have some business logic related to that property. Hibernate applications works efficiently with POJOs rather than simple java classes. Use of POJOs instead of simple java classes results in an efficient and well-constructed code.
Q7. What is ORM metadata?

Ans: ORM tools require a metadata format for the application to specify the mapping between classes and tables, properties and columns, associations and foreign keys, Java types and SQL types. This information is called the object/relational mapping metadata. It defines the transformation between the different data type systems and relationship representations.

Q8. What’s HQL?

Ans: HQL is the query language used in Hibernate which is an extension of SQL. HQL is very efficient, simple and flexible query language to do various types of operations on relational database without writing complex database queries.

Q9. What are the different types of property and class mappings?

Typical and most common property mapping
<property name=”description” column=”DESCRIPTION” type=”string”/>
Or 

<property name=”description” type=”string”>
<column name=”DESCRIPTION”/>
</property>

Derived properties
<property name=”averageBidAmount” formula=”( select AVG(b.AMOUNT) from BID b
where b.ITEM_ID = ITEM_ID )” type=”big_decimal”/>

Typical and most common property mapping
<property name=”description” column=”DESCRIPTION” type=”string”/>
Controlling inserts and updates
<property name=”name” column=”NAME” type=”string”
insert=”false” update=”false”/>

Saturday, October 12, 2013

IBM RFT-000-842 Dumps - Six

Q1. Which branches under Preferences contain specific settings to enable the ClearCase integration?

A. Workbench and Test
B. Functional Test and Run/Debug
C. Workbench and Team
D. Plug-in Development and Functional Test

Ans: C

Q2. When you set break points, why does the script not stop at the break points and switch over to the debug perspective?

A. This is a known eclipse bug in version 6.1 and has been corrected in the latest release or last interim fix
B. The break point has already been recognized by the JVM and the break point needs to be toggled
C. Either the icon or debug functional tester script was not invoked or the shift + F11 menu option was not invoked
D. The debug perspective is not listed as an available perspective when trying to debug a script

Ans: C

Q3. When you enable web browsers, what is the best way to select the Linux or UNIX web browser?

A. You use the Search button, choose Search All, select the executable, and provide all the needed parameters.
B. Modify the registry to enable Linux or Unix web browser support
C. Modify the Internet Explorer settings to refer to a Linux or Unix web browser
D. You use the Search button, choose Search In, browse to the executable, and provide all the needed parameters

Ans: D

Q4. In which situation is it best to use the Browser Enablement Diagnostic tool?

A. when the web browser does not launch when invoked through Functional Tester
B. when testers are trying to determine if their web browsers are compatible with Functional Tester
C. when Functional Tester is in the recording process and no HTML objects are being recognized
D. when Functional Tester is not able to launch the viewlet comparator on the HTML log

Ans: C

Q5. You cannot access help file from Rational Functional Tester. You receive an error or the page loads slowly. How can this be fixed?

A. talk to the LAN Administrator to see if there is a problem with the corporate network or if the ISP is having performance issues
B. in Network properties, change the IP configuration to static IP and provide a valid IP address, which can be obtained from the LAN Administrator
C. in the Network Advanced settings for proxies, remove "127.0.0.1; localhost" from the Exceptions if these addresses are listed
D. if your host was configured to use DHCP for IP assignment, make sure that the "Automatically detect settings" checkbox is cleared

Ans: D

Q6. Where do you set the option for switching to Test Debug perspective when debugging?

A. Preferences > Functional Test > Workbench > Advanced
B. Preferences > Java > Debug
C. Preferences > Run/Debug > Console
D. Preferences > Test

Ans: A

Q7. How do you add line numbers within the script editors view?

A. use a third party plug-in because this option is not available within the tools interface
B. download the latest version of the plug-in
C. select the option under the main menu > Window > Preferences > Debug
D. select the option under the main menu > Window > Preferences > Editor

Ans: D

Q8. How many default Java environments can you have within one configuration of Rational Functional Tester?

A. one for each instance of the application under test
B. as many default Java environments as are needed to do testing
C. You can change the java environments dynamically when testing different applications.
D. only one

Ans: D

Q9. What is the best practice when changing object maps that are already assigned to Functional Test projects?

A. highlight the project in the Functional Test projects, right-click, select Properties > Functional Test project and browse to the new object map
B. record a new script, select the new Functional Test project, click next and browse to the new test object map
C. modify the XML file, configurations.rftcfg, locate the object map section, enter the proper object and save the XML file
D. right-click the test object map in the script explorer, choose the Open option and make necessary changes

Ans: A

IBM RFT-000-842 Dumps - Five

Q1. Given the following settings: Maximum acceptable recognition score 10000 Last chance recognition score 20000 Warn if accepted score is greater than 10000 Maximum time to attempt to find Test Object 20. How will RFT behave at runtime if the recognition score of a found object is 10000?

A. It will accept the found object after waiting for 20 seconds for an object with better recognition and write an Ambiguous Recognition Warning to the log.
B. It will accept the found object after waiting for 20 seconds for an object with better recognition and write nothing to the log.
C. It will accept the found object immediately and write an Ambiguous Recognition Warning to the log.
D. It will accept the found object immediately and write nothing to the log.
E. It will immediately throw an ObjectNotFoundException and write an Ambiguous Recognition Failure to the log.
F. It will throw an ObjectNotFoundException after waiting for 20 seconds for an object with better recognition and write an Ambiguous Recognition Failure to the log.

Ans: D

Q2. Which feature is NOT offered by the Object Map interface?

A. the ability to delete test objects that are not referenced by any scripts
B. the ability to delete scripts that do not reference any test objects in the object map
C. the ability to find all test objects not referenced by scripts
D. the ability to merge two test objects

Ans: B

Q3. What is the minimum weight that can be assigned to a recognition property?

A. no value (leave blank)
B. 0
C. 1
D. 10
E. 100

Ans: B

Q4. Which regular expression offers a successful way to ensure the order number is a 1 to 3-digit number in the following format? Your order number is 125.

A. Your order number is [0-9]{3}.
B. Your order number is [0-9]{3}\.
C. Your order number is [0-9]{1,3}.
D. Your order number is [0-9]{1,3}\.

Ans: D

Q5. What are the default values for retry interval and maximum retry time?

A. 2 second retry interval, 20 seconds maximum retry time
B. 5 second retry interval, 30 seconds maximum retry time
C. 1 second retry interval, 5 seconds maximum retry time
D. 3 second retry interval, 15 seconds maximum retry time

Ans: A

Q6. Which objects can be tested with a State verification point?

A. A combo box and a list box
B. A label and a text box
C. A table and a tree view
D. A checkbox and a toggle button

Ans: D

Q7. What is an appropriate use of the command Test Object > Highlight when working with verification points?

A. It is used to highlight the test object at playback (to identify what is being tested).
B. It is used to create a new verification point in the current script
C. It is used to highlight the test object (to verify it is found in the application)
D. It is used to identify all objects in an application which can be tested

Ans: C

Q8. Which statement is true about the "Time Delayed" method when you are creating verification points in your scripts?

A. It introduces a fixed delay after a previous action before the verification point is tested
B. It allows a verification point to keep trying until the time specified has elapsed
C. It gives the tester time to reveal pop-up objects (such as menus) during the creation of a verification point
D. It gives the tester the opportunity to specify a delay after a verification point fails

Ans: C

Q9. Given the following manual verification point: vpManual ("manual1", "The rain in Spain", "The Rain in Spain").performTest(); What are the results?
A. The two strings are the same, and a pass would be generated in the log
B. The two strings are different, and a fail would be generated in the log
C. The syntax is incorrect, so this would not compile
D. This will compile but the parameters are mixed up, and a fail would be recorded in the log. The correct syntax is: vpManual ("The rain in Spain", "The Rain in Spain", "manual1").performTest();

Ans: B

iVTech Pageviews