Test on JAVA P10 test
Multiple choice questions on Java programming help you test your basic knowledge of this programming language. The set of questions includes 10 sentences to try.
Question 1. Given str = 'Yunlin university', what is the result of str.lastIndexOf ('i')?
Question 2. Given str = 'Yunlin university', what is the result of str.lastIndexOf ('i', 7) returning results?
Question 3. Given str = 'Yunlin university', what is the result of str.lastIndexOf ('sti')?
Question 4. After running the command block s =?
int s = 0; for (int i = 3; i <10; i ++) s + = i;
Question 5. After running the command block s =?
for (int i = 0; i <= 10; i ++) { int s = 0; s + = i;} System.out.print (s);
Question 6. After running the command block s =?
int s = 0; for (int i = 0; i <= 10; i ++) s + = i;
Question 7. If the program runs with the java message -g cruel world command, what is the value of the args [1] parameter?
public static void main (String [] args) { if (args [0] .equals ('- g')) System.out.print ('Goodbye,'); for (int i = 1; i System.out.print ('' + args [i]); }
Question 8. If the program runs with the java message -g cruel world, what is the result?
public static void main (String [] args) { if (args [0] .equals ('- g')) System.out.print ('Goodbye,'); for (int i = 1; i System.out.print ('' + args [i]); }
Question 9. If initializing two class A objects extending KiemTra and class B extends KiemTra, the id of object A is valid:
class KiemTra { private int i; private int nextId; public void setId () { id = nextId; nextId ++; } }
Question 10. If initializing two class A objects, the KiemTra and class B extends extends KiemTra, the id of object B is valid?
class KiemTra { private int i; private int nextId; public void setId () { id = nextId; nextId ++; } }