You are on page 1of 14

Modern Programming Languages Assignment

Dr. Saif Ur Rehman


Assistant Professor
University Institute of Information Technology
PMAS – University of Arid Agriculture – Rawalpindi
Deadline: 31st October 2022 4PM
Assignment # 1
Question# 1 Define the following Programming Languages Categories
a. Modern Programming Languages

b. Procedural Programming Languages

c. Functional Programming Languages

d. Symbolic Programming Languages

e. Object Oriented Programming Languages

f. Structured Programming Languages

g. Unstructured Programming Languages

Question# 2 Differentiate between


a. C++ and Java

b. C-Sharp and Java

c. PHP and Java

d. Object Code (.obj) and Byte Code (.class)

e. MSIL and JVM

Question# 3 Write the complete History of Java? Who Developed Java? When Java developed?
Question# 4 Why Java Developed?
Question# 5 What are Java Buzzwords? Define each of the Java Buzzwords?
Question# 6 What are the features of Java?
Question# 7 Do As Directed….
a. Define
a. JRE
b. JIT
c. JVM
d. Byte Code
e. Java is Platform Independent
f. JDK? Why it is used? What are its advantages?
g. When first Version of JDK was launched? Which version is currently
in use?
h. In which language does the Java Compiler is written
i. In which language does the C++ Compiler was written
j. Does Java Support Pointers?
k. List down various types of applications that can be developed in Java
l. What is J2EE, J2SE, J2ME. Also write down the difference between
J2EE, J2SE, J2ME
m. What is JRE? Why JRE is used?
n. Is Java a Compiled or an Interpreted programming language?
o. Define Just-in Time Compiler
p. Define JVM? Why JVM is used?
q. Write down Complete Procedure diagrammatically how the Java
Program is compiled and executed
r. Define Object Cloning

Question# 8 Complete the Following Table and add as many rows to table as needed
Table 1: Java Version Development Years
S# Version Developed On (Enter Date of Release)
1 Java 1.0
2
3
4
5
6
7

Table 2: Java Development Kit Release Years


S# Version Developed On (Enter Date of Release)
1 JDK 1.0
2
3
4
5
6
7
Table 3: Java Supported Data Types
S# Data Type Name Minimum Range and Maximum Range
1
2
3
4
5
6
7

Question# 9 Write down at least ten Editor available for Java program development?
Question# 10 Write down the type of Applications which can be developed using Java?
Question# 11 Write the program structure of Java
Question# 12What the output statements are available in Java? How Java Program read Inputs
from Users
Question# 13

(a) Declare One Dimensional Array of Size 100 and Initialize all its Elements to 0

(b) Declare Two Dimensional Array of Size 5 X 7 and Initialize all its Elements to 0

(c) Declare One Dimensional Array of Size m and Initialize all its Elements to 0. Where m is the

size of One Dimensional Array input by User.

(d) Declare Three Dimensional Array of Size 3 X 4 X 6 and Initialize all its Elements to 0.

(e) Search for the different built-in Java Array Functions. Give an example against each of the

built-in array function

Question# 14
(a) Why the Scanner Class is used in Java

(b) In which Java Package Scanner class is defined

(c) How you can read data using the Scanner class in an Integer Array

(d) How you can read data using the Scanner class in an Integer Array

(e) How you can read data using the Scanner class in an String Array

(f) How you can read data using the Scanner class in an Floating Point Array

Question# 15
a. How an array of type String is declared

b. Write down all the built-in String class methods available in Java. Give an example for

each of the Java String class built-in methods

Question# 16 Differentiate
a. Class and Object

b. Method Overloading and Overriding

c. Differentiate between the Inheritance in C++ and Java

d. Which Keyword is used for inheriting a class in Java

e. Single Inheritance and Multiple Inheritance

f. Single Level and Multilevel Class Inheritance

g. Class and Interface

h. Class and Abstract Class

i. Explain the difference between JDK, JRE, and JVM.

j. Would it be correct to say that Java is not 100% Object-oriented?

k. What is the purpose of garbage collection in Java, and when is it used?


l. What if the main() method is declared as private? What happens when the static modifier

is removed from the signature of the main() method?

m. What is the first argument of the String array in main() method?

n. Differentiate JAR and WAR files

o. What is a JIT compiler?

Question# 17
a. What is Interface

b. Why Interfaces are used

c. What is the syntax of defining an Interface

d. What are the advantages of using Interfaces in Java

e. Which keyword is used to implement the interface in Java

f. How you will use Interfaces to have the multiple inheritance in Java
Modern Programming Languages Assignment
Assignment No. 2

Dr. Saif Ur Rehman


Assistant Professor
University Institute of Information Technology
PMAS – University of Arid Agriculture - Rawalpindi
Old Modern Programming Languages

Exam Mid Papers


Attempt the Following Question (Modern Programming Language Final Paper, SPRING
2015)
I. Output of
public class Test implements Runnable {
public void run() {
System.out.println( "running!" );
}
public void start( int i ) {
}
public static void main( String[] args ) {
Test t = new Test();
Thread th = new Thread( t );
t.start( 1 );
}
}
II. In Java, an abstract class can implement Interfaces. True/False
III. Grid layout positions components left to right, top to bottom. True/False
IV. An Interface can have non-abstract Methods in their body. True/False
V. Output of
public static void main(String[] args)
{
int[] arr = { 0, 1, 2, 3, 4 };
System.out.println(arr[arr[arr.length-1]] );
}
VI. Abstract class can be instantiated. True/False
VII. Super class object can access any public Method of its Sub Class True/False
VIII. ArrayList cannot grow or shrink its size according to program need True/False
IX. IOException occurs when required file is not present in the provided Path. True/False
X. Output of System.out.println(“3 in binary Nos=” + “Integer.toBinaryString(3)”);

