Questionary 1 Answers

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

WORKSHOP 1

WILLIAM ALBERTO ROYERO BELEÑO


CODE: 20162150560

TEACHER:
ING. MATILDE MONTEALEGRE MADERO

SURCOLOMBIANA UNIVERSITY
FACULTY OF GENGINEERING
SOFTWARE ENGINEERING
JAVA PROGRAMMING
NEIVA - HUILA
2019
QUESTIONARY ANSWERS
1- C – This is because in the second FOR loop have an IF instruction in which says
that if the array its equals to “2”, it brakes the FOR LOOP and it doesn’t print the
number 3 because it keeps going through the first FOR loop, so it pass to the
number 4 in the array and that’s why the number 3 is not printed.
2- D – Throw an exception because the program needs two parameters and in the main
thread you give a NULL in the second parameter, not a compilation error but yes,
an exception error.
3- B – Protected, because protected data member is only accessible by the classes of
the same package and the subclasses present in any package.
4- C- Because yes, you can define multiple interfaces and classes in a java source file.
5- B – It compiles successfully because you can create multiple interfaces and classes
in a java source code file.
6- E – because the variable a_b is not initialized, so it throws an exception error in
code line 6.
7- C- Because when the source code.java is compiled, it generates the bytecode in a
.class file, it contains the bytecode of a single class.
8- It will not work without importing the Random package:
import java.util.Random;

public class ImportExample {

public static void main(String[] args) {


Random r = new Random();
System.out.println(r.nextInt(10));
}
}
9- I think that are redundant:
1: import java.lang.System;
2: import java.lang.*;
And,
3: import java.util.*;
Because you are only using the Random package in the java source code, and
packages like System come by default in most IDE’s.
10- Here will not work the E and F imports, because in E is redundant to put another *,
you are saying with the first * to import all of the packages inside NIO. And in the
second one, the F, there is a syntax error, is file, not files.

You might also like