Quiz
Test de DSE
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (11)
1Which of the following statements are true?
- AAn class is a blueprint for a object.
- BAn object and a class are exactly the same.
- CAn object is an instance of a class.
- DAn attribute cannot be a reference to another object.
2Given:
class X {
String str = "default";
X(String s) {
str = s;
}
void print() {
System.out.println(str);
}
public static void main(String[] args) {
new X("hello").print();
}
}
What is the result?- Ahello
- Bdefault
- CCompilation fails
- DThe program prints nothing
3Which two will compile, and can be run successfully using the command: java Fred1 hello walls. (Choose two)
- Aclass Fred1{
public static void main (String args)
{ System.out.println(args[1]);}} - Bclass Fred1{
public static void main (String [] args)
{ System.out.println(args[2]);}} - Cclass Fred1 {
public static void main (String [] args)
{ System.out.println (args);}} - Dclass Fred1 {
public static void main (String [] args)
{ System.out.println (args [1]);}}
- Aclass Fred1{
4Consider the following program:
class Point2D {
private int x, y;
public Point2D(int x, int y) {
x = x;
}
public String toString() {
return "[" + x + ", " + y + "]";
}
public static void main(String[] args) {
Point2D point = new Point2D(10, 20);
System.out.println(point);
}
}
Which one of the following options provides the output of this program when executed?- Apoint
- BPoint
- C[0, 0]
- D[10, 0]
- E[10, 20]
5Which of the these are valid declarations of the main() method in the order to start the execution of a Java application?
- Astatic void main(String [] args){/* … */}
- Bpublic static int main(String [] args){/*… */}
- Cpublic static void main(String args){/*… */}
- Dfinal public static void main(String [] arguments){/*… */}
- Epublic int main(String [] args, int argc){/*… */}
- Fstatic public void main(String args []){/* … */}
6Given:
public static void main(String[] args) {
double a = 2 + 5 * 6 / 7.0 % 6 + 7 - 9;
System.out.println(a);
}
What is the result?- A-2.0
- B30.0
- C4.2857
- Dcompilation fails
7What will be result of attempting to compile this class?
import java.util.*;
package test;
public class TestClass {
public OtherClass oc = new OtherClass();
}
class OtherClass {
int value;
}- AThe class will fail to compile, since the class OtherClass is used before it is defined.
- BThere is no problem with the code.
- CThe class will fail to compile, since the class OtherClass must be defined in a file called OtherClass.java
- DThe class will fail to compile.
- ENone of the above.
8Given:
public class SuperLoop3 {
public static void main(String[] args) {
int suma = 0;
for (int i = 0, j = 9, z = 1; i < 4 && j > 0; i++, --j, j--) {
do {
suma += i * j % z + 3;
} while (z++ <= 1);
}
System.out.println("suma:: " + suma);
}
}
What is the result?- Asuma:: 22
- Bsuma:: 14
- Csuma:: 20
- Dcompilation fails
9Given:
class Test {
public static void main(String[] args) {
int var = 3;
switch (var) {
case 1:
try {
throw new IllegalArgumentException();
} catch (RuntimeException e) {
e.printStackTrace();
}
default:
try {
throw new ArrayIndexOutOfBoundsException();
} catch (RuntimeException e) {
e.printStackTrace();
}
case 2:
try {
throw new ArithmeticException();
} catch (RuntimeException e) {
e.printStackTrace();
}
}
}
}
What is the result?- Ajava.lang.ArrayIndexOutOfBoundsException at com.bar.Test.main
and
java.lang.ArithmeticException at com.bar.Test.main at com.bar.Test.main - Bjava.lang.ArrayIndexOutOfBoundsException at com.bar.Test.main
- Cjava.lang.ArithmeticException at com.bar.Test.main
- Dcompilation fails
- Ajava.lang.ArrayIndexOutOfBoundsException at com.bar.Test.main
10Given:
public class Foo {
public static void main(String[] args) {
int a = 10;
long b = 20;
short c = 30;
System.out.println(++a + b++ * c);
}
}- A611
- B641
- C930
- D960
11class EJavaGuruStringBuilder {
public static void main(String args[]) {
StringBuilder ejg = new StringBuilder(10 + 2 + "SUN" + 4 + 5);
ejg.append(ejg.delete(3, 6));
System.out.println(ejg);
}
}
What is the output of the following code?- A12S512S5
- B12S12S
- C1025102S
- DRuntime exception
Information
- Description
- simulador para segundo parcial de DSE
- Language
- Español
- Views
- 84
- Tags
- Rating
- No ratings yet Rate this quiz