Friday, October 26, 2007

Java interview questions Part31


10. State the transactional behavior in a given scenario for an enterprise bean method with a specified transactional deployment descriptor.
11.Given a requirement specification detailing security and flexibility needs, identify architectures that would fulfill those requirements.
12. Identify costs and benefits of using an intermediate data-access object between an entity bean and the data resource.
13. State the benefits of bean pooling in an EJB container.
14. State the benefits of Passivation in an EJB container.
15. State the benefit of monitoring of resources in an EJB container.
16. Explain how the EJB container does lifecycle management and has the capability to increase scalability.
17. Given a scenario description, distinguish appropriate from inappropriate protocols to implement that scenario.
18. Identify a protocol, given a list of some of its features, where the protocol is one of the following: HTTP, HTTPS, IIOP, JRMP.
19. Select from a list, common firewall features that might interfere with the normal operation of a given protocol.
20. State the benefits of using design patterns.

Given that 1119280000000L is roughly the number of milliseconds from Jan. 1, 1970, to June 20, 2005, and that you want to print that date in German, using the LONG style such that "June" will be displayed as "juni", complete the code using the fragments below. Note: you can use each fragment either zero or one times, and you might not need to fill all of the slots.

Code:

import Java.___________

import Java.___________

class DateTwo {
public static void main(String[] args) {
Date d = new Date(1119280000000L);

DateFormat df =__________________________

_____________ , ______________ ) ;

System.out.println(_____________
}
}

Fragments:

io.*; new DateFormat( Locale.LONG
nio.*; DateFormat.getlnstance( Locale.GERMANY
util.*; DateFormat.getDatelnstance( DateFormat.LONG
text.*; util.regex; DateFormat.GERMANY
date.*; df.format(d)); d.format(df));



12.
Given:

import java.io.*;
class Directories {
static String [] dirs = {"dirl", "dir2"};
public static void main(String [] args){
for (String d : dirs) {

// insert code 1 here

File file = new File(path, args[0]) ;

// insert code 2 here
}
}
}

and that the invocation

java Directories file2.txt


is issued from a directory that has two subdirectories "dir1" and "dir1", and that "dir1" has a file "file1.txt" and "dir2" has a file "file2.txt", and the output is "false true"; which set(s) of code fragments must be inserted? (Choose all that apply.)

String path = d;

System.out.print (file.exists() + " ");

String path = d;

System.out .print (file . isFile() + " ");

String path = File.separator + d;

System.out .print (file . exists() + " ");

String path = File.separator + d;

System.out.print(file.isFile() +


13.
Given:

class Polish {
public static void main(String[] args) {
int x = 4 ;
StringBuffer sb = new StringBuffer("..fedcba");
sb.delete(3,6);
sb.insert(3, "az");
if(sb.length() > 6) x = sb.indexOf("b");
sb.delete((x-3), (x-2));
System.out.println(sb);
} }

What is the result?

.faza

.fzba

..azba

.fazba

..fezba

Compilation fails.

An exception is thrown at runtime.


14.
Given:

1. import java.util.*;
2. class Brain {
3. public static void main(String[] args) {

4. // insert code block here

5. }
6. }

Which, inserted independently at line 4, compile and produce the output "123 82"? (Choose all that apply.)

Scanner sc = new Scanner("123 A 3b c,45, x5x,76 82 L");

while(sc.hasNextInt()) System.out.print(sc.nextlnt() + " ");

Scanner sc = new Scanner("123 A 3b c,45, x5x,76 82 L").

useDelimiter(" ");

while(sc.hasNextlnt()) System.out.print(sc.nextlnt() + " ");

Scanner sc = new Scanner("123 A 3b c,45, x5x,76 82 L");

useDelimiter(" ");

while(sc.hasNext()) {

if (sc.hasNextlnt()) System.out.print(sc.nextlnt() + " ") ;

else sc.next(); }

Scanner sc = new Scanner("123 A 3b c,45, x5x,76 82 L").

useDelimiter(" ");

while(sc.hasNext()) }

if (sc.hasNextlnt()) System.out.print(sc.nextlnt() + " ") ;

else sc.next(); }

Scanner sc = new Scanner ("123 A 3b c,45, x5x, 76 82 L");

do {

if (sc.hasNextInt()) System.out.print (sc.nextInt() + "");

} while (sc.hasNext());

Scanner sc = new Scanner("12,3 A 3b c,45, x5x, 76 82 L").

useDelimiter(" ");

do {

if(sc.hasNextlnt()) System.out.print(sc.nextInt() + " ");

} while ( sc.hasNext() );


15.
Given:

import java.io.*;

public class TestSer {
public static void main(String[] args) {
SpecialSerial s = new SpecialSerial() ;
try {
ObjectOutputStream os = new ObjectOutputStream(
new FileOutputStream("myFile"));
os.writeObject(s); os. close();
System.out.print( + + s.z + " ");

ObjectlnputStream is = new ObjectlnputStream(
new FileInputStream("myFile"));
SpecialSerial s2 = (SpecialSerial)is.readObject();
is.close();
System.out.println(s2.y + " " + s2.z);
} catch (Exception x) {System.out.println("exc"); }
}
}
class SpecialSerial implements Serializable {
transient int y = 7;
static int z = 9;
}

Which are true? (Choose all that apply.)

Compilation fails.

The output is 10 0 9

The output is 10 0 10

The Output is 10 7 9

The output is 10 7 10

In order to alter the standard deserialization process you would override the readobject() method in SpecialSerial.

In order to alter the standard deserialization process you would override the defaultReadObject() method in SpecialSerial.

0 comments:

Advertisement

 

Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com