Partial preview of the text
Download PROGRAMMING FUNDAMENTALS II-second semester and more Exams Computer Fundamentals in PDF only on Docsity!
SJ UNIVERSITY OF PROFESSIONAL STUDIES, ACCRA (UPSA) DIPLOMA. END OF SECOND SEMESTER EXAMINATIONS — 2014/2015 FACULTY OF [IT AND COMMUNICATION STUDIES DEPARTMENT OF IT Srupres LEVEL 100 PDIM 106: PROGRAMMING FUNDAMENTALS II DATE: TUESDAY 19™ MAY, 2015. TIME ALLOWED: 2'4 HOURS INDEX NUMBER INSTRUCTION(S) THERE ARE TWO SECTIONS IN THIS PAPER, SECTIONS A & B Answer ALL questions in SECTION A on the question paper and any Two questions in Section B in your answer booklet Section A Choose the best option that best answers the question. Answer ALL Questions from this section. Each Question Carries I Mark 1, Java is typically a_ programming language. a) Procedural b) Sequential c) Object Oriented d) Distributed 2. Java was developed by and the green team at Sun Microsystems in 1991 a)Tim Beners-Lee b)Brian Kenighan c) Hot Java d)James Gosling 3, Java is architecture neutral, hence, Java programs are a) Object oriented b) secure c) Portable d) Distributed 4, is a kind of mold or ttmplate that defines what an object can and cannot do, a) Object b) Class c) Instance : d) Attribute S.A is a sequence of instructions that a class or an object follows to. perform a task a) Object b) Attribute c) Instance d) Mcthod 6. The ability of one class to extend the capabilities of another is known as —__ a) Superclass b) Inheritance c) Sub Class d) Coupling 7, The common class from which other classes inherit from is also called: a) Ancestor b) Sub class matty EE c) Derived class d) New oe Noura 8. If Class A inherits from Class B, which is a superclass? a) Class A b) Class B c) Both Class A and Class B d) None of the above 9. If we have Animal, Insect, and Mammal classes, which one will be a superclass’? a) Animal b) Insect 12. } a) 16.34 b) 16.566666644 ©) 16.46666666666667 d) 16.46666666666666 17. What is the output of this program? class increment { public static void main(String args[]) { int g=3; System.out.print(++g * 8); } } a) 25 b) 24 Ox c) 32 d) 33 Retrenceon NAMES 18. What is the output of this program? class area { public static void main(String args[]) { double r, pi, a; r=9.8; pi 4: a=pitr*r, System.out.println(a); mo Me bi irs te BO: 08 a) 301.5656 b) 301 c) 301.56 d) 301.56560000 19. Which of these values can a boolean variable contain? a) True & False b)O& 1 ¢) Any integer value d) true 20. Which one is a valid declaration of a boolean? a) boolean b1 = 1; b) boolean b2 c) boolean b3 = false: d) boolean b4 = 21. What is the output of this program? 1 class mainclass { 2. public static void main(String args[]) 3 { erat) = =" SI AA-S SIAR YN SHAAN char a='A'; at+; System.out.print((int)a); V f } a) 66 b) 67 c) 65 d) 64 rsily © 22. What is the output of this program? class mainclass { DO. Box public static void main(String args[]) Retire { boolean varl = true; boolean var2 = false; if (varl) System.out.println(var 1); else System.out.println(var2); } } a) 0 b) 1 c) true d) false 23. What is the output of this program? lass booloperators { public static yuid main(String args[]) { boolean varl = true; boolean var2 = false; System.out.printIn((var2 & var2)); } } aj0 b)1 c) true d) false 24. Which of these can not be used for a variable name in Java? a) identifier b) keyword c) identifier & keyword d) None of the mentioned 32. Which of these keywords is used to make a class? a) class b) struct ¢) int d) None of the mentioned 33. Which of the following is a valid declaration of an object of class Box? a) Box obj = new Box(); b) Box obj = new Box; c) obj = new Box(): d) new Box obj: 34. Which of these operators is used to allocate memory for an object? a) malloc b) alloc c) new d) give 35. Which of the following is a method having same name as that of it’s class? a) finalize b) delete c) class d) constructor 36. is a measure of the degree of interdependence between modules. a) Cohesion b) Coupling c) None of the mentioned 37. What is the process by which we can control what parts of a program can access the members of a class? a) Polymorphism b) Abstraction c) Encapsulation d) Recursion 38. Which of the following package stores all the standard java classes? a) lang b) java c) util d) java.packages 39, Which of these keyword must be used to inherit a class? a) super b) this c) extent d) extends 40. Which of these keywords must be used to monitor for exceptions? a) try b) finally c) throw d) find SECTION B Attempt any two (2) Questions from this section. Each Question Carries 10 Marks Definitions and essay questions 1, a, Modern programming languages are usually object oriented, unlike older languages (although some of these have been updated by adding object orientated extensions). What is "object orientation" and how is it defined’. (5 Marks) c. Write an interactive program in the java language, that prompts the user for two numbers, and swaps the numbers entered without introducing a third variable. (5) 2. a. Java is “cross platform” Explain (2 Marks) b. Write an interactive program in the java language, that prompts the user for a number, and determines whether the number entered by the user is an Even number or Odd number. (7 Marks) c. List and explain two(2) characteristics of Java (1 Mark) 3, a. State whether or not each of the following declarations is legal in JAVA? In each case explain your answer. (4 Marks) A. public MyClass {//...} B. public protected int my Var; C. friendly Button myButton; D. Label myLabel b. Write an interactive program in the java language that computes the factorial of a number entered by the user. (6 Marks) 4. Explain what the terms black-box testing and white-box testing mean and how these techniques could be used to test object-oriented software. (6 Marks) b. List two advantages of and two disadvantages of black-box testing and white-box testing. (4 Marks)