Академический Документы
Профессиональный Документы
Культура Документы
Raspuns :1
2. Ce extrage ?
public class Test {
public static void main(String[] args) {
int[][] values = {{3, 4, 5, 1 }, {33, 6, 1, 2}};
for (int row = 0; row < values.length; row++) {
java.util.Arrays.sort(values[row]);
for (int column = 0; column < values[row].length; column++)
System.out.print(values[row][column] + " ");
System.out.println(); }}}
Raspuns : 2 5 9 13
4. Ce extrage codul ?
public class Test5 {
public static void main(String[] args) {
int[][] matrix =
{{1, 2, 3, 4},
{4, 5, 6, 7},
{8, 9, 10, 11},
{12, 13, 14, 15}};
for (int i = 0; i < 4; i++)
System.out.print(matrix[1][i] + " ");}}
Raspuns : 4 5 6 7
5. Fie metoda p() are urmatorul antet. Care return poate fi folosit in p()?
public static int[][] p()
Raspuns : 5 33
Raspuns: a. 4, 5, si 6
9. Ce extrage codul ?
public class Test {
public static void main(String[] args) {
int[][][] data = {{{1, 2}, {3, 4}},
{{5, 6}, {7, 8}}};
System.out.print(data[1][0][0]);}}
Raspuns: 5
10.Ce extrage codul ?
public class Test {
public static void main(String[] args) {
int[][][] data = {{{1, 2}, {3, 4}},
{{5, 6}, {7, 8}}};
System.out.print(ttt(data[0]));}
public static int ttt(int[][] m) {
int v = m[0][0];
for (int i = 0; i < m.length; i++)
for (int j = 0; j < m[i].length; j++)
if (v < m[i][j])
v = m[i][j];
return v;}}
Raspuns : 4
15. Cate elemenete sunt in tabloul matrix (int[][] matrix = new int[5][5]) ?
Raspuns 25
16. Analizati codul
public class Test {
public static void main(String[] args) {
boolean[][] x = new boolean[3][];
x[0] = new boolean[1]; x[1] = new boolean[2];
x[2] = new boolean[3];
System.out.println("x[2][2] is " + x[2][2]);}}
Raspuns: Programul lucreaza si extrage x[2][2] is false
17. Fie int[][] x = {{1, 2}, {3, 4}, {5, 6}}. Ce valoare au x.length si x[0].length ?
RASPUNS: 3SI2
18. Fie int[][] x = {{1, 2}, {3, 4, 5}, {5, 6, 5, 9}}. Ce valoare au x[0].length,
x[1].length, si x[2].length ?
Raspuns: 2,3,4
Question 2
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d. try-finally block
Feedback
Question 3
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d. Error
Feedback
Question 4
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d. ambele
Feedback
Question 5
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d. try { }
Feedback
Question 6
Correct
Mark 10.00 out of 10.00
Flag question
Question text
e. throw
Feedback
Question 7
Correct
Mark 10.00 out of 10.00
Flag question
Question text
Ce este o exceptie ?
Select one:
a. o clasa
b. o interfata
c. o clasa abstracta
d. altceva
Feedback
Question 8
Correct
Mark 10.00 out of 10.00
Flag question
Question text
Ce extrage ?
try { x.doStuff(); } int y = 50; } catch(FooException fe) { }
Select one:
a. Eroare la compilare
b. Eroare la executie
c. Trece compilarea fara erori
Question 9
Correct
Mark 10.00 out of 10.00
Flag question
Question text
Question 10
Correct
Mark 10.00 out of 10.00
Flag question
Question text
Care bloc este executat oricand, independent daca a fost aruncata o exceptie
sau nu ?
Select one:
a. finally
b. throws
c. catch
d. throw
Feedback
Question 11
Correct
Mark 10.00 out of 10.00
Flag question
Question text
Question 12
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d.
java.lang.Exception
Feedback
Question 13
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d. java
Feedback
Question 14
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d. java 4
Feedback
Question 15
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d. 7
Feedback
Question 16
Correct
Mark 10.00 out of 10.00
Flag question
Question text
java.lang.NullPointerException este:
Select one:
a. Runtime Exception
b. Error
c. Compile time exception
d. nici una
Feedback
Question 17
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d. Exception
Feedback
Question 18
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d. raise
Feedback
Question 19
Correct
Mark 10.00 out of 10.00
Flag question
Question text
d. RuntimeException
Feedback
Question 20
Correct
Mark 10.00 out of 10.00
Flag question
Question text
Question 21
Correct
Mark 10.00 out of 10.00
Flag question
Question text
Question 22
Correct
Mark 10.00 out of 10.00
Flag question
Question text
b. false
Feedback
Question 23
Correct
Mark 10.00 out of 10.00
Flag question
Question text
Question 24
Correct
Mark 10.00 out of 10.00
Flag question
Question text
False
Feedback
Question 25
Correct
Mark 10.00 out of 10.00
Flag question
Question text
False
Feedback
Question 26
Correct
Mark 10.00 out of 10.00
Flag question
Question text
False
Feedback
Question 27
Correct
Mark 10.00 out of 10.00
Flag question
Question text
False
Feedback
Question 28
Correct
Mark 10.00 out of 10.00
Flag question
Question text
False
Feedback
Question 29
Correct
Mark 10.00 out of 10.00
Flag question
Question text
False
Feedback
Question 30
Correct
Mark 10.00 out of 10.00
Flag question
Question text
False
Feedback
Question 31
Correct
Mark 10.00 out of 10.00
Flag question
Question text
Question 32
Correct
Mark 10.00 out of 10.00
Flag question
Question text
Daca arunci o exceptie in codul tau, atunci trebuie sa declari exceptia cu throws
in declaratia metodei
Select one:
True
False
Feedback
Fie s1 si s2 sunt doua string-uri. Care afirmatii sau expresii sunt gresite ?
a. s1 >= s2 b. int i = s1.length
Ce returneaza "abc".compareTo("aba") ?
a. 2
Ce returneaza "AbA".compareToIgnoreCase("abC") ?
a. -2
Care returneaza true ?
a. "peter".equalsIgnoreCase("Peter") b. "peter".equalsIgnoreCase("peter")
Ce extrage codul ?
a. University
Ce returneaza apelul "SELECT".substring(0, 5)?
a. "SELEC"
Ce returneaza apelul "SELECT".substring(4, 4)
a. Un sir vid
Analizati codul
class Test {
public static void main(String[] args) {
String s;
System.out.println("s is " + s);
}
}
a. Eroare la compilare deoarece s nu este initializat dar este referit in println
Ce extrage codul ?
public class Test {
public static void main(String[] args) {
String s = "Java";
StringBuilder buffer = new StringBuilder(s);
change(s);
System.out.println(s);
}
Ce extrage codul ?
public static void main(String[] args) {
String[] tokens = "Welcome to Java".split("o");
for (int i = 0; i < tokens.length; i++) {
System.out.print(tokens[i] + " ");
}
}
a. Welc me t Java
Care instructiune este preferabila pentru a crea stringul "Welcome to Java" ?
a. String s = "Welcome to Java";
Ce extrage codul ?
System.out.print("Hi, ABC, good".matches("ABC ") + " ");
System.out.println("Hi, ABC, good".matches(".*ABC.*"));
a. false true
Ce extrage codul ?
System.out.print("A,B;C".replaceAll(",;", "#") + " ");
System.out.println("A,B;C".replaceAll("[,;]", "#"));
a. A,B;C A#B#C
Ce extrage codul ?
String[] tokens = "A,B;C;D".split("[,;]");
for (int i = 0; i < tokens.length; i++)
System.out.print(tokens[i] + " ");
a. A B C D
Care metoda nu este corecta in Character ?
a. isDigit() b. toUpperCase()
Ce extrage codul ?
public class Test {
public static void main(String[] args) {
String s1 = "Welcome to Java!";
String s2 = s1;
if (s1 == s2)
System.out.println("s1 and s2 reference to the same String object");
else
System.out.println("s1 and s2 reference to different String objects");
}
}
a. s1 and s2 reference to the same String object
Cum putem obtien cuvantul "abc" in metoda main() cu apelul
java Test "+" 3 "abc" 2 ?
a. args[2]
if (s1 == s2)
System.out.println("s1 and s2 reference to the same String object");
else
System.out.println("s1 and s2 reference to different String objects");
}
}
a. s1 and s2 reference to the same String object
Ce extrage codul ?
public class Test {
public static void main(String[] args) {
String s1 = new String("Welcome to Java!");
String s2 = new String("Welcome to Java!");
if (s1 == s2)
System.out.println("s1 and s2 reference to the same String object");
else
System.out.println("s1 and s2 reference to different String objects");
}
}
a. s1 and s2 reference to different String objects
Ce extrage codul ?
public class Test {
public static void main(String[] args) {
String s1 = new String("Welcome to Java!");
String s2 = new String("Welcome to Java!");
if (s1.equals(s2))
System.out.println("s1 and s2 have the same contents");
else
System.out.println("s1 and s2 have different contents");
}
}
a. s1 and s2 have the same contents
Ce extrage codul ?
public class Test {
public static void main(String[] args) {
String s1 = new String("Welcome to Java!");
String s2 = s1.toUpperCase();
if (s1 == s2)
System.out.println("s1 and s2 reference to the same String object");
else if (s1.equals(s2))
System.out.println("s1 and s2 have the same contents");
else
System.out.println("s1 and s2 have different contents");
}
}
a.
s1 and s2 have different contents
Ce extrage codul ?
public class Test {
public static void main(String[] args) {
String s1 = new String("Welcome to Java");
String s2 = s1;
if (s1 == s2)
System.out.println("s1 and s2 reference to the same String object");
else
System.out.println("s1 and s2 reference to different String objects");
}
}
a. s1 and s2 reference to different String objects
Ce extrage?
public class Test {
public static void main(String[] args) {
double[] x = new double[]{1, 2, 3};
System.out.println("Value is " + x[1]);
}
}
Select one:
a. Value is 2.0
a. 4
Ce extrage codul ?
double[] myList = {1, 5, 5, 5, 5, 1};
double max = myList[0];
int indexOfMax = 0;
for (int i = 1; i < myList.length; i++) {
if (myList[i] > max) {
max = myList[i];
indexOfMax = i;
}
}
System.out.println(indexOfMax);
Select one:
a. 1
Analizati codul
public class Test {
public static void main(String[] args) {
int[] x = new int[5];
int i;
for (i = 0; i < x.length; i++)
x[i] = i;
System.out.println(x[i]);
}
}
Select one:
Ce extrage codul ?
int[] myList = {1, 2, 3, 4, 5, 6};
a. 1 1 2 3 4 5
Ce extrage codul ?
public static void main(String[] args) {
int[] x = {120, 200, 016};
for (int i = 0; i < x.length; i++)
System.out.print(x[i] + " ");
}
}
Select one:
a. 120 200 14
Ce extrage codul ?
public class Test {
public static void main(String[] args) {
int list[] = {1, 2, 3, 4, 5, 6};
for (int i = 1; i < list.length; i++)
list[i] = list[i - 1];
a. 1 1 1 1 1 1
Ce extrage codul ?
class Test {
public static void main(String[] args) {
int[] list1 = {1, 2, 3};
int[] list2 = {1, 2, 3};
list2 = list1;
list1[0] = 0; list1[1] = 1; list2[2] = 2;
a. 0 1 2
a. a[2]
Ce extrage codul ?
class Test {
public static void main(String[] args) {
int[] list1 = {1, 2, 3};
int[] list2 = {1, 2, 3};
list2 = list1;
list1[0] = 0; list1[1] = 1; list2[2] = 2;
Analizati codul
public class Test {
public static void main(String[] args) {
int[] x = {1, 2, 3, 4};
int[] y = x;
x = new int[2];
a. 1 2 3 4
Analizati codul
public class Test {
public static void main(String[] args) {
int[] x = {1, 2, 3, 4};
int[] y = x;
x = new int[2];
a. 0 0
Analizati codul
public class Test {
public static void main(String[] args) {
final int[] x = {1, 2, 3, 4};
int[] y = x;
x = new int[2];
Analizati codul
int[] list = new int[5];
list = new int[6];
Select one:
Analizati codul
public class Test {
public static void main(String[] args) {
int[] a = new int[4];
a[1] = 1;
a = new int[2];
System.out.println("a[1] is " + a[1]);
}
}
Select one:
a. a[1] is 0
a. referinta la tablou
Ce extrage codul ?
public class Test {
public static void main(String[] args) {
int[] x = {1, 2, 3, 4, 5};
increase(x);
a. 2 1
Codurile urmatoare produc acelasi rezultat ?
Program I:
public class Test {
public static void main(String[] args) {
int[] list = {1, 2, 3, 4, 5};
reverse(list);
for (int i = 0; i < list.length; i++)
System.out.print(list[i] + " ");
}
list = newList;
}
}
Program II:
public class Test {
public static void main(String[] args) {
int[] oldList = {1, 2, 3, 4, 5};
reverse(oldList);
for (int i = 0; i < oldList.length; i++)
System.out.print(oldList[i] + " ");
}
list = newList;
}
}
Select one:
a. Yes
Fie tabloul double[] list = {3.4, 2.0, 3.5, 5.5}. Ce valoare are list[1] ?
Select one:
a. 2.0
Analizati codul
public class Test {
public static void main(String[] args) {
int[] oldList = {1, 2, 3, 4, 5};
reverse(oldList);
for (int i = 0; i < oldList.length; i++)
System.out.print(oldList[i] + " ");
}
list = newList;
}
}
Select one:
a. extrage 1 2 3 4 5
Analizati codul
public class Test1 {
public static void main(String[] args) {
xMethod(new double[]{3, 3});
xMethod(new double[5]);
xMethod(new double[3]{1, 2, 3});
}
a. referinta la tablou
Fie metoda p() are antetul public static int[] p(). Care return poate fi
folosit in p() ?
Select one:
a. true false
a. System.out.println(java.util.Arrays.toString(scores));
Fie tabloul array double[] list = {3.4, 2.0, 3.5, 5.5}. Care este cea mai
mare valoare a indicelui in tablou ?
Select one:
a. 3
a. 5
a. variabila indexata
Fie int i=5. Care din urmatoarele poate fi folosit ca indice pentru array
double[] t = new double[100] ?
Select one or more:
a. i
b. i+10
Analizati codul
public class Test {
public static void main(String[] args) {
int[] x = new int[3];
System.out.println("x[0] is " + x[0]);
}
}
Select one: