0% found this document useful (0 votes)
40 views11 pages

Java Ue-2023

Uploaded by

ericcostermboya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
40 views11 pages

Java Ue-2023

Uploaded by

ericcostermboya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 11
nding item in Column B- (i Mar! with its corresPo wo jn Column A Each) 4 a8 rit - obec Fat, double, Float identify and Giscard objee' int, | ea Tonger needed PY S a abet ulation ii, The method must have ie ye a eS rer at least that Of Ee _ Inheritane act ‘lass, and return type, | F- Collection of abstract class name and identical parameter G. Class list. H. Double, Integer, Character \ i. Bae or we 1. Object \ iv. It is always invoked when @ i \ new abject is created: J, Garbage collection \ v. The base class of a oo ; exception. \L. Overriding \ vi. Prevent anyone ‘from M. Enhanced for loop \ |. instantiating the class directly. | N- ArrayList class vit Cannot be extended ©, Error \ iii. ~The i . Wes \ ae a allows print() | P- Specialization \ i () methods to /Q. Instance of class \ invoke foString() method R. RuntimeExcepti " automatically. ls Exception \ ix, Blueprint or template . Late binding | Some of an|T. Polymorphism | x. Private m : \ embers, U. Collectio mee”: SS a | Ww. Constructor X. Interface QQ eT aration ArrayList list = new ArrayList(); 2 ix. What is known by the dec! Aclist is an ArrayList object. B. Elements of the list array are objects. C. The type of information stored by list is unknown. D. The number of array elements is not specified. E. All of the above x Which statement about interfaces is true? 1. An interface contains only public abstract methods and public static final fields. Ifa class implements an interface and then fails to implement IL any methods in that interface, then the class must be declared abstract. Mi. While a class may implement just one interface, it may extend more than one class A. Tonly B.1 and II only C.Tand ITI only D. Il and III only E, LU, and I Class What type of relationship exists between myMethod i iv 9 Animal and myMethod in class Dog? cle Animal ( oe ublic void myMethod By anecicde gare In ("from class An Diz } } class Dog extends Animal { ; public void myMethod( String x ) System.out.printIn ("from class Dog: } / D. Method hiding A. Method overloading B. Method binding E. Method Overriding ; C. Method copying ¥. Which of the following statement describes dy! "xy; namic resizing as is applies to the ArrayList class? Av The size of a new ArrayList object must be specified at instantiation. B. The size of an ArrayList object can be iterated throughout a Program. C. The size of an ArrayList object is fixed at instantiation. D.The object changes size dynamically as new elements are added. E. Both A andB vi. Assume you have three classes: Person, Teacher, and Student. Teacher and Student are both subclasses of Person. The Person Question One Read eae! iii. (0 MARKS) SECTION A: ¢ most correct respons and choose th (1 Marks Each) fh question carefully declared ina class is called 5 D. Object variables The static variable E, Global variables A. Local Variables B. Class variables C. Instance variables Which of the following characteristics of an object-oriented programming language restricts behaviour so that an object can perform actions that are defined for its class? D. Encapsulation only FE. Abstraction A. Dynamic Binding B. Polymorphism C. Inheritance Which command lines will compile and run java class called echo respectively? A. javac echo and java echo,java B.javac echo.java and java echo C. java echo.class and javac echo D. java echo and javac echo.java E. javac echo. java and java echo.class Question Three 2 2 Mark (@) Why main method is declared static” @ Marks) (0) Briefly explain how add(index, values) affect the performance of 1 2 Ma Jaya collection? (@ Marks) (©) Carefully read the following program and use it to answer questions that follow: -comments indicate where missing components of the program are to be placed. (2 Marks Each) public class MyMain { publie static yoid main(String { Jargs)( //(2)print the greeting //(3) construct a MyClass object called myObject //(4) update() } } class MyClass( “4/ (1) definition of M; i yClass_ construct Public static void greetings () { a h // definition of g: Public void update (in /f definition o } Public void pr. 0 4 definition ng title) { A INSTRUCTIONS TO CANDIDATES i. This examination paper consists of TWO (2) -Sectio SEVEN (7) questions in FIFTEEN (15) printed pages, ii, Answer all questions in Sections A and THREE (3) questions in Section B, iii. The total score for this examination is 100 points, Marks are allocated at the end of each question. iv. ALL responses should be written in the answer book provided Insert the examination Paper into the answer book after the examination. Students should not take any examination paper(s) Out of the examination room, All regulations guiding the administrati on of university ¢xaminations apply, application to ote can invoke jects. Class Invoice ation for only one bles partNumber, partDeser ntains @ constructor, | Invoice obj «ce that contains billing inform: kind of part. The class declares private instance varial quantity and pricePerltem. Class Invoice also col methods and a toString method that returns 2 String representation of an 7 object. The class Employee contains employee’s firstName, fami id . Si: an : lo It also contains a constructor for ‘on of instance variable and a toString method for returning its string representation. Salaried : employee is paid a fixed 7a weekly sali »gardless of the number of hours worked. Thereft . a: class should contain a uni i fore, SalariedEmployee ique variable called salary, a constructor, a

You might also like