Sei sulla pagina 1di 2

United International University

Department of Computer Science and Engineering


CSI 212 Object Oriented Programming Lab
Mid-term Examination, Fall 2016
Marks: 10 2 = 20 and 20 on Question 11.

Name

ID

Section

1. What is the difference between static and non-static methods?

2. If a class name Account , write code to access a method called ShowBalance from it.

3. Give two examples each of compile time and run time errors?

4. Class XV has static member int a = 799 , class RomanNumeral extends class XV . Write code to access
static member of RomanNumeral inside main method of a class named Numerals .

5. An abstract class Rail has a regular method MonoRail and an abstract method MetroRail . Define a class
called RunEngine that extends Rail such that no error is given on run time.

6. What is the use of finally block in java and when is it executed?

7. Give a simple example of method overloading and overriding with class name SimpleClass and method name
SimpleClassMethod ?

8. You are given an abstract class Torso with abstract method moveTorso , an interface named Head with
method nodHead and another interface named Limbs with method moveLimbs . Write a class named
Human implementing all necessary methods from the class given above.

9. We have a code Shape s = new Triangle(); . Which one is super class and which one is sub class and what
is this code example of?

10. Write the names of four fundamental Object Oriented Programming concepts.

11. Write a JAVA code with three classes Card , Player and App . Card has two private attributes value
and suit . value can be assigned with 13 (thirteen) possible values from the set {2,3,4,5,6,7,8,9,10,J,Q,K,A}.
suit can have 4 (four) possible values from {Spade, Heart, Diamond, Clubs}. You need to add setters, getters
and parameterized constructor for Card . Player has an array of 13 (thirteen) Card objects. There should
be a method named addCard(Card c) which will add a card in the array. It also has a method printHand()
which prints all the thirteen cards suit and value. Now, inside App class create main(String args[]) method
and create 4 (four) objects of Player named east, west, north and south. Now assign 52 cards within these
4 players (13 each) RANDOMLY (using) using addCard(Card c) method. Print all the players hand (13
cards) and also print the count of face {K, Q, J} cards for each player.

Potrebbero piacerti anche