IT1406_2023
IT1406_2023
Important Instructions
• Each question will have 5 (five) choices with ONLY ONE correct answer.
• This paper consists of 100 marks and all the questions will carry equal marks.
• Note that questions appear on both sides of the paper. If a page or part of a page is not printed,
please inform the supervisor/invigilator immediately.
• Mark the correct choices on the question paper first and then transfer them to the given answer
sheet which will be machine marked. Please completely read and follow the instructions
given on the other side of the answer sheet before you shade your correct choices.
• Any electronic device capable of storing and retrieving text, including electronic dictionaries,
smartwatches, and mobile phones, is not allowed.
• All Rights Reserved. This question paper can NOT be used without proper permission from
the University of Colombo School of Computing.
1). Which of the following is correct regarding the Java programming language?
2). Which of the following indicates the correct statement regarding the top-down development pro-
cess?
3). Which of the following statement(s) is/are correct regarding type conversion in Java program-
ming?
(I) Int can be assigned to a byte by casting the target type to a byte.
(II) There are automatic conversions from the numeric types to Boolean.
(III) Automatic type conversion will occur if the destination type is larger than the source type.
5). If int a=2 and int b=3 are in a Java program, what would be the values of a&b and a|b
respectively?
2
6). Consider the following code written in Java.
1 public class stringOut {
2 p u b l i c s t a t i c v o i d main ( S t r i n g [ ] a r g s ) {
3 S t r i n g s t r = ” Hello −world ! ” ;
4 i n t a = s t r . lastIndexOf ( ”o” ) ;
5 System . o u t . p r i n t l n ( a ) ; } }
Which one of the following indicates the correct output of the above code?
II) –
B - Represents an input or output
process in an algorithm.
a). I →A, II →C, III → B b). I →B, II →C, III →A c). I →C, II →B, III →A
d). I →B, II→A, III →C e). I →C, II →A, III →B
3
8). Which of the following statement(s) is/are correct regarding the repetition control structure?
Which one of the following indicates the correct output of the above code?
10). is used to destroy unused objects and their memory is released for later
reallocation in Java.
Which one of the following indicates the correct output of the above code segment?
4
12). Consider the following code which is written in Java.
1 p u b l i c c l a s s Sample {
2 p u b l i c s t a t i c v o i d main ( S t r i n g [ ] a r g s ) {
3 i n t x = 15 , y = 4;
4 f l o a t z = ( f l o a t ) ( x / y) * 2;
5 System . o u t . p r i n t ( z ) ; } }
Which one of the following shows the output of the above code?
Which one of the following indicates the correct output of the above code?
Which one of the following indicates the correct output of the above code?
5
15). Consider the following code written in Java.
1 public c l a s s SimpleCalc {
2 p u b l i c s t a t i c v o i d main ( S t r i n g [ ] a r g s ) {
3 i n t a = 1;
4 switch ( a ) {
5 case 2:
6 System . o u t . p r i n t ( ”A ” ) ;
7 break ;
8 case 1:
9 System . o u t . p r i n t ( ”B ” ) ;
10 default :
11 System . o u t . p r i n t ( ”C ” ) ; } } }
Which one of the following indicates the correct output of the above code?
17). Which of the following is NOT a basic object-oriented programming concept facilitates in Java?
18). indicates how closely the elements or statements of a module are associ-
ated with each other.
6
19). Consider the following code piece written in Java.
1 p u b l i c c l a s s CharApp {
2 p u b l i c s t a t i c v o i d main ( S t r i n g [ ] a r g s ) {
3 int [][][] x = {
4 {{1 , 2} , {3 , 4}} ,
5 { { 5 , 6 } , { 7 , 8}}
6 };
7 System . o u t . p r i n t ( x [ 0 ] [ 1 ] [ 0 ] ) ; } }
Which one of the following indicates the correct output of the above code segment?
20). What is the most suitable response that represents, the ‘this’ Keyword in Java?
Which one of the following indicates a method, an object and a state of the above code seg-
ment?
7
22). To disallow a method from being overridden, can be used as a modifier at
the start of its declaration.
23). Which of the following statement(s) is/are correct regarding Method Overloading?
Which one of the following indicates the correct output of the above code segment?
8
26). Which one of the following does NOT indicate type wrappers in Java?
27). In Java, the exception type automatically defined for the programs to detect errors like division by
zero is .
28). Which of the following statement(s) is/are correct regarding Strings in Java?
Which of the following exceptions type(s) needed to be checked in the above code?
(I) NullPointerException
(II) ArrayIndexOutOfBoundsException
(III) ArithmeticException
9
30). method can be used to extract a single character from a String.
31). Which of the following statement(s) is/are correct regarding the enumeration in Java?
32). Select the most suitable options for filling the blanks in the following statements.
33). Which of the following indicates the correct statements regarding packages in Java?
10
34). Consider the following two classes defined in Java.
1 c l a s s Shape {
2 v o i d draw ( ) {
3 System . o u t . p r i n t l n ( ” Drawing a s h a p e ” ) ; } }
4 c l a s s C i r c l e e x t e n d s Shape {
5 v o i d draw ( ) {
6 (A)
7 System . o u t . p r i n t l n ( ” Drawing a c i r c l e ” ) ; } }
To access the superclass version of the draw() method, which one of the following lines needs to
be added to the given space(mentioned as (A) )?”
8 p u b l i c s t a t i c v o i d main ( S t r i n g [ ] a r g s ) {
9 S t r i n g [ ] A = { ”A” , ”B” , ”C” , ”D” , ”E” } ;
10 S t r i n g r e s u l t = Sample (A) ;
11 System . o u t . p r i n t l n ( r e s u l t ) ; } }
Which one of the following is correct regarding the output of the above code?
36). Which of the following statement(s) is/are correct regarding Scanner class in Java?
11
37). Which of the following statement(s) is/are correct regarding access modifiers in Java?
(I) Classes or interfaces declared as public can be accessed from any other class.
(II) The protected allows access within its subclasses, and classes within the same package.
(III) The private access modifier restricts the access of a class method only to the class in which
it is declared.
38). Which of the following statement(s) is/are correct regarding design concepts in Java?
39). Which one of the following statement(s) is/are correct regarding multithreaded programming.
40). Which of the following statement(s) is/are correct regarding JAVA Database Connectivity(JDBC)?
12