It1406 2022 2
It1406 2022 2
It1406 2022 2
Important Instructions
• Each question will have 5 (five) choices with one or more correct answers.
• The mark given for a question will vary from -1 (All the incorrect choices are marked & no
correct choices are marked) to +1 (All the correct choices are marked & no incorrect choices
are marked). However, the minimum mark per question would be zero.
• Note that questions appear on both sides of the paper. If 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.
• 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 statement(s) is/are TRUE with respect to the Java programming lan-
guage?
2). Which of the following languages can be considered as ancestries of java programming lan-
guage?
2
6). Which of the following is/are primitive data type(s) in java?
7). Which of the following variables is/are NOT suitable to define as f loat?
8). If, the variable ch is defined as char ch = 66;, what would be the output of the following
line?
1 System . o u t . p r i n t l n (++ ch ) ;
9). If, the variable ch is defined as char ch = ’\101’;, what would be the output of the follow-
ing line?
1 System . o u t . p r i n t l n ( ch ) ;
10). If, the variable x is defined as int x = 017;, what would be the output of the following line?
1 System . o u t . p r i n t l n ( x ) ;
3
11). Consider the following piece of code written in Java.
1 p u b l i c s t a t i c v o i d main ( S t r i n g s [ ] ) {
2 i n t x = 10;
3 i f ( x ==10) { i n t y = 1 5 ; }
4 y = 20;
5 System . o u t . p r i n t l n ( y ) ;
6 }
12). If two data types are compatible, Java will perform the conversion automatically from one type to
the other. Which of the following conversion(s) will automatically occur in java?
What would be the values of x and z respectively after executing these lines?
4
15). Consider the following piece of code written in Java.
1 p u b l i c s t a t i c v o i d main ( S t r i n g s [ ] ) {
2 i n t x = 2;
3 do { System . o u t . p r i n t l n ( x +=2) ;
4 } w h i l e ( x <3) ;
5 }
17). Consider the following statements regarding the case statement of Java.
5
18). What is the output of the following Java program?
1 p u b l i c s t a t i c v o i d main ( S t r i n g s [ ] ) {
2 i n t x [ ] [ ] = {{1 ,2} , {3 ,4} , {5 ,6}};
3 System . o u t . p r i n t l n ( x [ 1 ] [ 1 ] ) ;
4 }
19). Which of the following is/are NOT (a) Program Design Methodology(ies)?
20). Following are some of the basic steps you have to follow in the development of a computer pro-
gram.
6
22). Following are three (3) basic symbols used in flowcharts.
A B C
23). Consider the following three (3) statements regarding the classes in object orientation.
24). Which of the following is/are NOT (a) characteristic(s) of an object in object orientation?
25). Consider the three (3) statements given below regarding the following line of code written in Java.
1 C i r c l e m y C i r c l e = new C i r c l e ( 8 ) ;
7
26). Consider the following piece of code written in Java.
1 p u b l i c c h a r ABC( i n t x ) {
2 <v a r i a b l e type> y ;
3 return y;
4 }
29). Consider the following three (3) statements regarding polymorphism in Java.
I. It allows a class to have multiple methods with the same name but different parameters.
II. It allows a class to be used as an instance of any of its parent classes.
III. It allows a class to inherit from multiple parent classes.
30). Which of the following access control(s) is/are allowed to access to methods and variables of a
class by the other classes in the same package?
8
31). Which of the following is/are true about the static keyword in Java?
32). Consider the following three (3) statements regarding the purpose of using packages in Java.
33). Consider the following three (3) statements regarding the Abstract classes in Java.
9
Questions 35 and 36 are based on the following Java programme.
1 p u b l i c s t a t i c v o i d main ( S t r i n g s [ ] ) {
2 i n t num1 = 0 , num2 = 1 0 , num3 ;
3 try {
4 num3 = num1 / num2 ;
5 System . o u t . p r i n t ( ”A” ) ;
6 }
7 catch ( Exception e ) {
8 System . o u t . p r i n t ( ”B” ) ;
9 }
10 finally {
11 System . o u t . p r i n t ( ”C” ) ;
12 }
13 System . o u t . p r i n t ( ”D” ) ;
14 }
36). What is the output of the above program when num1 = 10 and num2 = 0?
If the output of this program is 3AB, what would be the valid arguments passed to the pro-
gram?
10
38). Consider the following piece of code written in Java.
1 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 [ ] ) {
2 System . o u t . p r i n t l n ( a r g [ 1 ] + a r g [ 2 ] ) ;
3 }
39). What is the use of sleep() method in the Thread class in Java?
40). Which of the following API is used to establish a connection to a database in Java?
11