Q No.2 Suppose we have the following a table named “tblOrderDetails (OrderID, ItemName,

Quantity, Price)” in the database nameddb_Super_Store. Your task is to code in Java to MySQL

or Java to SQL Server for the following.

i. Add new record to database [Marks: 02]

ii. Delete an existing record from database [Marks: 02]

iii. Find how much quantity has been ordered upto now for Item Name = “Laptops”[Marks: 03]
iv. Implement the Exception Handling where necessary. Your program also check that Quantity

should not be less than 1 [Marks: 02]

v. Item Name cannot be NULL as well as each Item Name length cannot be less than 5.

[Marks: 01]

Q No.3 In Java keyword final is used to prevent overriding and inheritance. Explain these two
uses of final keyword in Java with programming examples. [Marks: 02]

Q No.4 Design a calculator application in Java and then code for the following functions

a. Convert input No to Hexadecimal, Octal base [Marks: 01]


b. Find the log, Sin, Cos, Tan of the input No [Marks: 01]
c. Find Cube and Factorial of the input no [Marks: 01]

Q No.5 Create a file in D drive. Add the following Text into this file using Java Code. Finally,
perform the following operations on this text file. [Marks: 20]

a. Display the length of the text file


b. How many times name Pakistan has been used in this text file.

c. Replace all the Words Pakistan with our Motherland.

d. Count the frequency of The, of and are.


Mid Examination – Fall 2016
Question 1: Do As Directed

1. Differentiate between Byte Code and Object Code [Marks: 0.5]


2. Briefly define try-catch-finaly block in Java. Give programming examples [Marks: 1]
3. Define JVM, Command Line Arguments, import keyword, Data Hiding [Marks: 01]
4. Why super keyword is used in Java? Give programming examples to show the use of super keyword
[Marks: 01]
5. Method overloading and Method overriding in Java. Give programming examples [Marks: 01]
6. Abstract class can be instantiated [Yes or No] [Marks: 0.5]
Question 2: what will be the output of the following java code [Marks: 2]

abstract class A { class equality {


abstract void callme(); int x;
void callmetoo() { int y;
System.out.println("This is a concrete boolean isequal() {
method."); return (x == y);
} }
} }
class Output {
class B extends A {
void callmetoo() {
public static void main(String args[]) {
System.out.println("B's implementation of
callme.");
equality obj = new equality();
}
} obj.x = 5;
obj.y = 5;
class AbstractDemo {
public static void main(String args[]) { System.out.println(obj.isequal);
B b = new B(); }
b.callmetoo();
} }
}}

Question 3: [Marks: 2]

A cloth showroom has announced the following seasonal discounts on purchase of items:

Purchase Amount Discount


Mill Cloth Handloom items

0 – 100 - 5.00%

101-200 5.00% 7.50%

201-300 7.50% 10.00%

Above 300 10.00% 15.00%

Write a program using switch and if statements to compute the net amount to be paid by a customer.

Question 4: [Marks: 3]

Design a class in Java for Patient with Patient_Number, Patient_Name, Disease_Type instance variables.
Add methods for reading, displaying and searching data. Finally, instantiate the class and test the class
methods.
MID Examination – Summer 2016

BSCS/MCS

Modern Programming Language CS-793

Total Time: 90 Minutes Maximum Points: 12

Q No. 1 Do as directed [2 Marks]

1. JVM will differ from platform to platform but still all understand the Same Java Bytecode
[True/False]
2. JVM is a _____________ .
a. Interpreter b. Debugger c. Assembler d. Compiler
3. Which of the following statements about the Java language is true?
a. Both procedural and OOP are supported in Java.
b. Java supports only procedural approach towards programming.
c. Java supports only OOP approach.
d. None of the above.
4. Which of these is correct way of inheriting class A by class B?
a) class B + class A {}
b) class B inherits class A {}
c) class B extends A {}
d) class B extends class A {}
5. What of the following limits a class and its members to be used only within the class, classes
within same package and classes that inherits them.
a. public b. private c. protected d. default
The command to execute a compiled program is _________
a. run b. execute c. javac d. java
6. Which of the following is NOT an advantage to using inheritance?
a. Code that is shared between classes needs to be written only once.
b. Similar classes can be made to behave consistently.
c. Enhancements to a base class will automatically be applied to derived classes.
d. One big superclass can be used instead of many little classes.
7. Which of these keywords must be used to monitor for exceptions?
a) try b) finally c) throw d) catch
8. Define the following terms
a. Java is platform independent language
b. Method overriding Vs Method Overloading, provide programming Example
c. Use of Super keyword in Java

Q No.2 Design a Class named PakistanMotorWay. In this Class, you are required to manage the different
types Vehicles passing on daily basis. You are also required to enter the different type of Vehicles and Tool
Rate for each Vehicle. Also, your program should display a Menu for different Choices. As the user chooses
a choice then your application should respond accordingly. The sample run and output of the program is
show below. Implement this entire scenario using Java Classes. Inheritance, Interfaces (if required). Only
neat and working code will give you marks. No marks will be given if code is not written clearly. You
program should display the Menu repeatedly until he/she choose the option 5 or 6 and display the complete
details as shown[3 Marks]

Sample Run
Program Menu : Please Enter your Choice
0 : Car
1 : Bus
2 : Jeep
3 : Truck
4 : Long Vehicle
5 : Exit
6 : Report Display

Sample output
****************** Pakistan Motorway ******************
****************** Islamabad Tool Plaza******************
S# Vehicle Type # of Entries Total Tool
1 Car 10 500
2 Bus 10 1000
3 Jeep 5 10000
4 Truck 15 10000
5 Long Vehicle 10 100

Grand Total : 21600 (Rs.)

You might also like