-
Given:
https://assets.asklib.com/images/image2/2018080116102651104.jpg
Which code fragment, inserted at line 23, allows the code to compile?()
A . df = new DateFormat();
B . df = Date.getFormat();
C . df = date.getFormat();
D . df = DateFormat.getFormat();
E . df = DateFormat.getInstance()
-
Which code fragment, inserted at line 24, outputs "123abc 123abc"?()https://assets.asklib.com/images/image2/2018080115325081380.jpg
A . sb1.append("abc"); s1.append("abc");
B . sb1.append("abc"); s1.concat("abc");
C . sb1.concat("abc"); s1.append("abc");
D . sb1.concat("abc"); s1.concat("abc");
E . sb1.append("abc"); s1=s1.concat("abc");
F . sb1.concat("abc"); s1=s1.concat("abc");
-
Given:
https://assets.asklib.com/images/image2/2018080210080511517.jpg
https://assets.asklib.com/images/image2/2018080210075661615.jpg
Which two code fragments, inserted independently at line 13, will compile?()
A . super(name, baseSalary);
B . this.commission = commission;
C . super();this.commission = commission;
D . this.commission = commission;super();
E . super(name, baseSalary);this.commission = commission;
F . this.commission = commission;super(name, baseSalary);
G . super(name, baseSalary, commission)
-
Which two code fragments will execute the method doStuff() in a separate thread?()
A . new Thread() {public void run() { doStuff(); }};
B . new Thread() {public void start() { doStuff(); }};
C . new Thread() {public void start() { doStuff(); }}.run();
D . new Thread() {public void run() { doStuff(); }}.start();
E . new Thread(new Runnable() {public void run() { doStuff(); }}).start();
-
Which two code fragments are most likely to cause a StackOverflowError?()
A .https://assets.asklib.com/images/image2/2018080211253564940.jpg
B .https://assets.asklib.com/images/image2/2018080211254118625.jpg
C .https://assets.asklib.com/images/image2/2018080211254518551.jpg
D .https://assets.asklib.com/images/image2/2018080211255082831.jpg
E .https://assets.asklib.com/images/image2/2018080211255590835.jpg
F .https://assets.asklib.com/images/image2/2018080211255925645.jpg
-
Given:
https://assets.asklib.com/images/image2/2018080114023542163.png
Which two code fragments, inserted independently at line 3, generate the output 4247? ()
A . String s = "123456789";s = (s-"123").replace(1,3,"24") - "89";
B . StringBuffer s = new StringBuffer("123456789");
C . sdelete(0,3).replace(1,3,";24";).delete(4,6);
D . substring(3,6).delete(1,3).insert(1, ";24";);
-
Given that c is a reference to a valid java.io.Console object,which two code fragments read a line of textfrom the console?()
A . String s = c.readLine();
B . char[] c = c.readLine();
C . String s = c.readConsole();
D . char[] c = c.readConsole();
E . String s = c.readLine("%s", "name ");
-
Given:
https://assets.asklib.com/images/image2/2018080114103736681.png
Which code fragment, inserted at line 23, allows the code to compile?()
A . df = new DateFormat();
B . df = Date.getFormat();
C . df = date.getFormat();
D . df = DateFormat.getFormat();
E . df = DateFormat.getInstance();
-
10.publicclassBar{ 11.staticvoidfoo(int...x){ 12.//insertcodehere 13.} 14.} Which two code fragments,inserted independently at line1 2,will allow the class to compile()
A . foreach(x)System.out.println(z);
B . for(intz:x)System.out.println(z);
C . while(x.hasNext())System.out.println(x.next());
D . for(inti=0;i
-
Which two code fragments correctly create and initialize a static array of int elements?()
A . static final int[] a = { 100,200 };
B . static final int[] a; static { a=new int[2]; a[0]=100; a[1]=200; }
C . static final int[] a = new int[2] { 100,200 };
D . static final int[] a; static void init() { a = new int[3]; a[0]=100; a[1]=200; }
-
Given that c is a reference to a valid java.io.Console object, which two code fragments read a line of text from the console?()
A . String s = c.readLine();
B . char[ ] c = c.readLine();
C . String s = c.readConsole();
D . char[ ] c = c.readConsole();
E . String s = c.readLine("%s", "name ");
F . char[ ] c = c.readLine("%s", "name ");
-
10. public class Bar { 11.static void foo(int...x) { 12. // insert code here 13. } 14. } Which two code fragments, inserted independently at line 12, will allow the class to compile?()
A . foreach(x) System.out.println(z);
B . for(int z : x) System.out.println(z);
C . while( x.hasNext()) System.out.println( x.next());
D . for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
-
Which two code fragments correctly create and initialize a static array of int elements()
A . static final int[]a={100,200};
B . static final int[]a;static{a=new int[2];a[0]=100;a[1]=200;}
C . static final int[]a=new int[2]{100,200};
D . static final int[]a;static void int(){a=new int[3];a[0]=100;a[1]=200;}
-
Which two code fragments correctly create and initialize a static array of int elements?()https://assets.asklib.com/images/image2/2018080115383061215.jpg
A . A
B . B
C . C
D . D
-
Which two code fragments, inserted independently at line 12, will compile?()https://assets.asklib.com/images/image2/2018080111245793093.jpg
A . super(name, baseSalary);
B . this.commission=commission;
C . super();this.commission=commission;
D . this.commission = commission;super();
E . super(name, baseSalary);this.commission=commission;
F . this.commission=commission;super(name, baseSalary);
G . super(name, baseSalary, commission);
-
Which code fragment, inserted at line 23, allows the code to compile?()https://assets.asklib.com/images/image2/2018080115383537922.jpg
A . df = new DateFormat();
B . df = Date.getFormat();
C . df = date.getFormat();
D . df = DateFormat.getFormat();
E . df = DateFormat.getInstance();
-
Which two code fragments represent these relationships?()https://assets.asklib.com/images/image2/2018080111262484167.jpg
A . class Widget{Sprocket s;};class Gadget extends Widget{Spring s;}
B . class Widget{};class Gadget extends Widget{Spring s1; Sprocket s2;}
C . class Widget{Sprocket s1; Spring s2;};class Gadget extends Widget{}
D . class Gadget{Spring s;};class Widget extends Gadget{Sprocket s;}
E . class Gadget{};class Widget extends Gadget{Sprocket s1; Spring s2;}
F . class Gadget{Spring s1; Sprocket s2;};class Widget extends Gadget{}
-
public class TestString3 { public static void main(String[] args) { // insert code here System.out.println(s); } } Which two code fragments, inserted independently at line 3, generate the output 4247?()
A . String s = “123456789”; s = (s-”123”).replace(1,3,”24”) - “89”;
B . StringBuffer s = new StringBuffer(”123456789”); s.delete(0,3).replace( 1,3, “24”).delete(4,6);
C . StringBuffer s = new StringBuffer(”123456789”); s.substring(3,6).delete( 1 ,3).insert(1, “24”);
D . StringBuilder s = new StringBuilder(”123456789”); s.substring(3,6).delete( 1 ,2).insert( 1, “24”);
E . StringBuilder s = new StringBuilder(”123456789”); s.delete(0,3).delete( 1 ,3).delete(2,5).insert( 1, “24”);
-
Which two code fragments correctly create and initialize a static array of int elements?()
A . static final int[] a = { 100,200 };
B . static final int[] a; static { a=new int[2]; a[0]=100; a[1]=200; }
C . static final int[] a = new int[2]{ 100,200 };
D . static final int[] a; static void init() { a = new int[3]; a[0]=100; a[1]=200; }
-
Given that: Gadget has-a Sprocket and Gadget has-a Spring and Gadget is-a Widget and Widget has-a Sprocket Which two code fragments represent these relationships? ()
A .https://assets.asklib.com/images/image2/2018080116372242416.jpg
B .https://assets.asklib.com/images/image2/2018080116372748968.jpg
C .https://assets.asklib.com/images/image2/2018080116373495076.jpg
D .https://assets.asklib.com/images/image2/2018080116373950755.jpg
E .https://assets.asklib.com/images/image2/2018080116374889300.jpg
F .https://assets.asklib.com/images/image2/2018080116375347013.jpg
-
Which two code fragments correctly create and initialize a static array of int elements?()
A .https://assets.asklib.com/images/image2/2018080115515869311.jpg
B .https://assets.asklib.com/images/image2/2018080115520283848.jpg
C .https://assets.asklib.com/images/image2/2018080115521279815.jpg
D .https://assets.asklib.com/images/image2/2018080115521823798.jpg
-
Which two code fragments are most likely to cause a StackOverflowError?()https://assets.asklib.com/images/image2/2018080115040047369.jpg
A . A
B . B
C . C
D . D
E . E
F . F
-
Given:
https://assets.asklib.com/images/image2/2018080116063010254.png
Which two code fragments, inserted independently at line 5, will compile without warnings?()
A . public void addStrings(List list) {
B . public void addStrings(List<String> list) {
C . public void addStrings(List<? super String> list) {
D . public void addStrings(List<? extends String> list) { B,C
-
publicclassBar{11.staticvoidfoo(int...x){12.//insertcodehere13.}14.}Which two code fragments,inserted independently at line1 2,will allow the class to compile()
A.foreach(x)System.out.println(z);
B.for(intz:x)System.out.println(z);
C.while(x.hasNext())System.out.println(x.next());
D.for(inti=0;i<x.length;i++)system.out.println(x[i]);< body=""></x.length;i++)system.out.println(x[i]);<>