-
The 8859-1 character code for the uppercase letter A is 65. Which of these code fragments declare and initialize a variable of type char with this value?()
A . char ch = 65;
B . char ch = ’¥65’;
C . char ch = ’¥0041’;
D . char ch = ’A’;
E . char ch = "A";
-
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();
-
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 ");
-
Which two code fragments, inserted independently at line 3, generate the output 4247?()https://assets.asklib.com/images/image2/2018080115362240155.jpg
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");
-
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);
-
Given that file is a reference to a File object that represents a directory, which code fragments will succeed in obtaining a list of the entries in the directory?()
A . Vector filelist = ((Directory) file).getList();
B . String[] filelist = file.directory();
C . Enumeration filelist = file.contents();
D . String[] filelist = file.list();
E . Vector filelist = (new Directory(file)).files();
-
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{}
-
interface A { public int getValue() } class B implements A { public int getValue() { return 1; } } class C extends B { // insert code here } Which three code fragments, inserted individually at line 15, make use of polymorphism?()
A . public void add(C c) { c.getValue(); }
B . public void add(B b) { b.getValue(); }
C . public void add(A a) { a.getValue(); }
D . public void add(A a, B b) { a.getValue(); }
E . public void add(C c1, C c2) { c1.getValue(); }
-
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]);<>