All in One JPR I Scheme Model Answer Papers
All in One JPR I Scheme Model Answer Papers
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 1 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Syntax: Syntax
protected void finalize() { 1M
}
c) Name the wrapper class methods for the following: 2M
(i) To convert string objects to primitive int.
(ii) To convert primitive int to string objects.
Ans. (i) To convert string objects to primitive int:
String str=”5”;
int value = Integer.parseInt(str); 1M for
each
(ii) To convert primitive int to string objects: method
int value=5;
String str=Integer.toString(value);
d) List the types of inheritances in Java. 2M
(Note: Any four types shall be considered)
Ans. Types of inheritances in Java:
i. Single level inheritance Any
ii. Multilevel inheritance four
iii. Hierarchical inheritance types
iv. Multiple inheritance ½M
v. Hybrid inheritance each
Page 2 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
byte code.
Diagram
1M
Page 4 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 5 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
name=n;
}
void display() {
System.out.println("Roll no is: "+roll_no);
System.out.println("Name is : "+name);
}
public static void main(String a[]) {
Student s = new Student(20,"ABC");
s.display();
}
}
Page 6 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 7 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 8 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 9 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
for(i=0;i<5;i++)
{
arr[i].display();
}
}
}
b) Explain dynamic method dispatch in Java with suitable example. 4M
Ans. Dynamic method dispatch is the mechanism by which a call to an
overridden method is resolved at run time, rather than compile time.
When an overridden method is called through a superclass
reference, Java determines which version (superclass/subclasses) of
that method is to be executed based upon the type of the object being
referred to at the time the call occurs. Thus, this determination is
made at run time.
At run-time, it depends on the type of the object being referred to
Explana
(not the type of the reference variable) that determines which version
tion 2M
of an overridden method will be executed
A superclass reference variable can refer to a subclass object. This
is also known as upcasting. Java uses this fact to resolve calls to
overridden methods at run time.
Therefore, if a superclass contains a method that is overridden by a
subclass, then when different types of objects are referred to through
a superclass reference variable, different versions of the method are
executed. Here is an example that illustrates dynamic method
dispatch:
// A Java program to illustrate Dynamic Method
// Dispatch using hierarchical inheritance
class A
{
void m1()
{
System.out.println("Inside A's m1 method");
}
}
Example
2M
class B extends A
{
// overriding m1()
void m1()
Page 10 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
{
System.out.println("Inside B's m1 method");
}
}
class C extends A
{
// overriding m1()
void m1()
{
System.out.println("Inside C's m1 method");
}
}
// Driver class
class Dispatch
{
public static void main(String args[])
{
// object of type A
A a = new A();
// object of type B
B b = new B();
// object of type C
C c = new C();
Page 11 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 12 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 13 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 14 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 15 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 16 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 17 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
// Driver class
class Dispatch
{
public static void main(String args[])
{
// object of type A
A a = new A();
// object of type B
B b = new B();
// object of type C
C c = new C();
Page 18 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Output:
Inside A’s m1 method
Inside B’s m1 method
Inside C’s m1 method
Explanation:
The above program creates one superclass called A and it’s two
subclasses B and C. These subclasses overrides m1( ) method.
1. Inside the main() method in Dispatch class, initially objects of
type A, B, and C are declared.
2. A a = new A(); // object of type A
3. B b = new B(); // object of type B
C c = new C(); // object of type C
Page 19 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 20 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
The arguments passed from the console can be received in the java
program and it can be used as an input.
So, it provides a convenient way to check the behaviour of the
program for the different values. You can pass N (1,2,3 and so on)
numbers of arguments from the command prompt.
4M for
Command Line Arguments can be used to specify configuration explanat
information while launching your application. ion
There is no restriction on the number of java command line
arguments.
You can specify any number of arguments
Information is passed as Strings.
They are captured into the String args of your main method
In this example, we are receiving only one argument and printing it.
To run this java program, you must pass at least one argument from
the command prompt.
class CommandLineExample
{
public static void main(String args[]){
System.out.println("Your first argument is: "+args[0]); 2M for
} example
}
compile by > javac CommandLineExample.java
run by > java CommandLineExample sonoo
b) Write a program to input name and salary of employee and 6M
throw user defined exception if entered salary is negative.
Ans. import java.io.*;
class NegativeSalaryException extends Exception Extende
{ d
public NegativeSalaryException (String str) Exceptio
{ n class
super(str); with
} construc
} tor 2M
public class S1
Page 21 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
{
public static void main(String[] args) throws IOException
{ Acceptin
BufferedReaderbr= new BufferedReader(new g data
InputStreamReader(System.in)); 1M
System.out.print("Enter Name of employee");
String name = br.readLine();
System.out.print("Enter Salary of employee");
int salary = Integer.parseInt(br.readLine()); Throwin
Try g user
{ defining
if(salary<0) Exceptio
throw new NegativeSalaryException("Enter Salary amount n with
isnegative"); try catch
System.out.println("Salary is "+salary); and
} throw
catch (NegativeSalaryException a) 3M
{
System.out.println(a);
}
}
}
c) Describe the applet life cycle in detail. 6M
Ans.
2M
Diagram
Page 22 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
start(): The start() method contains the actual code of the applet that 4M
should run. The start() method executes immediately after descripti
the init() method. It also executes whenever the applet is restored, on
maximized or moving from one tab to another tab in the browser.
stop(): The stop() method stops the execution of the applet. The
stop() method executes when the applet is minimized or when
moving from one tab to another in the browser.
paint(): The paint() method is used to redraw the output on the applet
display area. The paint() method executes after the execution
of start() method and whenever the applet or browser is resized.
The method execution sequence when an applet is executed is:
init()
start()
paint()
The method execution sequence when an applet is closed is:
stop()
destroy()
Page 23 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
SUMMER – 2022 EXAMINATION
Subject Name:Data Communication & Computer Network Model Answer Subject Code: 22414
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the model
XXXXX
answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to
assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance
(Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the
figure. The figures drawn by candidate and model answer may vary. The examiner may give
credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant
values may vary and there may be some difference in the candidate’s answers and model
answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant
answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on
equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and
Bilingual (English + Marathi) medium is introduced at first year of AICTE diploma Programme
from academic year 2021-2022. Hence if the students in first year (first and second semesters)
write answers in Marathi or bilingual language (English +Marathi), the Examiner shall consider
the same and assess the answer based on matching of concepts with model answer.
Ans A computer network is a system that connects various independent computers in order to Correct
share information (data) and resources. definition-2
M
OR
A computer network is a collection of two or more computer systems that are linked
together. A network connection can be established using either cable or wireless media.
OR
A computer network is defined as a system that connects two or more computing devices
for transmitting and sharing information.
Page No: 1 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Following are the types of multiplexing: Correct
1. Frequency-Division Multiplexing types-2 M
2. Wavelength-Division Multiplexing
3. Time-Division Multiplexing
a) Synchronous Time-Division Multiplexing
b) Asynchronous Time-Division Multiplexing
c) List different types of errors 2M
Page No: 2 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
ii) Bandwidth:
The bandwidth of a composite signal is the difference between the highest and the
lowest frequencies contained in that signal.
For example, if a composite signal contains frequencies between 1000 and 5000, its
bandwidth is 5000 - 1000, or 4000.
Ans o The way in which data is transmitted from one device to another device is known List-1M
as transmission mode. All 3 modes
o The transmission mode is also known as the communication mode. Explanation
with figure-
3M
The Transmission mode is divided into three categories:
o Simplex mode
o Half-duplex mode
o Full-duplex mode
Simplex mode
Page No: 3 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
o In Simplex mode, the communication is unidirectional, i.e., the data flow in one
direction.
o A device can only send the data but cannot receive it or it can receive the data but
cannot send the data.
o This transmission mode is not very popular as mainly communications require the
two-way exchange of data. The simplex mode is used in the business field as in
sales that do not require any corresponding reply.
o The radio station is a simplex channel as it transmits the signal to the listeners but
never allows them to transmit back.
o Keyboard and Monitor are the examples of the simplex mode as a keyboard can
only accept the data from the user and monitor can only be used to display the data
on the screen.
Half-Duplex mode
o In a Half-duplex channel, direction can be reversed, i.e., the station can transmit and
receive the data as well.
o Messages flow in both the directions, but not at the same time.
o The entire bandwidth of the communication channel is utilized in one direction at a
time.
o In half-duplex mode, it is possible to perform the error detection, and if any error
occurs, then the receiver requests the sender to retransmit the data.
o A Walkie-talkie is an example of the Half-duplex mode. In Walkie-talkie, one party
speaks, and another party listens. After a pause, the other speaks and first party
listens. Speaking simultaneously will create the distorted sound which cannot be
understood.
Page No: 4 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Full-duplex mode
o In Full duplex mode, the communication is bi-directional, i.e., the data flow in both
the directions.
o Both the stations can send and receive the message simultaneously.
o Full-duplex mode has two simplex channels. One channel has traffic moving in one
direction, and another channel has traffic flowing in the opposite direction.
o The Full-duplex mode is the fastest mode of communication between devices.
o The most common example of the full-duplex mode is a telephone network. When
two people are communicating with each other by a telephone line, both can talk and
listen at the same time.
Architecture: ESS:
The standard defines two kinds of services: the basic service set (BSS) and the extended
explanation
service set (ESS).
with fig:2M
In this architecture, stations can form a network without the need of an AP; they can
locate one another and agree to be part of a BSS. A BSS with an AP is sometimes
referred to as an infrastructure network.
When BSSs are connected, the stations within reach of one another can communicate
without the use of an AP. However, communication between two stations in two
different BSSs usually occurs via two APs. The idea is similar to communication in a
cellular network if we consider each BSS to be a cell and each AP to be a base station.
Note that a mobile station can belong to more than one BSS at the same time.
c) Explain Bluetooth Architecture. 4M
Ans Bluetooth technology is the implementation of a protocol defined by the IEEE 802.15 Explanation
standard. of Piconet
Page No: 6 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
with
Architecture diagram-2M
Bluetooth defines two types of networks: piconet and scatternet.
Piconets: Explaination
of Scatternet
A Bluetooth network is called a piconet, or a small net. A piconet can have up to eight
with
stations, one of which is called the primary;t the rest are called secondaries. All the
diagram-2M
secondary stations synchronize their clocks and hopping sequence with the primary. Note
that a piconet can have only one primary station. The communication between the primary
and the secondary can be one-to-one or one-to-many. Figure shows a piconet.
Fig: Piconet
Scatternet:
Piconets can be combined to form what is called a scatternet. A secondary station in one
piconet can be the primary in another piconet. This station can receive messages from
the primary in the first piconet (as a secondary) and, acting as a primary, deliver them to
secondaries in the second piconet. A station can be a member of two piconets. Figure
illustrates a scatternet.
Page No: 7 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Fig: Scatternet
d) Draw a neat diagram of twisted pair cable and state its types. 4M
Ans A twisted pair consists of two conductors (normally copper), each with its own plastic Diagram with
insulation, twisted together, as shown in Figure. naming-2 m
Unshielded Twisted Pair (UTP): These generally comprise of wires and insulators.
Category 1 − UTP used in telephone lines with data rate < 0.1 Mbps
Category 2 − UTP used in transmission lines with a data rate of 2 Mbps
Category 3 − UTP used in LANs with a data rate of 10 Mbps
Category 4 − UTP used in Token Ring networks with a data rate of 20 Mbps
Category 5 − UTP used in LANs with a data rate of 100 Mbps
Category 6 − UTP used in LANs with a data rate of 200 Mbps
Category 7 − STP used in LANs with a data rate of 10 Mbps
Shielded Twisted Pair ( STP ): STP cable has a metal foil or braided mesh covering
Page No: 8 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
that encases each pair of insulated conductors.
2. Sender - It is the device which sends the data messages. It can be a computer,
workstation, telephone handset etc.
3. Receiver - It is the device which receives the data messages. It can be a computer,
workstation, telephone handset etc.
4. Transmission Medium - It is the physical path by which a message travels from sender
to receiver. Some examples include twisted-pair wire, coaxial cable, radio waves etc.
Page No: 9 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Example
If a block of 32 bits is to be transmitted, it is divided into matrix of four rows and eight
columns which as shown in the following figure:
Figure: LRC
In this matrix of bits, a parity bit (odd or even) is calculated for each column. It means 32
bits data plus 8 redundant bits are transmitted to receiver. Whenever data reaches at the
destination, receiver uses LRC to detect error in data.
Advantage:
LRC is used to detect burst errors.
c) Describe line of sight transmission. 4M
Page No: 10 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
the transmitting and receiving antennas must be within an effective line of sight of
each other.
The figure depicts this mode of propagation very clearly. The line-of-sight propagation will
not be smooth if there occurs any obstacle in its transmission path. As the signal can travel
only to lesser distances in this mode, this transmission is used for infrared or microwave
transmissions.
Speeds up to 2.4 kbps
Poor voice quality
Large phones with limited battery life
No data security
Used analog signals
2G-Second generation
2G refers to the second generation of mobile telephony which used digital signals for the
first time. It was launched in Finland in 1991 and used GSM technology.
2G networks used digital technology.
It implemented the concept of CDMA and GSM. Provided small data services like sms and
mms.
2G capabilities are achieved by allowing multiple users on a single channel via
multiplexing.
Page No: 11 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Features:
Page No: 12 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Features
It provides an all IP packet switched network for transmission of voice, data,
signals and multimedia.
It aims to provide high quality uninterrupted services to any location at any
time.
As laid down in IMT-Advanced specifications, 4G networks should have
peak data rates of 100Mbps for highly mobile stations like train, car etc., and
1Gbps for low mobility stations like residence etc.
It also lays down that 4G networks should make it possible for 1 Gbps
downlink over less than 67 MHz bandwidth.
They provide have smooth handoffs across heterogeneous network areas.
5G is the 5th generation mobile network. It is a new global wireless standard after
1G, 2G, 3G, and 4G networks. 5G enables a new kind of network that is designed to
connect virtually everyone and everything together including machines, objects, and
devices.
5G wireless technology is meant to deliver higher multi-Gbps peak data
speeds, ultra low latency, more reliability, massive network capacity, increased
availability, and a more uniform user experience to more users. Higher performance
and improved efficiency empower new user experiences and connects new
industries.
Features
High Speed, High Capacity 5G technology providing large broadcasting of data in
Gbps.
Multi - Media Newspapers, watch T. V pro clarity as to that of an HD Quality.
Faster data transmission that of the previous generations.
Large Phone Memory, Dialing Speed, clarity in Audio/Video.
Support interactive multimedia, voice, streaming video, Internet and other
5G is More Effective and More Attractive.
Ans In the question it is given that we are supposed to consider eight computers. Both For valid
architecture can be considered depending upon the requirement. for eight explanation
computers I would like to prefer Peer to Peer network architecture. 4M : either
peer to peer
Because
or client-
Page No: 13 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
The number of computers or devices in the network is less than 15. For peer to peer server
network less than 10 devices shows good performance.
Data security is not the top priority
Networking is mainly required for hardware sharing.
Advanced sharing is not required.
Additional networking features are not required.
The administrator personally knows all users of the network.
The above conditions are usually fulfilled in home and small office networks. Thus,
peer-to-peer networking is mostly used in home and small office networks.
Less costly
Also if security is in priority and cost is not the consideration then I would prefer client
server network it will provide a stable network.
Page No: 14 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
handling bilateral traffic. bilateral traffic.
In-Circuit switching, the charge depends on
time and distance, not on traffic in the In Packet switching, the charge is based on
network. the number of bytes and connection time.
Recording of packets is never possible in Recording of packets is possible in packet
circuit switching. switching.
In-Circuit Switching there is a physical In Packet Switching there is no physical
path between the source and the destination path between the source and the destination
Circuit Switching does not support store Packet Switching supports store and
and forward transmission forward transmission
No call setup is required in packet
Call setup is required in circuit switching. switching.
In-circuit switching each packet follows the In packet switching packets can follow any
same route. route.
The circuit switching network is Packet switching is implemented at the
implemented at the physical layer. datalink layer and network layer
Circuit switching requires simple protocols Packet switching requires complex
for delivery. protocols for delivery.
c) List the protocols related to all layers of OSI reference model 4M
Page No: 15 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 1. Satellite is a manmade system which is kept in continuous rotation around the earth 2M diagram
in a specific orbit at a specific height above the earth and with specific speed.
2M for
2. In satellite communication, signal transferring between the sender and receiver is
explanation
done with the help of satellite.
3. In this process, the signal which is basically a beam of modulated microwaves is
sent towards the satellite called UPLINK (6 GHz).
4. Then the satellite amplifies the signal and sent it back to the receiver’s antenna
present on the earth’s surface called as DOWNLINK (4Ghz), as shown in the
diagram given
5 . As the entire signal transferring is happening in space. Thus this type of communication
is known as space communication. The satellite does the functions of an antenna and the
Page No: 16 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
repeater together. If the earth along with its ground stations is revolving and the satellite is
stationery, the sending and receiving earth stations and the satellite can be out of sync over
time.
6. Therefore Geosynchronous satellites are used which move at same RPM as that of the
earth in the same direction.
7. So the relative position of the ground station with respect to the satellite never changes.
1. From the Control Panel, go to Administrative Tools >> Computer Management >>
Services and Application >> DHCP.
2. From the Action menu, select New Scope. The New Scope wizard is displayed.
7. Select BOOTP only, set the lease duration to Unlimited, and click OK.
10. Enter the IP address and the MAC address for Controller B. Click Add. The
controllers are added to the right of the Reservations listing.
Page No: 17 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
11. Right-click Scope [iPad dress] scope-name to disable the scope.
Working:
A hub has many ports in it. A computer which intends to be connected to the network is
plugged in to one of these ports. When a data frame arrives at a port, it is broadcast to every
other port, without considering whether it is destined for a particular destination device or
not.
Features of Hubs
A hub operates in the physical layer of the OSI model.
A hub cannot filter data. It is a non-intelligent network device that sends message to
all ports.
It primarily broadcasts messages. So, the collision domain of all nodes connected
through the hub stays one.
Transmission mode is half duplex.
Page No: 18 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
II. Switch:
Switches are networking devices operating at layer 2 or a data link layer of the OSI model.
They connect devices in a network and use packet switching to send, receive or forward
data packets or data frames over the network.
Working:
A switch has many ports, to which computers are plugged in. When a data frame arrives at
any port of a network switch, it examines the destination address, performs necessary
checks and sends the frame to the corresponding device(s). It supports unicast, multicast as
well as broadcast communications.
Page No: 19 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Features of Switches
It is an intelligent network device that can be conceived as a multiport network
bridge.
It uses MAC addresses (addresses of medium access control sublayer) to send data
packets to selected destination ports.
It uses packet switching technique to receive and forward data packets from the
source to the destination device.
It is supports unicast (one-to-one), multicast (one-to-many) and broadcast (one-to-
all) communications
III. Bridge:
Bridges are used to connect similar network segments.
It combines two LANs to form an extended LAN.
Working:
A bridge accepts all the packets and amplifies all of them to the other side. The bridges are
intelligent devices that allow the passing of only selective packets from them. A bridge only
passes those packets addressed from a node in one network to another node in the other
network.
Page No: 20 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Before beginning configuration procedure, the following are the prerequisites. Step by step
procedure -
Network hardware is installed and cabled. 6M
TCP/IP software is installed.
To configure your TCP/IP network, the following steps are followed:
Page No: 21 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
6) Decide which services each host machine on the network will use.
By default, all services are available. Follow the instructions in Client network
services if you wish to make a particular service unavailable.
7) Decide which hosts on the network will be servers, and which services a
particular server will provide. Follow the instructions in Server network
services to start the server daemons you wish to run.
Ans Multiplexing is the set of techniques that allows the simultaneous transmission of multiple 2 M for 3
signals across a single data link. multiplexing
technique
with diagram
Frequency-Division Multiplexing
Page No: 22 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
In above figure, the transmission path is divided into three parts, each representing a
channel that carries one transmission.
Wavelength-Division Multiplexing
WDM is conceptually the same as FDM, except that the multiplexing and de-multiplexing
involve optical signals transmitted through fiber-optic channels. The idea is the same: We
are combining different signals of different frequencies. The difference is that the
frequencies are very high.
Time-Division Multiplexing
Figure gives a conceptual view of TDM. Note that the same link is used as in FDM; here,
however, the link is shown sectioned by time rather than by frequency. In the figure,
portions of signals 1,2,3, and 4 occupy the link sequentially.
Page No: 23 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
We also need to remember that TDM is, in principle, a digital multiplexing technique.
Digital data from different sources are combined into one timeshared link. However, this
does not mean that the sources cannot produce analog data; analog data can be sampled,
changed to digital data, and then multiplexed by using TDM.
In this type of network topology, all the nodes of a network are connected to a common
transmission medium having two endpoints.
All the data that travels over the network is transmitted through a common transmission
medium known as the bus or the backbone of the network.
When the transmission medium has exactly two endpoints, the network topology is known
by the name, 'linear bus topology'. A network that uses a bus topology is referred to as a
“Bus Network”.
Fig.shows bus topology. The central cable is the backbone of the network and is known as
Bus (thus the name). Every workstation or node communicates with the other device
through this Bus.
A signal from the source is broadcasted and it travels to all workstations connected to bus
cable. Although the message is broadcasted but only the intended recipient, whose MAC
Page No: 24 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
address or IP address matches, accepts it.
If the MAC/IP address of machine does not match with the intended address, machine
discards the signal. A terminator is added at ends of the central cable, to prevent bouncing
of signals. A barrel connector can be used to extend it.
II.Ring Topology:
Ring topology is a network topology that is set-up in circular fashion. It is called ring
topology because it forms a ring as each computer is connected to another computer, with
the last one connected to the first. Exactly two neighbors for each device.
Each node in this topology contains repeater. A signal passes node to node, until it reaches
its destination. If a node receives a signal intended for another node its repeater regenerates
the signal and passes it.
Token is a special three-byte frame that travels around the ring network. It can flow
clockwise or anticlockwise. Ring topology is a point to point network.
In dual ring topology, two ring networks are formed, and data flow is in opposite direction
in them. Also, if one ring fails, the second ring can act as a backup, to keep the network up.
In a ring network, the data and the signals that pass over the network travel in a single
direction. In ring topology network arrangement, a signal is transferred sequentially using a
‘token’ from one node to the next.
Fig. shows a ring topology. The token travels along the ring until it reaches its destination.
Once, token reaches destination, receiving computer acknowledges receipt with a return
message to the sender. The sender then releases the token for the token for use by another
computer.
Page No: 25 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Tree Topology:
As its name implies in this topology devices make a tree structure. Tree topology integrates
the characteristics of star and bus topology.
• In tree topology, the number of star networks are connected using Bus. This main cable
seems like a main stem of a tree, and other star networks as the branches.
• It is also called expanded star topology. Ethernet protocol is commonly used in this type
of topology.
• Fig. shows tree topology. A tree topology can also combine characteristics of linear bus
and star topologies. It consists of groups of star configure workstations connected to a linear
bus backbone cable.
• Tree topologies allow for the expansion of an existing network and enable schools to
configure a network to meet their needs.
Page No: 26 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Layered Architecture of ISO-OSI Model: 1M for
Diagram and
1. The basic idea of a layered architecture is to divide the ISO-OSI model into small pieces. 5M for
Each layer adds to the services provided by the lower layers in such a manner that the explanation
highest layer is provided a full set of services to manage communications and run the
applications.
3. In an n-layer architecture, layer n on one machine carries on conversation with the layer n
on other machine. The rules and conventions used in this conversation are collectively
known as the layer-n protocol.
2. It is responsible for transmission and reception of the unstructured raw data over
network.
3. Voltages and data rates needed for transmission is defined in the physical layer.
Page No: 27 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Layer2: Data Link Layer
1. Data link layer synchronizes the information which is to be transmitted over the physical
layer.
2. The main function of this layer is to make sure data transfer is error free from one node to
another, over the physical layer.
4. This layer sends and expects acknowledgements for frames received and sent
respectively. Resending of no acknowledgement received frames is also handled by this
layer.
1. Network Layer routes the signal through different channels from one node to other.
4. It divides the outgoing messages into packets and assembles the incoming packets into
messages for higher levels.
1. Transport Layer decides if data transmission should be on parallel path or single path.
2. Functions such as Multiplexing, Segmenting or Splitting on the data are done by this
layer
3. It receives messages from the Session layer above it, converts the message into smaller
units and passes it on to the Network layer.
4. Transport layer can be very complex, depending upon the network requirements.
Transport layer breaks the message (data) into small units so that they are handled more
efficiently by the network layer.
1. Session Layer manages and synchronizes the conversation between two different
applications.
2. Transfer of data from source to destination session layer streams of data are marked and
are resynchronized properly, so that the ends of the messages are not cut prematurely and
data loss is avoided.
Page No: 28 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Layer 6: The Presentation Layer
1. Presentation Layer takes care that the data is sent in such a way that the receiver will
understand the information (data) and will be able to use the data.
2. While receiving the data, presentation layer transforms the data to be ready for the
application layer.
2. Transferring of files disturbing the results to the user is also done in this layer. Mail
services, directory services, network resource etc are services provided by application layer.
3. This layer mainly holds application programs to act upon the received and to be sent data.
ARP finds the hardware address, also known as Media Access Control (MAC) address, of
a host from its known IP address.
It is responsible to find the hardware address of a host from a know IP address there are
three basic ARP terms.
Page No: 29 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
The important terms associated with ARP are:
(i) Reverse ARP
(ii) Proxy ARP
(iii) Inverse ARP
Subnetting:
Dividing the network into smaller contiguous networks or subnets is called subnetting.
Suppose we take a network of class A. So, in class A, we have 2²⁴ hosts. So to manage
such a large number of hosts is tedious. So if we divide this large network into the smaller
network then maintaining each network would be easy.
So, in subnetting we will divide these 254 hosts logically into two networks. In the above
class C network, we have 24 bits for Network ID and the last 8 bits for the Host ID.
Supernetting:
For example:
Page No: 30 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Page No: 31 | 31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 2022 EXAMINATION
Subject Name: Java Programming Model Answer Subject Code: 22412
Ans 2M (1/2 M
Operator Meaning
each)
< Less than Any Four
> Greater than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= Not equal to
Ans The access specifiers in java specify accessibility (scope) of a data member, 2M (1/2 M
method, constructor or class. There are 5 types of java access specifier: each)
public Any Four
private
Page No: 1 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
default (Friendly)
protected
private protected
c) Explain constructor with suitable example. 2M
Ans Constructors are used to assign initial value to instance variable of the class. 1M-
It has the same name as class name in which it resides and it is syntactically similar Explanation
to anymethod. 1M-
Constructors do not have return value, not even ‘void’ because they return the instance if Example
class.
Constructor called by new operator.
Example:
class Rect
{
int length, breadth;
Rect() //constructor
{
length=4; breadth=5;
}
public static void main(String args[])
{
Rect r = new Rect();
System.out.println(“Area : ” +(r.length*r.breadth));
}
}
Output : Area : 20
d) List the types of inheritance which is supported by java. 2M
1 M each
Page No: 2 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 1. Thread is a smallest unit of executable code or a single task is also called as thread. 1 M-
2. Each tread has its own local variable, program counter and lifetime. Define
3. A thread is similar to program that has a single flow of control. Thread
There are two ways to create threads in java:
1M -2ways
1. By extending thread class to create
Syntax: - thread
class Mythread extends Thread
{
-----
}
2. Implementing the Runnable Interface
Syntax:
class MyThread implements Runnable
{
public void run()
{
------
}
f) Distinguish between Java applications and Java Applet (Any 2 points) 2M
Page No: 3 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 1 M for
each point
(any 2
Applet Application Points)
Applet does not use main() Application use main() method
method for initiating execution of for initiating execution of code
code
Applet cannot run independently Application can run
independently
Applet cannot read from or write Application can read from or
to files in local computer write to files in local computer
Applet cannot communicate with Application can communicate
other servers on network with other servers on network
Applet cannot run any program Application can run any program
from local computer. from local computer.
Applet are restricted from using Application are not restricted
libraries from other language from using libraries from other
such as C or C++ language
Applets are event driven. Applications are control driven.
Ans 2M-Correct
diagram
Page No: 4 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
2. Attempt any THREE of the following: 12 M
int i,m=0,flag=0;
m=n/2;
if(n==0||n==1){
}else{
for(i=2;i<=m;i++){
if(n%i==0){
flag=1;
break;
}//end of else
Output:
7 is prime number
Page No: 5 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
b) Define a class employee with data members 'empid , name and salary. 4M
Accept data for three objects and display it
Ans class employee 4M (for
{ correct
int empid; program
String name; and logic)
double salary;
void getdata()
{
BufferedReader obj = new BufferedReader (new InputStreamReader(System.in));
System.out.print("Enter Emp number : ");
empid=Integer.parseInt(obj.readLine());
System.out.print("Enter Emp Name : ");
name=obj.readLine();
System.out.print("Enter Emp Salary : ");
salary=Double.parseDouble(obj.readLine());
}
void show()
{
System.out.println("Emp ID : " + empid);
System.out.println(“Name : " + name);
System.out.println(“Salary : " + salary);
}
}
classEmpDetails
{
public static void main(String args[])
{
employee e[] = new employee[3];
for(inti=0; i<3; i++)
{
e[i] = new employee(); e[i].getdata();
}
System.out.println(" Employee Details are : ");
for(inti=0; i<3; i++)
e[i].show();
}
}
Page No: 6 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
c) Describe Life cycle of thread with suitable diagram. 4M
2) Runnable State
It means that thread is ready for execution and is waiting for the availability of the
processor i.e. the thread has joined the queue and is waiting for execution. If all
threads have equal priority, then they are given time slots for execution in round
robin fashion. The thread that relinquishes control joins the queue at the end and
again waits for its turn. A thread can relinquish the control to another before its turn
comes by yield().
Runnable runnable = new NewState();
Thread t = new Thread(runnable); t.start();
3) Running State
It means that the processor has given its time to the thread for execution. The thread
runs until it relinquishes control on its own or it is pre-empted by a higher priority
thread.
4) Blocked State
A thread can be temporarily suspended or blocked from entering into the runnable
and running state by using either of the following thread method.
Page No: 7 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Page No: 8 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
a) Write a program to find reverse of a number. 4M
while(number !=0)
number = number/10;
} }
Ans Final keyword : The keyword final has three uses. First, it can be used to create the Use of final
equivalent of a named constant.( in interface or class we use final as shared constant or keyword-2
constant.) M
Program-2
Other two uses of final apply to inheritance
M
Using final to Prevent Overriding While method overriding is one of Java’s most powerful
features,
To disallow a method from being overridden, specify final as a modifier at the start of its
declaration. Methods declared as final cannot be overridden.
The following fragment illustrates final:
class A
{
final void meth()
{
System.out.println("This is a final method.");
Page No: 9 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
}
class B extends A
{
void meth()
{ // ERROR! Can't override.
System.out.println("Illegal!");
}
}
As base class declared method as a final , derived class can not override the definition of
base class methods.
Page No: 10 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
(x1,y1) and (x2,y2) as arguments and draws a line between them.
The graphics object g is passed to paint() method.
Syntax: g.drawLine(x1,y1,x2,y2);
Example: g.drawLine(100,100,300,300;)
iv) drawArc ()
drawArc( ) It is used to draw arc.
Syntax: void drawArc(int x, int y, int w, int h, int start_angle, int sweep_angle);
where x, y starting point, w & h are width and height of arc, and start_angle is starting
angle of arc sweep_angle is degree around the arc
Ans One
public String getName() Returns the name of the file or directory denoted by this method
abstract pathname.
public String getParent() Returns the pathname string of this abstract pathname's 1M
parent, or null if this pathname does not name a parent
directory
public String getPath() Converts this abstract pathname into a pathname string.
public boolean isAbsolute() Tests whether this abstract pathname is absolute. Returns
true if this abstract pathname is absolute, false otherwise
public boolean exists() Tests whether the file or directory denoted by this abstract
pathname exists. Returns true if and only if the file or
directory denoted by this abstract pathname exists; false
otherwise
public boolean isDirectory() Tests whether the file denoted by this abstract pathname is
a directory. Returns true if and only if the file denoted by
this abstract pathname exists and is a directory; false
otherwise.
public boolean isFile() Tests whether the file denoted by this abstract pathname is
a normal file. A file is normal if it is not a directory and, in
addition, satisfies other system-dependent criteria. Any
nondirectory file created by a Java application is guaranteed
to be a normal file. Returns true if and only if the file
denoted by this abstract pathname exists and is a normal
file; false otherwise.
a) Write all primitive data types available in Java with their storage Sizes in 4M
Page No: 11 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
bytes.
Page No: 12 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
method to initialize and display the information for three objects.
Ans class Book Correct
{ program- 4
String author, title, publisher; M
Book(String a, String t, String p)
{
author = a;
title = t;
publisher = p;
}
}
class BookInfo extends Book
{
float price;
int stock_position;
BookInfo(String a, String t, String p, float amt, int s)
{
super(a, t, p);
price = amt;
stock_position = s;
}
void show()
{
System.out.println("Book Details:");
System.out.println("Title: " + title);
System.out.println("Author: " + author);
System.out.println("Publisher: " + publisher);
System.out.println("Price: " + price);
System.out.println("Stock Available: " + stock_position);
}
}
class Exp6_1
{
public static void main(String[] args)
{
BookInfo ob1 = new BookInfo("Herbert Schildt", "Complete Reference", "ABC
Publication", 359.50F,10);
BookInfo ob2 = new BookInfo("Ulman", "system programming", "XYZ Publication",
359.50F, 20);
BookInfo ob3 = new BookInfo("Pressman", "Software Engg", "Pearson Publication",
879.50F, 15);
ob1.show();
Page No: 13 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
ob2.show();
ob3.show();
}
}
OUTPUT
Book Details:
Title: Complete Reference
Author: Herbert Schildt
Publisher: ABC Publication
Price: 2359.5
Stock Available: 10
Book Details:
Title: system programming
Author: Ulman
Publisher: XYZ Publication
Price: 359.5
Stock Available: 20
Book Details:
Title: Software Engg
Author: Pressman
Publisher: Pearson Publication
Price: 879.5
Stock Available: 15
d) Mention the steps to add applet to HTML file. Give sample code. 4M
Page No: 14 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
“Hellojava.java”
import java.awt.*;
import java.applet.*;
public class Hellojava extends Applet
{
public void paint (Graphics g)
{
g.drawString("Hello Java",10,100);
}}
Use the java compiler to compile the applet “Hellojava.java” file.
C:\jdk> javac Hellojava.java
After compilation “Hellojava.class” file will be created. Executable applet is nothing but
the .class file
of the applet, which is obtained by compiling the source code of the applet. If any error
message is
received, then check the errors, correct them and compile the applet again.
We must have the following files in our current directory.
o Hellojava.java
o Hellojava.class
o HelloJava.html
If we use a java enabled web browser, we will be able to see the entire web page containing
the
applet.
We have included a pair of <APPLET..> and </APPLET> tags in the HTML body section.
The
<APPLET…> tag supplies the name of the applet to be loaded and tells the browser how
much space
the applet requires. The <APPLET> tag given below specifies the minimum requirements
to place the
HelloJava applet on a web page. The display area for the applet output as 300 pixels width
and 200
pixels height. CENTER tags are used to display area in the center of the screen.
<APPLET CODE = hellojava.class WIDTH = 400 HEIGHT = 200 > </APPLET>
Example: Adding applet to HTML file:
Create Hellojava.html file with following code:
<HTML>
<! This page includes welcome title in the title bar and displays a welcome message. Then
it specifies
the applet to be loaded and executed.
>
<HEAD> <TITLE> Welcome to Java Applet </TITLE> </HEAD>
<BODY> <CENTER> <H1> Welcome to the world of Applets </H1> </CENTER> <BR>
<CENTER>
Page No: 15 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<APPLET CODE=HelloJava.class WIDTH = 400 HEIGHT = 200 > </APPLET>
</CENTER>
</BODY>
</HTML>
e) Write a program to copy contents of one file to another. 4M
Ans
Page No: 16 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Sr. Array Vector
No.
4 Array can store primitive type data Vector are store non-primitive type data
element. element
8 Array allocates the memory for the Vector allocates the memory
fixed size ,in array there is wastage of dynamically means according to the
memory. requirement no wastage of memory.
9 No methods are provided for adding Vector provides methods for adding and
and removing elements. removing elements.
10 In array wrapper classes are not used. Wrapper classes are used in vector
elementAT( ):
The elementAt() method of Java Vector class is used to get the element at the specified
Page No: 17 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
index in the vector. Or The elementAt() method returns an element at the specified index.
addElement( ):
The addElement() method of Java Vector class is used to add the specified element to the
end of this vector. Adding an element increases the vector size by one.
b) Write a program to create a class 'salary with data members empid', ‘name' 6M
and ‘basicsalary'. Write an interface 'Allowance’ which stores rates of
calculation for da as 90% of basic salary, hra as 10% of basic salary and pf as
8.33% of basic salary. Include a method to calculate net salary and display it.
Ans interface allowance 6 M for
{ correct
double da=0.9*basicsalary; program
double hra=0.1*basicsalary;
double pf=0.0833*basicsalary;
void netSalary();
}
class Salary
{
int empid;
String name;
float basicsalary;
Salary(int i, String n, float b)
{
empid=I;
name=n;
basicsalary =b;
}
void display()
{
System.out.println("Empid of Emplyee="+empid);
System.out.println("Name of Employee="+name);
System.out.println("Basic Salary of Employee="+ basicsalary);
}
}
a) Write a program to check whether the string provided by the user is palindrome 6M
or not.
class palindrome
System.out.println("Enter String:");
String word=br.readLine( );
int l=0;
int flag=1;
int r=len;
while(l<=r)
Page No: 20 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
if(word.charAt(l)==word.charAt(r))
l++;
r--;
else
flag=0;
break;
if(flag==1)
System.out.println("palindrome");
else
System.out.println("not palindrome");
b) Define thread priority ? Write default priority values and the methods to set 6M
and change them.
Ans Thread Priority: 2 M for
define
In java each thread is assigned a priority which affects the order in which it is scheduled for Thread
running. Threads of same priority are given equal treatment by the java scheduler. priority
Default priority values as follows 2 M for
Page No: 21 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
The thread class defines several priority constants as: - default
priority
MIN_PRIORITY =1 values
NORM_PRIORITY = 5
MAX_PRIORITY = 10
2 M for
Thread priorities can take value from 1-10. method to
set and
getPriority(): The java.lang.Thread.getPriority() method returns the priority of the given change
thread.
import java.lang.*;
add(tf1);
add(tf2);
add(tf3);
add(b1);
add(b2);
add(b3);
add(b4);
Page No: 23 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
setSize(400,400);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String s1 = tf1.getText();
String s2 = tf2.getText();
int a = Integer.parseInt(s1);
int b = Integer.parseInt(s2);
int c = 0;
if (e.getSource() == b1){
c = a + b;
}
else if (e.getSource() == b2){
c = a - b;
else if (e.getSource() == b3){
c = a * b;
else if (e.getSource() == b4){
c = a / b;
}
String result = String.valueOf(c);
tf3.setText(result);
}
public static void main(String[] args) {
new sample();
}
}
Page No: 24 | 24