Register No.
SRM Institute of Science and Technology
College of Engineering and Technology
SET - B
School of Computing
Department of Networking and Communications
Academic Year: 2022-23 (EVEN)
Test: CLA-T1 Date: 6-9-2023
Course Code & Title: 21CSC203P Advanced Programming Practice Duration: 100 minutes
Year & Sem: II Year / III Sem Max. Marks: 50
Course Articulation Matrix: (to be placed)
S.No. Course PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2 PSO3
Outcome
3 2 - - - - - - - - - - - 2 -
1 CO1
3 2 - 1 - - - - - - - - - 2 -
2 CO2
3 - 2 - 2 - - - - 1 - - - 2 -
3 CO3
3 2 - 1 - - - - - - - - - 2 -
4 CO4
3 - 2 1 2 - - - - 1 - - - 2 -
5 CO5
Part - A
(10 x 1 = 10 Marks)
Instructions: Answer all
Q. Question Marks BL CO PO PI
No Code
1 HTML/CSS for web development, and MATLAB 1 L1 1 1 1.4.1
for numerical computing are those languages
commonly used for
a) Low-Level Languages
b) High-Level Languages
c) Scripting Languages
d) Domain-Specific Languages
2 Assembly language are generally stated as 1 L1 1 1 1.4.1
a) Low-Level Languages
b) High-Level Languages
c) Domain-Specific Languages
d) Object-Oriented Languages
3 __________ defines the rules and structure of a 1 L1 1 1 1.4.1
programming language.
a) Syntax
b) Comments
c) Datatypes
d) Functions
4 ____________focuses on type checking, program 1 L1 1 1 1.4.1
verification, optimization techniques, and program
understanding
a) Programming Language Automata
b) Programming Language Analysis
c) Language Expressiveness
d) Programming Language Semantics
5 _________ refers to the process of converting an 1 L1 1 1 1.4.1
object's state into a format that can be stored,
transmitted, or reconstructed later.
a) Message Passing
b) Object Serialization
c) Dynamically Dispatching
d) Parallel and Concurrent
6 What is the correct output of following program? 1 L2 2 2 1.4.1
public class First_C {
public void myMethod(){
System.out.println("Method");
}
{
System.out.println(" Instance Block");
}
public void First_C() {
System.out.println("Constructor ");
}
static {
System.out.println("static block");
}
public static void main(String[] args) {
First_C c = new First_C();
c.First_C();
c.myMethod();
}
}
a) Method, Instant Block, Constructor, static block.
b) Constructor, static block, Instant Block, Method.
c) Instant Block, Method, Constructor, static block.
d) static block, Instant Block, Constructor, Method.
7 What will be the output of the program? 1 L2 2 1 1.4.1
class Main {
public static void main(String [] args) {
Main p = new Main();
p.start();
}
void start() {
boolean b1 = false;
boolean b2 = fix(b1);
System.out.println(b1 + " " + b2);
}
boolean fix(boolean b1) {
b1 = true;
return b1;
}
}
a) true true
b) true false
c) false true
d) false false
8 What will be the output of the program? 1 L2 2 1 1.4.1
class Main {
public static void main(String args[]) {
System.out.println(fun());
}
int fun() {
return 20;
}
}
a) 20
b) compiler error
c) 0
d) garbage value
9 An interface in Java is related to? 1 L2 2 1 1.4.1
a) static class
b) abstract class
c) instance method
d) constructor
10 What is the output of the below Java program with 1 L2 2 2 1.4.1
multiple methods?
class A
{
int i;
}
class B extends A
{
int j;
void display()
{
super.i = j + 1;
System.out.println(j + " " + i);
}
}
class inheritance
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
a) 2 2
b) 3 3
c) 2 3
d) 3 2
Part – B
(4 x 4 = 16 Marks)
Answer any 4 Questions
11 State structured program theorem. 4 L1 1 1 1.4.1
The Böhm-Jacopini theorem, is a fundamental result
in programming language theory. It states that any
computation can be performed using only three
basic control structures: sequence, selection (if-then-
else), and iteration (while or for loops). This means
that any program, regardless of its complexity, can
be expressed using these three control structures
alone.
The theorem is significant because it
establishes that more complex control structures,
such as goto statements or multiple exit points, are
not necessary to express any algorithm.
By limiting the control structures to sequence,
selection, and iteration, the theorem promotes
structured programming, which emphasizes readable
and modular code.
12 Signify the importance of parallel computing. 4 L2 1 2 1.4.1
Parallel processing is a concept that refers to the
simultaneous execution of multiple tasks or
processes. It involves dividing a problem into
smaller subproblems that can be executed
concurrently on multiple processors or cores. The
goal of parallel processing is to improve
performance and efficiency by exploiting the
available computational resources.
Parallel processing can be achieved through various
techniques, such as multi-threading,
multiprocessing, and distributed computing.
Languages like Go, Erlang, and Java (with
concurrency libraries) provide support for parallel
processing.
13 Interpret the accessibility of data in Java 4 L2 2 1 1.4.1
The access modifiers in Java specifies the
accessibility or scope of a field, method, constructor,
or class. The access level can be changed to fields,
constructors, methods, and classes by applying the
access modifier on it. The Java language supports
private, protected, public.
14 Enumerate the built-in packages in Java 4 L2 2 2 1.4.1
Packages that come with JDK or JRD you download
are known as built-in packages. The built-in
packages have come in the form of JAR files and
when we unzip the JAR files we can easily see the
packages in JAR files, for example, lang, io, util,
SQL, etc. Java provides various built-in packages
for example java.awt
15 Differentiate between constructor and method in 4 L2 2 2 1.4.1
Java.
Constructors Methods
A Constructor is a block of code that A Method is a collection of statements
initializes a newly created object. which returns a value upon its execution.
A Constructor can be used to initialize an A Method consists of Java code to be
object. executed.
A Constructor is invoked implicitly by the A Method is invoked by the programmer.
system.
A Constructor is invoked when a object is A Method is invoked through method calls.
created using the keyword new.
A Constructor doesn’t have a return type. A Method must have a return type.
A Constructor initializes a object that A Method does operations on an already
doesn’t exist. created object.
A Constructor’s name must be same as the A Method’s name can be anything.
name of the class.
A class can have many Constructors but A class can have many methods but must
must not have the same parameters. not have the same parameters.
A Constructor cannot be inherited by A Method can be inherited by subclasses.
subclasses.
Part – C
(2 x 12 = 24 Marks)
16. a Distinguish between logic and functional 4 L2 1 2 1.4.1
i) programming paradigms
Functional Programming Logical Programming
It is totally based on functions. It is totally based on formal logic.
In this programming paradigm, programs In this programming paradigm, program statements
are constructed by applying and composing usually express or represent facts and rules related to
functions. problems within a system of formal logic.
These are specially designed to manage and These are specially designed for fault diagnosis,
handle symbolic computation and list natural language processing, planning, and machine
processing applications. learning.
Its main aim is to reduce side effects that Its main aim is to allow machines to reason because it
are accomplished by isolating them from is very useful for representing knowledge.
the rest of the software code.
Some languages used in functional Some languages used for logic programming include
programming include Clojure, Wolfram Absys, Cycl, Alice, ALF (Algebraic logic functional
Language, Erland, OCaml, etc. programming language), etc.
It reduces code redundancy, improves It is data-driven, array-oriented, used to express
modularity, solves complex problems, knowledge, etc.
increases maintainability, etc.
It usually supports the functional It usually supports the logic programming paradigm.
programming paradigm.
Testing is much easier as compared to Testing is comparatively more difficult as compared
logical programming. to functional programming.
It simply uses functions. It simply uses predicates. Here, the predicate is not a
function i.e., it does not have a return value.
ii) Mithun aims to design a mini keyboard with alpha- 8 L3 1 4 2.2.4
numeral keys. He tries to test the keyboard for
numerals and negates other keys. Help Mithun, with
a code of structured programming paradigm to
identify the key pressed.
import java.lang.*;
import java.util.Scanner;
public class TestClass
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
String str = sc.next();//.charAt(0);
if (str.length() >1)
{
System.out.println("Not allowed"); return;
}
char c=str.charAt(0);
boolean b1;
b1 = Character.isDigit(c);
if(b1) System.out.println("You pressed "+c);
else
System.out.println("Not allowed");
}
}
Or
b i) Discuss the hierarchy of programming paradigm 4 L1 1 1 1.4.1
ii) The Mn Finance Ltd lends $5000 at 10% per annum 8 L3 1 4, 2.2.4
for five years to Mr.Bharath. Bharath queried about PSO2
the simple interest and total amount due after five
years for the offered amount. Guide Bharath in
finding the amount, using the structured
programming paradigm for computation.
import java.util.Scanner;
public class JavaExample
{
public static void main(String args[])
{
float p, r, t, sinterest;
Scanner scan = new Scanner(System.in);
System.out.print("Enter the Principal : ");
p = scan.nextFloat();
System.out.print("Enter the Rate of interest : ");
r = scan.nextFloat();
System.out.print("Enter the Time period : ");
t = scan.nextFloat();
scan.close();
sinterest = (p * r * t) / 100;
System.out.print("Simple Interest is: "
+sinterest);
}
}
17. a Describe function definition and calling in Java. 4 L1 2 1 1.4.1
i) In Java, a function is a set of statements that
executes a specific task/operation when someone
invokes it. Functions/methods are popularly used
concepts in any programming language that
facilitates us with the reusability of the code. In a
java program, each function must have a unique
name. Every function will be called/invoked with its
name. Once a user invokes a function the code
associated with that function will get executed.
public class ExampleClass {
void showInformation() {
System.out.println("This is a user-defined non-
static function");
}
public static void main(String[] args) {
ExampleClass exObj = new ExampleClass();
exObj.showInformation();
}
}
ii) ELEC is a leading Electronics showroom. The 8 L3 2 4, 2.2.4
PSO2
showroom has the specialty of Grinders, with the
follow-up technique of Wet Grinder. Devise the
hierarchical order through which the customer can
have a device category. Hint- Use Constructor with
reusability
class Electronics {
public Electronics(){
System.out.println("Class Electronics");
}
public void deviceType() {
System.out.println("Device Type: Electronics");
}
}
class Grinder extends Electronics {
public Grinder() {
System.out.println("Class Grinder");
}
public void category() {
System.out.println("Category - Grinder");
}
}
class WetGrinder extends Grinder {
public WetGrinder() {
System.out.println("Class WetGrinder");
}
public void grinding_tech() {
System.out.println("Grinding Technology-
WetGrinder");
}
}
public class Tester {
public static void main(String[] arguments) {
WetGrinder wt= new WetGrinder();
wt.deviceType();
wt.category();
wt.grinding_tech();
}
}
Or
b i) Distinguish between method overloading and 4 L2 2 1 1.4.1
method overriding
Method Overloading Method Overriding
Method overloading is a compile-time Method overriding is a run-time polymorphism.
polymorphism.
Method overloading helps to increase the Method overriding is used to grant the specific
readability of the program. implementation of the method which is already
provided by its parent class or superclass.
It occurs within the class. It is performed in two classes with inheritance
relationships.
Method overloading may or may not Method overriding always needs inheritance.
require inheritance.
In method overloading, methods must In method overriding, methods must have the
have the same name and different same name and same signature.
signatures.
In method overloading, the return type In method overriding, the return type must be the
can or can not be the same, but we just same or co-variant.
have to change the parameter.
Static binding is being used for Dynamic binding is being used for overriding
overloaded methods. methods.
Poor Performance due to compile time It gives better performance. The reason behind
polymorphism. this is that the binding of overridden methods is
being done at runtime.
Private and final methods can be Private and final methods can’t be overridden.
overloaded.
The argument list should be different The argument list should be the same in method
while doing method overloading. overriding.
Digital Print service Ltd., need to develop an 8 L3 2 4, 2.2.4
application to implement the printer service. It PSO2
provides functionalities.
1.Print
2.Fax
3.Scan
4.PrintDuplex
The HPDigital makes use of all the functionalities
and the Inkjet makes use of print and scan. Help the
service centre in devising the application using Java
programming. Hint-Interface
interface IPrinterTasks {
void Print(string PrintContent);
void Scan(string ScanContent);
}
interface IFaxTasks {
void Fax(string content);
}
interface IPrintDuplexTasks {
void PrintDuplex(string content);
}
class HPLaserJetPrinter implements IPrinterTasks,
IFaxTasks, IPrintDuplexTasks
{
public void Print(string PrintContent)
{
System.out.println(PrintContent);
}
public void Scan(string ScanContent)
{
System.out.println (ScanContent);
}
public void Fax(string FaxContent)
{
System.out.println (FaxContent);
}
public void PrintDuplex(string
PrintDuplexContent)
{
System.out.println (PrintDuplexContent);
}
}
class LiquidInkjetPrinter implements IPrinterTasks
{
public void Print(string PrintContent)
{
System.out.println (PrintContent);
}
public void Scan(string ScanContent)
{
System.out.println (ScanContent);
}
}
class Program
{
public static void main(string[] args)
{
HPLaserJetPrinter hPLaserJetPrinter = new
HPLaserJetPrinter();
hPLaserJetPrinter.Scan("Scan Services by
HPLaserJetPrinter");
hPLaserJetPrinter.Print("Print Services by
HPLaserJetPrinter");
hPLaserJetPrinter.Fax("Fax Services by
HPLaserJetPrinter");
hPLaserJetPrinter.PrintDuplex("Print Duplex
Services by HPLaserJetPrinter");
LiquidInkjetPrinter liquidInkjetPrinter = new
LiquidInkjetPrinter();
liquidInkjetPrinter.Scan("Scan Services by
LiquidInkjetPrinter");
liquidInkjetPrinter.Print("Print Services by
LiquidInkjetPrinter");
}
}
*Program Indicators are available separately for Computer Science and Engineering in AICTE
examination reforms policy.
Course Outcome (CO) and Bloom’s level (BL) Coverage in Questions
Approved by the Audit Professor/Course Coordinator