Professional Documents
Culture Documents
Networks Multiple Choice Questions
Networks Multiple Choice Questions
“DHCP”.
Answer: a
Explanation: We use DHCP to allow the hosts to acquire their ip addresses dynamically which is
better than visiting each and every host on the network and configure all of this information
manually.
Answer: c
Explanation: DHCP is used for both IPv4 and IPv6 addressing. With DHCP you get to let the
hosts know about the change dynamically, and hosts update their info themselves.
Answer: d
Explanation: Whenever a DHCP server gets a request from a client it responds with a DHCP
offer containing IP address being offered, network mask offered, the amount of time that the
client can use and keep it, the ip address of the DHCP server making this offer.
5. DHCP uses UDP port _________ for sending data to the server.
a) 66
b) 67
c) 68
d) 69
View Answer
Answer: b
Explanation: 67 is the UDP port number that is used as the destination port of a server. Whereas
UDP port number 68 is used by the client.
Answer: d
Explanation: When a host acquires multiple offers of IP addresses from different DHCP servers,
the host will broadcast a dhcp request identifying the server whose offer has been accepted.
7. DHCP client and servers on the same subnet communicate via _________
a) UDP broadcast
b) UDP unicast
c) TCP broadcast
d) TCP unicast
View Answer
Answer: a
Explanation: DHCP actually employs a connectionless service, which is provided by UDP, since
TCP is connection oriented. It is implemented with two UDP port numbers 67 and 68 for its
operations.
8. After obtaining the IP address, to prevent the IP conflict the client may use _________
a) internet relay chat
b) broader gateway protocol
c) address resolution protocol
d) none of the mentioned
View Answer
Answer: c
Explanation: ARP abbreviation for address resolution protocol is used for mapping IP addresses
to MAC addresses that are present in the local network.
Answer: a
Explanation: DHCP snooping is a security feature that is used in OS of a network in the layer 2.
This technology prevents unauthorized DHCP servers offering IP addresses to DHCP clients.
10. If DHCP snooping is configured on a LAN switch, then clients having specific ______ can
access the network.
a) MAC address
b) IP address
c) Both MAC address and IP address
d) None of the mentioned
View Answer
Answer: c
Explanation: The DHCP snooping is done to prevent unauthorized IP addresses being offered by
unauthorized servers. This features allows only specific mac addresses and IP addresses to access
the network.
Questions
1 The entire hostname has a maximum of ___________
A 31 characters
B 255 characters
C 127 characters
D None of the above
Answer: 255 characters
2 Which one of the following allows client to update their DNS entry as their IP address change?
A dynamic DNS
B authoritative name server
C mail transfer agent
D None of the above
Answer: dynamic DNS
3 The right to use a domain name is delegated by domain name registers which are accredited by
_______
A internet research task force
B internet corporation for assigned names and numbers
C internet architecture board
D internet society
Answer: internet corporation for assigned names and numbers
4 The Domain Name System support in Microsoft Windows NT, and thus its derivatives
________, Windows XP, and Windows Server 2003, comprises two clients and a server.
A Windows 2000
B Windows Server 2008
C Internet Explorer
D Windows Vista
Ans window2000
5 Microsoft DNS is the name given to the implementation of domain name system services
provided in ________ operating systems.
A Microsoft Windows
B Internet Explorer
C Internet Information Services
D DirectX
Answer: Microsoft Windows
6 Prior to ________ and Microsoft Windows 2000 Service Pack 3, the most common problem
encountered with Microsoft’s DNS server was cache pollution.
A Windows XP
B Windows Server 2008
C Windows Server 2003
D Windows Vista
Answer: Windows Server 2003
7 What is an alias record used for?
A creating an alternate record or alias for an existing record
B a routable internal address (similar to the 192.168 address space)
C in an unsecured location facing the internet
D when you have a large number of single-name clients to support
Answer: creating an alternate record o
8 What are the 3 types of IPv6 addresses?
A link-local, site-local, and global unicast
B dynamic, read-write, and read-only
C in the Start of Authority (SOA) record
D older applications that are unable to use FQDN’s
Answer: link-local, site-local, and global unicast
9 What are the 3 strategies for updating DNS servers?
A dynamic, read-write, and read-only
B the Mail exchanger (MX) record
C a unique, internet-usable IP address
D in a highly-secure environment
Answer: dynamic, read-write, and read-only
10 How are the bits in an IPv6 address organized?
A into 8 16-bit groups
B reverse lookup
C canonical name (CNAME)
D name records
Answer: into 8 16-bit groups
2 What is used to control DNS data replication scope?
A the Mail exchanger (MX) record
B in the Start of Authority (SOA) record
C application directory partitions
D in a highly-secure environment
Answer: application directory partitions
13 How can PNRP names be protected from spoofing or poisoning?
A with digital signatures
B in a highly-secure environment
C in perimeter networks
D Pointer (PTR) records
Answer: with digital signatures
14 What is the most common record type in DNS?
A dnscmd.exe
B Host (A) records
C name records
D None of the above
Answer: Host (A) records
15 In what format are IPv6 addresses usually displayed?
A in hexidecimal format
B the Mail exchanger (MX) record
C canonical name (CNAME)
D Host (A) records
Answer: in hexidecimal format
16 For what purpose is the BIND root cache file used?
A To prime the name server with the root server’s addresses
B To serve as a configuration file for the name server
C To serve as a zone file for the loopback address
D To provide zone files for authoritative servers
Answer: To prime the name server with the root server’s addresses
17 What is the function of the directory directive in the name server configuration file?
A To establish an initial path for later file references
B To declare the server as a secondary server for a zone
C To declare the server as an authoritative server for a zone
D To establish the origin domain and name of the root cache file
Answer: To establish an initial path for later file references
18 What is the basic function of the nslookup program?
A To look up only SOA records from a company’s database
B To look up only IP addresses in the DNS database
C To look up only domain names in the DNS database
D To probe the DNS database for various types of information
Answer: To probe the DNS database for various types of information
19 What file does the nslookup program use to locate a name server?
A The /etc/resolv.conf file
B The /etc/hosts file
C The /etc/named.boot file
D The /var/log/messages file
Answer: The /etc/resolv.conf file
20 Besides the name server process, what are the other parts of the BIND package?
A The /etc/resolv.conf file
B The name server data files
C The /etc/named.boot file
D The /etc/hosts file
Answer: The name server data files
a)
b)
c)
d) All of the mentioned
View Answer
Answer: a
Explanation: You can define the features in software and hardware that enables flexibility as
conforming to one or more of the mobility patterns.
2. Point out the wrong statement.
a) Abstraction enables the key benefit of cloud computing: shared, ubiquitous access
b) Virtualization assigns a logical name for a physical resource and then provides a pointer to
that physical resource when a request is made
c) All cloud computing applications combine their resources into pools that can be assigned on
demand to users
d) All of the mentioned
View Answer
Answer: c
Explanation: Several important cloud computing approaches use a strictly hardware-based
approach to abstraction.
Answer: d
Explanation: To enable these characteristics, resources must be highly configurable and flexible.
Answer: c
Explanation: Load balancing is an optimization technique.
Answer: d
Explanation: Alternatively, systems can be virtualized through load-balancing technologies.
6. Which of the following software can be used to implement load balancing?
a) Apache mod_balancer
b) Apache mod_proxy_balancer
c) F6’s BigIP
d) All of the mentioned
View Answer
Answer: b
Explanation: Load balancing can be used to increase utilization and throughput, lower latency,
reduce response time, and avoid system overload.
Answer: d
Explanation: Load balancing provides the necessary redundancy to make an intrinsically
unreliable system reliable through managed redirection.
Answer: a
Explanation: They determine the current utilization of the resources in their pool.
9. A ______ is a combination load balancer and application server that is a server placed
between a firewall or router.
a) ABC
b) ACD
c) ADC
d) All of the mentioned
View Answer
Answer: c
Explanation: An Application Delivery Controller is assigned a virtual IP address (VIP) that maps
to a pool of servers based on application specific criteria.
10. Which of the following should be replaced with the question mark in the following figure?
a) Abstraction
b) Virtualization
c) Mobility Pattern
d) All of the mentioned
View Answer
Answer: b
Explanation: Virtualization is a key enabler of the first four of five key attributes of cloud
computing.
2.
What are two valid iSCSI discovery methods?
A)
Static Discovery
B)
Dynamic Discovery
C)
Automatic Discovery
D)
Both (A) and (B)
3.
A vSphere Administrator wants to migrate a virtual machine from a host with an AMD Opteron
CPU to an intel Xeon CPU. Which method should be used?
A)
vMotion
B)
Cold Migration
C)
Hot Migration
D)
Storage vMotion
5.
Where can you check the configuration of a vSphere Distributed Switch using the vSphere
client?
A)
From the main network view
B)
From the datastores view
C)
From the hosts configuration section
D)
From the VMs and templates view
6.
What is the maximum supporter number of vCPU per VM in VMware vSphere 6.5?
A)
32
B)
64
C)
128
D)
256
7.
Which two network failure detection options are available when using a vSphere Standard
Switch?
A)
Fixed with preferred path
B)
Link status with Beacon probing
C)
Link status only
D)
Both (B) and (C)
8.
Which type of user account is added to an ESX host when that host is joined to a vCenter server?
A)
vpxuser
B)
VPD admin
C)
vCenter admin
D)
local administrator
9.
What is the maximum number of hosts per vNetwork Distributed Switch?
A)
8
B)
16
C)
32
D)
64
10 .
Which problem is MOST likely to be due to bad physical memory?
A)
slow performance
B)
VMkernel panics
C)
virtual machines not starting
D)
Errors on virtual machines' virtual SCSI buses
Answer: c) RemoteFX
Explanation: RemoteFX is a feature of Remote Desktop Services, not Windows Server 2012.
2. What is the minimum number of processors required for Windows Server 2012
Standard Edition?
a) 1
b) 2
c) 4
d) 8
Answer: a) 1
Explanation: Windows Server 2012 Standard Edition can be installed on a single processor
system.
3. Which of the following is a new feature in Windows Server 2012 that allows virtualized
workloads to be moved between different hosts with no downtime?
a) Storage Spaces
b) Dynamic Memory
c) Live Migration
d) RemoteFX
Explanation: Live Migration is a new feature in Windows Server 2012 that allows virtualized
workloads to be moved between different hosts with no downtime.
4. Which of the following editions of Windows Server 2012 supports up to 640 logical
processors?
a) Standard Edition
b) Datacenter Edition
c) Essentials Edition
d) Foundation Edition
6. Which of the following is a new feature in Windows Server 2012 that allows
administrators to create virtualized network infrastructures?
a) Hyper-V
b) RemoteFX
c) Virtual Network
d) DirectAccess
Explanation: Virtual Network is a new feature in Windows Server 2012 that allows
administrators to create virtualized network infrastructures.
7. What is the minimum amount of RAM required to install Windows Server 2012?
a) 512 MB
b) 1 GB
c) 2 GB
d) 4 GB
Answer: b) 1 GB
Explanation: The minimum amount of RAM required to install Windows Server 2012 is 1 GB.
8. Which of the following is a new feature in Windows Server 2012 that allows
administrators to set up virtualized desktop infrastructures?
a) Hyper-V
b) RemoteFX
c) Virtual Desktop Infrastructure
d) DirectAccess
10. Which of the following is a new feature in Windows Server 2012 that allows
administrators to manage storage devices and pools of storage?
a) Storage Space
b) Dynamic Memory
c) Live Migration
d) RemoteFX
Explanation: Storage Spaces is a new feature in Windows Server 2012 that allows
administrators to manage storage devices and pools of storage.
11. Which of the following is NOT a type of installation available in Windows Server 2012?
Explanation: Custom Installation is not a type of installation available in Windows Server 2012.
12. Which of the following is a new feature in Windows Server 2012 that allows
administrators to manage and control access to data stored on file servers?
a) Access-Based Enumeration
b) Distributed File System
c) Data Deduplication
d) BranchCache
Answer: a) Access-Based Enumeration
Explanation: Access-Based Enumeration is a new feature in Windows Server 2012 that allows
administrators to manage and control access to data stored on file servers.
13. Which of the following editions of Windows Server 2012 is designed for small
businesses with up to 25 users?
a) Standard Edition
b) Datacenter Edition
c) Essentials Edition
d) Foundation Edition
Explanation: Essentials Edition of Windows Server 2012 is designed for small businesses with
up to 25 users.
14. Which of the following is a new feature in Windows Server 2012 that allows
administrators to manage multiple servers from a single console?
a) Server Manager
b) Remote Desktop Services
c) Hyper-V
d) Windows PowerShell
Explanation: Server Manager is a new feature in Windows Server 2012 that allows
administrators to manage multiple servers from a single console.
15. Which of the following is NOT a file system supported by Windows Server 2012?
a) NTFS
b) FAT32
c) ReFS
d) FAT16
Answer: d) FAT16
16. Which of the following is a new feature in Windows Server 2012 that allows
administrators to manage and monitor virtual machines?
a) Hyper-V
b) RemoteFX
c) Virtual Machine Manager
d) Remote Desktop Services
Explanation: Virtual Machine Manager is a new feature in Windows Server 2012 that allows
administrators to manage and monitor virtual machines.
17. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure networking on servers and workstations?
Answer: b) DirectAccess
Explanation: DirectAccess is a new feature in Windows Server 2012 that provides a way to
manage and configure networking on servers and workstations.
18. Which of the following is NOT a benefit of using virtualization in Windows Server
2012?
Explanation: Virtualization can actually result in slower application performance due to the
overhead of running multiple virtual machines on a single physical machine.
19. Which of the following is a new feature in Windows Server 2012 that allows
administrators to manage and monitor network traffic?
20. Which of the following editions of Windows Server 2012 supports up to 64 processors?
a) Standard Edition
b) Datacenter Edition
c) Essentials Edition
d) Foundation Edition
21. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and deploy virtual machines?
Explanation: Virtual Machine Manager is a new feature in Windows Server 2012 that provides
a way to manage and deploy virtual machines.
22. Which of the following is a new feature in Windows Server 2012 that allows
administrators to monitor and manage storage resources?
a) Data Deduplication
b) Storage Spaces
c) BranchCache
d) File Server Resource Manager
Explanation: Storage Spaces is a new feature in Windows Server 2012 that allows
administrators to monitor and manage storage resources.
23. Which of the following is a new feature in Windows Server 2012 that provides a way to
access corporate resources securely from remote locations?
a) DirectAccess
b) Remote Desktop Services
c) Hyper-V Replica
d) BranchCache
Answer: a) DirectAccess
Explanation: DirectAccess is a new feature in Windows Server 2012 that provides a way to
access corporate resources securely from remote locations.
24. Which of the following editions of Windows Server 2012 is designed for large
organizations and supports unlimited virtual instances?
a) Standard Edition
b) Datacenter Edition
c) Essentials Edition
d) Foundation Edition
Explanation: Datacenter Edition of Windows Server 2012 is designed for large organizations
and supports unlimited virtual instances.
25. Which of the following is a new feature in Windows Server 2012 that allows
administrators to manage and configure storage resources?
a) Storage Spaces
b) Data Deduplication
c) BranchCache
d) Network Controller
Explanation: Storage Spaces is a new feature in Windows Server 2012 that allows
administrators to manage and configure storage resources.
26. Which of the following is a new feature in Windows Server 2012 that provides a way to
replicate virtual machines to a secondary location?
a) DirectAccess
b) RemoteFX
c) Hyper-V Replica
d) Remote Desktop Services
Explanation: Hyper-V Replica is a new feature in Windows Server 2012 that provides a way to
replicate virtual machines to a secondary location.
27. Which of the following is a new feature in Windows Server 2012 that provides a way to
monitor and manage virtual machines?
a) Server Manager
b) Remote Desktop Services
c) Hyper-V Manager
d) Windows PowerShell
Explanation: Hyper-V Manager is a new feature in Windows Server 2012 that provides a way
to monitor and manage virtual machines.
28. Which of the following is a new feature in Windows Server 2012 that provides a way to
optimize branch office connectivity?
a) DirectAccess
b) Remote Desktop Services
c) BranchCache
d) Network Controller
Answer: c) BranchCache
Explanation: BranchCache is a new feature in Windows Server 2012 that provides a way to
optimize branch office connectivity.
29. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and control network traffic?
Explanation: Network Controller is a new feature in Windows Server 2012 that provides a way
to manage and control network traffic.
30. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure file services?
Explanation: File Server Resource Manager is a new feature in Windows Server 2012 that
provides a way to manage and configure file services.
31. Which of the following is a new feature in Windows Server 2012 that provides a way to
optimize WAN connectivity?
a) DirectAccess
b) BranchCache
c) Network Controller
d) Remote Desktop Services
Answer: b) BranchCache
Explanation: BranchCache is a new feature in Windows Server 2012 that provides a way to
optimize WAN connectivity.
32. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure Active Directory?
Explanation: Active Directory Administrative Center is a new feature in Windows Server 2012
that provides a way to manage and configure Active Directory.
33. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure DNS?
a) DNS Server
b) DNS Client
c) DNS Manager
d) DNS Resolver
Explanation: DNS Manager is a new feature in Windows Server 2012 that provides a way to
manage and configure DNS.
34. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure DHCP?
a) DHCP Server
b) DHCP Client
c) DHCP Manager
d) DHCP Resolver
Explanation: DHCP Manager is a new feature in Windows Server 2012 that provides a way to
manage and configure DHCP.
35. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure Group Policy?
Explanation: Group Policy Preferences is a new feature in Windows Server 2012 that provides a
way to manage and configure Group Policy.
36. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure remote access?
Answer: b) DirectAccess
Explanation: DirectAccess is a new feature in Windows Server 2012 that provides a way to
manage and configure remote access.
37. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure certificates?
a) Certificate Services
b) Certificate Manager
c) Certificate Authority
d) Certificate Enrollment Policy
38. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure file and storage services?
Explanation: Storage Spaces is a new feature in Windows Server 2012 that provides a way to
manage and configure file and storage services.
39. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure security settings?
Explanation: Security Configuration Wizard is a new feature in Windows Server 2012 that
provides a way to manage and configure security settings
40. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure remote desktops?
a) RemoteFX
b) Remote Desktop Services
c) Remote Desktop Connection
d) Remote Desktop Gateway
Explanation: Remote Desktop Services is a new feature in Windows Server 2012 that provides
a way to manage and configure remote desktops.
41. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure virtualization?
a) Hyper-V Manager
b) Hyper-V Replica
c) Virtual Machine Manager
d) Virtual Network Manager
Explanation: Virtual Machine Manager is a new feature in Windows Server 2012 that provides
a way to manage and configure virtualization.
42. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure network settings?
Explanation: Network Controller is a new feature in Windows Server 2012 that provides a way
to manage and configure network settings.
43. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure web applications?
Explanation: Web Application Proxy is a new feature in Windows Server 2012 that provides a
way to manage and configure web applications.
44. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure backup and recovery?
45. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure print services?
a) Print Management
b) Printer Driver Isolation
c) Print Server
d) Print Queue Management
Explanation: Print Management is a new feature in Windows Server 2012 that provides a way
to manage and configure print services.
46. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure application servers?
Explanation: Application Server is a new feature in Windows Server 2012 that provides a way
to manage and configure application servers.
47. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure identity and access?
48. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure remote management?
a) Remote Server Administration Tools
b) Windows PowerShell
c) Server Manager
d) WinRM
Answer: d) WinRM
Explanation: WinRM is a new feature in Windows Server 2012 that provides a way to manage
and configure remote management.
49. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure storage?
a) Storage Spaces
b) Disk Management
c) Storage Management
d) Storage Replication
Explanation: Storage Spaces is a new feature in Windows Server 2012 that provides a way to
manage and configure storage.
50. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure server roles and features?
a) Server Manager
b) Windows PowerShell
c) Server Configuration Tool
d) Remote Server Administration Tools
Explanation: Server Manager is a new feature in Windows Server 2012 that provides a way to
manage and configure server roles and features.
51. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure file sharing?
52. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure failover clustering?
Explanation: Cluster-Aware Updating (CAU) is a new feature in Windows Server 2012 that
provides a way to manage and configure failover clustering.
53. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure monitoring and event logging?
a) Event Viewer
b) Performance Monitor
c) Windows PowerShell
d) Windows Management Instrumentation (WMI)
Explanation: Performance Monitor is a new feature in Windows Server 2012 that provides a
way to manage and configure monitoring and event logging.
54. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure security?
Explanation: Windows Firewall with Advanced Security is a new feature in Windows Server
2012 that provides a way to manage and configure security.
55. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure network infrastructure?
a) Network Policy and Access Services
b) DNS Server
c) DHCP Server
d) IP Address Management (IPAM)
Explanation: IP Address Management (IPAM) is a new feature in Windows Server 2012 that
provides a way to manage and configure network infrastructure.
56. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure remote desktop services?
Explanation: Remote Desktop Connection Broker is a new feature in Windows Server 2012 that
provides a way to manage and configure remote desktop services.
57. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure web services?
Explanation: Internet Information Services (IIS) is a new feature in Windows Server 2012 that
provides a way to manage and configure web services.
58. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure certificate services?
59. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure data deduplication?
Explanation: Data Deduplication is a new feature in Windows Server 2012 that provides a way
to manage and configure data deduplication.
60. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure remote access to virtual machines?
a) Hyper-V Replica
b) RemoteFX
c) Remote Desktop Gateway
d) Virtual Machine Connection
Explanation: Hyper-V Replica is a new feature in Windows Server 2012 that provides a way to
manage and configure remote access to virtual machines.
61. Which of the following is a new feature in Windows Server 2012 that provides a way to
manage and configure Windows updates?
a) Windows Update
b) Windows Server Update Services (WSUS)
c) System Center Configuration Manager
d) Group Policy Management
Explanation: Windows Server Update Services (WSUS) is a new feature in Windows Server
2012 that provides a way to manage and configure Windows updates.
Java
Which of this keyword must be used to inherit a class?
a) super
b) this
c) extent
d) extends
View Answer
Answer: d
Explanation: None.
Answer: b
Explanation: A class member declared protected becomes a private member of subclass.
Answer: c
1. class A
2. {
3. int i;
4. void display()
5. {
6. System.out.println(i);
7. }
8. }
9. class B extends A
10. {
11. int j;
12. void display()
13. {
14. System.out.println(j);
15. }
16. }
17. class inheritance_demo
18. {
19. public static void main(String args[])
20. {
21. B obj = new B();
22. obj.i=1;
23. obj.j=2;
24. obj.display();
25. }
26. }
a) 0
b) 1
c) 2
d) Compilation Error
View Answer
Answer: c
Explanation: Class A & class B both contain display() method, class B inherits class A, when
display() method is called by object of class B, display() method of class B is executed rather
than that of Class A.
output:
$ javac inheritance_demo.java
$ java inheritance_demo
2
1. class A
2. {
3. int i;
4. }
5. class B extends A
6. {
7. int j;
8. void display()
9. {
10. super.i = j + 1;
11. System.out.println(j + " " + i);
12. }
13. }
14. class inheritance
15. {
16. public static void main(String args[])
17. {
18. B obj = new B();
19. obj.i=1;
20. obj.j=2;
21. obj.display();
22. }
23. }
a) 2 2
b) 3 3
c) 2 3
d) 3 2
View Answer
Answer: c
Explanation: None
output:
$ javac inheritance.java
$ java inheritance
2 3
1. class A
2. {
3. public int i;
4. public int j;
5. A()
6. {
7. i = 1;
8. j = 2;
9. }
10. }
11. class B extends A
12. {
13. int a;
14. B()
15. {
16. super();
17. }
18. }
19. class super_use
20. {
21. public static void main(String args[])
22. {
23. B obj = new B();
24. System.out.println(obj.i + " " + obj.j)
25. }
26. }
a) 1 2
b) 2 1
c) Runtime Error
d) Compilation Error
View Answer
Answer: a
Explanation: Keyword super is used to call constructor of class A by constructor of class B.
Constructor of a initializes i & j to 1 & 2 respectively.
output:
$ javac super_use.java
$ java super_use
1 2