91% found this document useful (11 votes)
32K views152 pages

Quiz

The document discusses various object-oriented programming and unified modeling language (UML) concepts. 1. Tom is advised to use an object-oriented approach and language for a new project because it allows for modularity, data abstraction, and software reusability. 2. The scenario describes an automated banking system where customers can perform functions like fund transfers and view profiles online. 3. The scenario identifies potential classes as Employee, Allen software company, projects (STPS, LMS), and relationships between employees and projects. [END SUMMARY]
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
91% found this document useful (11 votes)
32K views152 pages

Quiz

The document discusses various object-oriented programming and unified modeling language (UML) concepts. 1. Tom is advised to use an object-oriented approach and language for a new project because it allows for modularity, data abstraction, and software reusability. 2. The scenario describes an automated banking system where customers can perform functions like fund transfers and view profiles online. 3. The scenario identifies potential classes as Employee, Allen software company, projects (STPS, LMS), and relationships between employees and projects. [END SUMMARY]
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 152

OOP & UML

1. In which approach, software enhancement is easier?


Object Oriented
2. Tom is the developer of Allen Software Company. He gets the requirement for which he needs to provide
solution. His friend advised him to understand Object oriented concepts and choose a language that support
Object oriented concept for implementation. What factors does his friend would have thought in mind that
made him advise Tom to opt for a language that supports Object oriented concepts and principles
Modularity is achieved
Data Abstraction is possible
Software Re-usability is more
3. ABC bank wants to automate its banking operations. Customers can register with the bank to perform the
banking operations like online fund transfer, pay creditbill, view profile. From the above scenario identify the
possible functions.
Online fund transfer, pay creditbill, view profile
4. Consider the following scenario and identify all the possible classes and objects.
"John and Sam are the employees of Allen software company. SPTS, LMS are the projects that are to be moved
to the production environment. Every employee has empid, designation, allocation status and project has
projectid, startDate, endDate, projcost".
John, Sam, Allen software company, STPS, LMS, Employee, Project
5. Procedure Oriented Programming focus more on functions than the data.
True
6. Wall and Building has a "is a part of" relationship. When the Building is destroyed, Wall also ceases to exist.
The relationship between Building and Wall is
Composition
7. Match the following
Super class Generalized class
Late binding Overriding
Early binding Overloading
Sub class Specialized class
8. Match the following
Binding data and methods Encapsulation
Private and Public Access specifiers
Exposing relevant information Abstraction
Creating objects for the class Constructor
9. ABC university came up with the requirement. They wanted to enhance their website by adding a feature of
knowing the count of the new candidates who register in their website. Which OO concept can be used to
implement this task?
Static
10. With respect to the problem domain taking the relevant information and ignoring the remaining information is
called ________.
Abstraction
11. PermanentEmployee is an Employee. What is the relationship between these classes?
Generalization
12. Data Persistence can be achieved using a data base system.
True
13. _________ behaves like a folder.
Package
14. Which UML model depicts the interactions between the objects by passing a series of messages
sequence diagram
15. There are two use cases, viewemployeeid and validateemployeeid. What is the relationship between these two
cases.
include
16. Which of the following are true about the class diagram?
depicts the relationship between the classes
17. Which of the multiplicity indicator is used to denote the optional association?
0..1
18. Who is an actor
An actor can be a human, device or an external system
19. Notation in sequence diagram which is used to represent the period of time the object is active
Focus of control
20. In statechart diagram the objects state is changed because of
event
21. Fork is used for representing
Concurrent flow
22. Activity diagram does not contain
Attributes
23. Activity diagram
Represents the flow of control from activity to activity
24. Sequence diagram is intended
To represent the temporal aspects of the system
25. A software objects behaviour is exposed through ____________.
methods
26. Smith behaves differently depending on the situations. At school he is a student, at home he is a son, in school
bus he is a passenger and at super market he is a customer. What OO concept does Smith exhibit?
Polymorphism
27. Camera has the feature called takePhoto. Mobile has implemented camera and has given its own definition for
takePhoto. Laptop has also implemented Camera and has given its own implementation of Camera. What is the
Object Oriented concept between Camera and Mobile and Camera and Laptop?
Interface
28. What is the relationship between Book and Index of the book?
Composition
29. Which of the following are true about the class diagram?
depicts the relationship between the classes
30. Identify the actors from the given scenario for completing the usecase
Actor 1 [Manager]
Actor 2 [Customer Care Rep]
31. Identify, whether there is a relation between bill generation and cancel/postpone if present what type of
relation from the given scenario
Fill the relation [include]
32. Select the correct class diagram for the given scenario
Employee can work for a project and project can be allocated to many employees. A fresher will undergo a
training process and he/she will not be allocated to any project during the training phase. Every employee is
allotted with a department at the time of joining

33. Match Class Relationship and its notation


Generalization

Association

Aggregation

Composition

34. A company wants to maintain their employees information along with their payroll details. Employees can be
PermanentEmployee or ContractEmployee. The departments in the company are also maintained. The salary for
the employee is calculated using a helper class.
From the given scenario, the classes identified are
• Employee
• PermanentEmployee
• ContractEmployee
• Department
• PayrollCalculator
Identify the relation between the
• Employee and Department
• Employee and PermanentEmployee
• Employee and PayrollCalculator
Employee and PermanentEmployee Inheritance
Employee and Department Association
Employee and PayrollCalculator Dependency
35. Match the right methods for the numbers specified in the sequence diagram. Use the class diagram given below
to complete the task.

1 → validCustomerDetails(custDetails)
2 → initiateCustomer(custDetails)
3 → registerCustomerDetails(custDetails)
4 → generateCustomerID()
5 → create
6 → addCustomertoDB(customer)
7 → Customer
8 → displayCustomerDetails(Customer)
36. Activity diagram does not contain _______.
attributes
37. In Activity diagram, Fork is used to represent ________.
Concurrent flow
38. Who is an actor?
An actor is a user, who interacts with the system.
39. What is the type of relation between Cycle and Bi-cycle?
Generalization
40. Which UML model depicts the interactions between the objects by passing series of messages?
sequence diagram
41. In statechart diagram, the objects state is changed because of _________.
event
42. Activity diagram:
represents the flow of control from activity to activity.
43. Which notation in sequence diagram is used to represent the period of time the object is active?
Focus of control
44. Identify the missing usecase that is part of bill calculation from the scenario
Discount Calculation
45. Identify, whether there is a relation between bill generation and cancel/postpone if present what type of
relation from the given scenario
include
46. Is the given usecase diagram correct for the given scenario

False
47. In a library there are many books and members register themselves with their name, age, address and if staff
with staffid, department or if student then regno, year. Registered members can borrow the book. The details of
the books been borrowed by the members are also maintained. Every time a member borrows a book the return
date is calculated. If the date of return by the member is beyond the return date, then a penalty is calculated.
The difference in date and the return date are calculated using a helper class methods
For the given scenario identify the classes.
Member, Staff, Student, Book, Transaction, DateCalculator
48. Complete the sequence diagram.
Classes present
Software Engineering Fundamentals
Software Engineering Fundamentals
1. Transition from what phase to how is implemented in ---------- phase of SDLC
Design
2. ________ deals with transforming the customer requirements, into a set of documents that is suitable for
implementation in a programming language.
System design
3. The goal of system analyst is to determine where the problem is, in an attempt to fix the system.
True
4. Unit testing is performed by ………..
Developer
5. Allen company got a project to be done from scratch. They decided to follow the below steps analysis design
coding testing. This constitutes ….
SDLC
6. The student mark processing system software has been developed and deployed at the StPeter's University. The
system shows the grade as 0 for all the students rather than the actual grade. Which below phase was not done
properly during SDLC
Software testing
7. The software is put into operation in the clients environment. Client comes back to enhance the UI to attract
more customers. This is ------------- project
Maintenance
8. ------------- does not involve in the source code execution
validation
9. Which confirms that the software meets its technical specifications?
verification
10. In evolutionary prototype model unstable requirements are prioritized and code is developed initially for the
unstable requirements then foe the stable requirements
False
11. In which model, Testing is done from the earlier stage thereby brings high quality into the development of our
products.
V-model
12. The client wants the UI Screen in their company logo color. The developer is not very sure about the color which
the client is expecting, in this scenario which model be the right model that can be used?
Prototype model
13. ______ is a linear sequential model, systematic in approach and the principle of this model suggests - "Can't
retrieve to the previous phase”
Waterfall model
14. The KK department is doing few activities manually for the past 10 years. The department has decided to
automate the same activities to improve profitability. Which model would be best suited for the above scenario
Waterfall model
15. ________ prioritizes requirements of the system and implements them in groups.
Incremental model
16. The RAD model follows a component based approach.
True
17. ________ is not suitable for large projects because they require more manpower for creating multiple RAD
groups.
RAD
ABC company comes to the Allen Software Company with various requirement. The client wants the
functionality to view all the employee profile, view salary information of the employee and view the leave
details.Once each functionality is completed the module will be delivered to the client. Which would be the right
model for this scenario

Incremental model

A client wants to develop a Web application for the new Super market store. The client want to have lot of UI
components and customers will have lot of interactions with the UI. What model is best suited

Prototype

________ involves tranformation of user needs into an effective software solution.

Software development process

Spiral life cycle model is not suitable for products that are vulnerable to large number of risks. State if True or
False.

FALSE

When there is a difference between the output what is expected and the actual one is termed as……

Defect

XYZ Finance Co. has, at present, started its operations in India. Based on the first six months performance, it has
plans for expansion across five countries. They want to automate their operations at this stage. What is the
process model that the developer should choose to adopt?

Evolutionary prototyping model

Which conforms that the software meets its technical specifications?


Verification conforms that the software meets its technical specifications
Verification
The software is put into operation in the client’s environment. The client comes back to enhance the UI to attract
more customers. This phase is called as _______________
Any change that is made to the software after it is deployed is known as maintenance
Maintenance
Match the appropriate usage of the SDLC process models, based on the nature of requirements

When the requirements are unclear use the Throw away prototype and when the requirements are unstable use
the evolutionary prototype
When the requirements are unstable → Use the Evolutionary prototype,
When the requirements are unclear → Use the Throw away prototype
Arrange the steps / activities involved in the process of prototyping

• Identify basic requirements


• Develop Initial Prototype
• Review the prototype
• Make necessary changes or Enhance the Prototype

Match the phases of the Rapid Application Development model against their objectives
Business modeling - information flow between various modules, Data modeling - define data objects, Process
modeling - CRUD of data objects are determined, Application generation - convert process models into the
actual system,Testing and turnover - new components are tested

generation → Automated tools are used to convert process models into the actual system,
Data modeling → Information gathered from business modeling is used to define data objects,
Testing and turnover → New components along with all the interfaces are tested,
Business modeling → The information flow is identified between various modules,
Process modeling → Data objects are converted to achieve the business objective
High-risk or major functions are addressed in the first cycles there by delivering an operational product. Which of
the SDLC process models achieves this?

High-risk or major functions are addressed in the first increment cycles and each release delivers an operational
product
Incremental model
Beta technologies has undertaken a collision avoidance system software to be implemented for airports.
Additional safety measures have to be automated by warning pilots when another aircraft gets closer, otherwise
impacts are huge. Which of the following SDLC process models best suits the requirement?
Spiral model is used when risks perceived is high
Spiral model
The student mark processing system software has been developed and deployed at the St. Peters university.
The system shows the grade as 0 for all the students rather than the actual grade. Which phase below was not
done properly during the SDLC?
Software Testing
Arrange the phases of Water fall model

• Requirement Gathering
• Analysis
• Design
• Implementation
• Testing
• Deployment
• Maintenance

Testing performed by the user to ensure that the system meets the agreed upon quality attributes and the
specification is called as….

Acceptance testing
Match the correct E,T,V,X (Entry,Task,Verify,Exit) criteria for the below scenario

Input containing the reviewed SRS → Entry,

Developing HLD and LLD Artifacts → Task,

Review of the artifacts → Verfication,

Reviewed design document → Exit

Scenario: LIC has manually carried out their process of premium collection procedure for the past 45 years.
Now, they have employed the services of another company to automate the above.
Question: Which of the following models would you suggest to the outsource company?

Waterfall model

Which model emphasizes Validation and Verification at each level of stage containment?

Validation and Verification at each level of the stage containment is emphasized in V Model
V-Model
Consider that you have to develop a flight control system. The system is simulated as such that the original
system is working. There are many potential hazards with such a system. What model would you suggest to
develop the system?

Spiral model
_________ is the application of a systematic, disciplined, quantifiable approach to the design, development,
operation and maintenance of software.

Software Engineering is the application of a systematic, disciplined, quantifiable approach to the design,
development, operation and maintenance of software
Software Engineering
Requirement came to Allen Software company to develop a software for military purpose. .00001 second delay
in the missle launching software would create greater loss to the human life. What kind of model is best suited
for this scenario

Spiral model

During which phase the following activties are identified:Identifying the major modules of the system, how
these modules integrate, the architecture of the system and describing pseudocode for each of the identified
module

Design

_______ describes how the development activities will be performed and how development phases follow each
other.

Software Development Process describes how the development activities will be performed and how
development phases follow each other
Software Development Process
Aesthetics of the website is part of the functional requirement. State true or false

FALSE

Which of the following options are the steps involved in Requirements Analysis?

Requirements Gathering phase is followed by the Analysis of the gathered requirements

Requirements Gathering phase, Analysis of the gathered requirements phase


Match the correct objectives of each phase involved in Requirements Engineering

Requirements Analysis → Analyzing the customer and the user/stakeholder to arrive at a definition of software
requirements,

Requirements Specification → Documents all the requirements properly,


Requirements Elicitation → Gathering requirements from the users, customers and other stake holders

Arrange the activities of the Requirements Engineering phase and the Design phase

• Requirements Elicitation
• Requirements Analysis
• Requirements Specification
• High Level Design
• Low Level Design

Identify the type of design that helps in transforming the data model created during requirements analysis phase
into the data structures that will be used to implement the software

Data Design helps in creating the data architecture for a system to represent the data components
Data Design
Match the objectives of the types of design involved

Architecture design defines the modules of the system and the functions that each module perform
The interface design describes how the software communicates with itself, and with the users interacting with
the software
Low Level Design focuses on writing a detailed algorithm
Interface design → Describes how the software communicates with itself, and with the users interacting with
the software,
Architecture design → Defines the modules of the system and the functions that each module perform, Low
Level Design → Focuses on writing a detailed algorithm
The order of activities performed by a System Analyst are,
[Understand ] users requirement
[Collects data needed for ] user requirement
[Writes ] software requirement specification
Consider the below scenario. A team has many players and the player belongs to one team. Identify
the cardinality between player and team
M:1
What kind of non functional requirement best suit the below scenario? Whenever the new offers are published in
the online shopping site, an sms has to be sent to all the registered customers within 10 minutes of publishing.
Performance requirement is one of the non functional requirements
Performance Requirement
Choose the correct type of testing for the given Scenario
Testing to test the GUI components in the screen → Usability Testing,
Testing to check if 1000000 users accessing website at the same point of time → Load Testing,
Testing to check if the report is generated within 5 sec on click of the button as agreed in the SRS →
Performance Testing,
Testing to check if the card is swiped for more than three times with wrong pin, the card has to be blocked →
Security Testing
Which of the following are available in SRS Document?
SRS document includes sections for Functional Requirements, Non Functional Requirements, and Constraints
Functional Requirements, Non Functional Requirements, Constraints
Identify the possible entities from the given option
Customer, Sale
Whenever a new product is arrived, the stock needs to be updated. This requirement is an example for non
functional requirement. State true or False
FALSE

Basics Of Testing
Client Comes to Allen Company for a Banking Solution.Which phase of SDLC is best suited to gather what is
expected from client?
Requirement analysis
The standard document that describes all the requirements of the system is called as .............
The standard document that describes all the requirements of the system is called as Software Requirement
Specification
Software Requirement Specification
In remote control Car application, in the step by step execution of the requirement described, it is mentioned
when the fuel level goes below the minium level, the application should indicate the user in red color. In the
output section of the same process it is mentioned that the indicator will glow pink. What is the kind of
requirement specified in SRS
Contradicting
An SRS has the following requirement.The stock exchange shall show the stock report for the next 24
hours.What is the issue with this requirement
Ambiguous
A good SRS should be ______, ________ and _______.
Traceable, Consistent, Complete
Client Comes to Allen Company for a Banking Solution. Who from the below options would be best suited to
gather all the requirements correctly from the client?
A System Analyst understands the users requirements, and collects or gathers the required data
System analyst
Identify this technique of dynamic testing where, For a range of input, three values are chosen, One value above
the range, One value below the range, and One value within the range
Equivalence class partitioning divides the input domain into classes of data from which test cases can be
derived
Equivalence partitioning
What is the difference between the actual output of a software and the correct output?
Error – is the difference between the actual output of a software and the correct output
Error
Match the objectives of the phases of Software Testing Life Cycle
Test Plan→ Resource allocation, creation of test environment, test schedule and test functionality,
Test Execution→ Executing test scripts and Finding bugs,
Test Design→ Test scenarios, test cases, test data, and test scripts are prepared
Arrange the phases of Software Testing Life Cycle

• Test plan
• Test Design
• Test execution
• Report to developer
• Verify and close

Match the roles involved in Static Testing

Reader → Presents the document,


Inspector → Inspecting the document,
Author → Writer of the ‘document under review’,
Scribe → Records each defect found,
Moderator → Leads the review process
What is the type of testing in which the tester will know about the input and the expected output details based on
the specification document only but no knowledge on implementation?
In Black box testing functionality of the software is tested without the knowledge of the internal implementation
of the code
Black Box Testing
Match the objectives against the techniques of generating test cases in black box testing
Cause Effect Analysis → It is suitable for applications in which combinations of input conditions are few,
Cause Effect Graphing → The causes and effects represent the nodes,
State Transition Diagram → Involves actions as one of its components
Which all of the following options would basis path testing perform?
Every statement(Statement coverage)
Every predicate (condition) in the code(branch coverage)
Loops (loop coverage)

Statement Coverage,
Condition or Branch Coverage,
Loop Coverage
After implementation of Library management system, the tester identified that certain logic are redundantly
rewritten by the developers, and the coding standards are violated in few modules. What type of testing is
carried out to identify these errors?
Static Testing is a software testing method where the code of the software and the work products, that is, the
associated documents are observed and tested manually to find errors
Static Testing
Tester is trying to test whether the values in the drop down are listed properly.
What type of testing the tester performs in this scenario?
In Black box testing functionality of the software is tested and not the internal implementation of the code
Black box testing
In the online shopping portal, for customer registration the password field can accept only characters in the
range of 5 to 25. Derive test cases using Boundary value analysis
5,25,4,26
Walk through is performed by the trained moderator, whereas the Inspection is usually conducted by the author
itself to record defects and deviations
False
The testing technique that deals with the internal logic and structure of the code is called ________.
WhiteBox Testing
Determine the cyclomatic complexity for the following
code: Accept year
if(year mod 4=0 and year mod 100!=0) or(year mod 400 =0)
print year is leap
else
print year is not leap
end if.
4
Boundary value analysis can only be used during white-box testing. State if True or False.
FALSE

Software Maintenance
Which maintenance includes all efforts to refine the quality of the software or the document?
Perfective Maintenance includes all efforts to polish or refine the quality of the software or the document
Perfective Maintenance
Match the scenarios against the types of Maintenance
The fare details are updated in the Railway reservation software to reflect the increase in fare → Adaptive
Maintenance,
Client comes back for a change to be made in the Billing report getting generated due to incorrect rounding of
amount → Corrective Maintenance,
The UI of the managetrip.com is refined to include more options for Booking tickets and venues → Perfective
Maintenance
Arrange the steps involved in the Maintenance process

• Impact Analysis
• System release planning
• Change Implementation
• System release
• When a change request comes, Change Control Board first does an impact analysis and does the system
release planning. The changes are then implemented and released.
Identify the correct facts about Maintenance

Maintenance costs are greater than the development cost.


It is affected by both technical and non technical factors.
Aging software can have high support costs (e.g. old languages, compilers etc.).

It is affected by both technical and non technical factors, Aging software can have high support costs
Match the terms involved in Maintenance and its objectives
Software re-engineering → New functionalities are not added to the system but it is restructured and
reorganized,
Architectural transformation → The system is modified from a centralized to a distributed platform,
Software maintenance → Changes are made in response to changed requirements but the fundamental
software structure is stable
RBI has slashed the interest rate from 8% to 7% on all the loans that banks offer. What kind of maintanence has
to be carried out on the banking applications to accommodate this change
Adaptive Maintenance
Help option provided in the online shopping portal has minimal inputs about the application navigation. Client
wants Allen software company to include advanced help options to better serve their customers. What kind of
maintenance best suits the above scenario
Perfective Maintenance
The customer comes back to Allen software company stating that when more than 'n' users simultaneously hit
the website at the same time for customer registration , the application failed to generate the customerid
correctly.What kind of maintanence best suit the given scenario
Corrective Maintenance
State true or false.Well documented and well structured software are difficult to maintain
FALSE
When a system is restructured and reorganized to facilitate future changes, it is called as _________.
Software re-engineering

Configuration Management And Version Control


Y2K problem is an example for ------------- maintenance
Preventive
Any changes done to the software during the operational phase of the software before project wind up is called
as maintenance. State if True or False.
Any change that is made to the software after it is deployed is known as maintenance
FALSE
In an online shopping application, during customer registration the customer was made to enter his city in a text
box. As the site became popular for online shopping, the client came back to include autocomplete feature in the
city field to improve user friendliness. What maintenance needs to be carried out in this scenario?
Perfective maintenance involves making functional enhancements to the system which can increase the
system's performance even when the changes have not been suggested by faults
Perfective
Client wanted to add a new feature to his existing application "Discount Offers" for all the existing customers.
Whenever a new product comes to the supermarket, their customer's should be intimated with the week day
offer. What kind of maintenance is this?
Perfective maintenance involves making functional enhancements to the system
Perfective Maintanence
In Software maintenance, changes are implemented by modifying existing components and adding new
components to the system. State if True or False.
True
Software maintenance for the change of the platform is an example for --------- maintenance
Adaptive
Client has developed an application that allows each of their customers to store 2TB of data. As the number of
Customers are increasing client feels the storage space has to be increased for smooth operations to its
customers. What type of maintanence is this?
Preventive Maintanence

Which of the following options are valid for the relationship between the configuration objects?
A curved arrow indicates a compositional relation.
A double-headed straight arrow indicates an interrelationship.

Match the following facts about Version Management


If a file is changed and we want to roll back to the previous version - Automatic backup.
Lock a file - Serialized changes to file.
When a member of the team wants his code to work in isolation - Create branches.
is responsible for reviewing the items against various specifications for assessing its quality and correctness
Configuration audit
Arrange the steps involved in the Change Control Process

• Identify and submit change request


• Evaluate impacts of change request
• Plan the change
• Implement and test the change
• Verify implementation of change
• Close change request

Version Control allows users to lock files so they can only be edited by one person at a time and track changes
to files
Version control is a mechanism used to manage multiple versions of files
True
Which of the following describes the change history of an object?
Evolution graph
_________ is a committee that makes decisions regarding whether or not proposed changes to a software project
can be incorporated.
Change Control Board
State true or false. Automated tools are available in the market, for managing change and versioning the
software
TRUE
John bought a new Laptop with a high end configuration. To protect his laptop and the applications installed he
Preventive
installed a antivirus software.This is an example for Maintenance
Preventive
From the options identify the features that are part of the software configuration management
Version management, Concurrency control, Synchronisation control
baseline
The entry door of the Server room inside the company can be considered as equivalent to concept in
configuration management.
Baseline
Version Management allows parallel concurrent development. State True or False.
True
Match the correct option
The standard document where the requester fills the change in the change management process → Change
Request Form,
Process that ensures different versions of the project is managed → Configuration Management,
Who authenticates that the change proposed is valid → Change Control Board,
Process that ensures that changes made are recorded and controlled → Change Management

Introduction to Agile Technologies


________ is the process during which the changes of a system are implemented in a controllable manner by
following a predefined model, with some reasonable modifications.
Change Management
Which is the software configuration concept that ensures that change should be done in a controlled and
authorized environment
Baseline
____________ ensures that when two different people does the work and update parallelly, one should not over
write the other
Synchronization control
From the options select the configuration items that are eligible for configuration management
Source code document, Test Report, SRS, Design Document
Tom and Peter works on the same project. Tom does his work and update the local copy back to the
configuration management server. This process is called as
Check-in
Collaborative and co-operative approach among all the stake holders is important. This is a feature of the
_______________ Agile Methodology
Dynamic system development method,
Match the phases and objectives of Dynamic System Development Method
Feasibility study - Assess cost, time and technical factors
Business study - Analyzing the process and the users who are a part of it and their needs
Functional model - Studying the business processes and converting these business process into functional
model
Design and build - Product is developed in iterations
Implementation phase - Delivers the tested system along with the documentation to the end users
Arrange the phases of Feature Driven Development

• Develop overall Model


• Build a Features List
• Plan by Feature
• Design by Feature
• Build by Feature

Match the principles and objectives of Lean Software Development


Eliminate waste - Unnecessary work.
Build in quality - Quality assurance should be integrated through out the project development.
Create knowledge - Learn and share knowledge with others and empower self.
Defer commitment - Make decisions even at the last possible moment.
Deliver fast - Deliver smaller increments of the product in short intervals.
Match the roles and responsibilities of the scrum agile methodology
Scrum master → Coordinator responsible for controlling, handling discussions, communications and removing
any barrier or problems during the scrum process,
Team Member → Programmer, a designer, a tester or an architect,
Product owner → Client/Customer
Arrange the Scrum practices in the correct order

• Plan for the Sprint


• Sprint
• Daily Scrum
• Review the Sprint
• Work Review and finding Improvement

State true or false. During agile development more emphasize is given for documentation
FALSE
Which of the following agile methodologies depends on the cohesiveness of the team and individual
commitment of the team members?
Lean Software Development
Which agile methodology divides the development into sprint cycles, in which a Specified set of features are
delivered? Choose from the following:
SCRUM
What are the roles in dynamic system development method? Choose from the following:
Scribe Facilitator, Technical Coordinator
__________ is an iterative and incremental approach that embraces principles of agile development, including
continuous user/customer involvement.
Dynamic System Development Method

Computer teacher has advised her student that before starting coding you always need to follow the below
activities: Analyse the requirement, write pseduocode then code the same.
From the above scenario, identify the apt keyword from below the teacher is trying to make her students
follow
process

A is a set of programs, procedures and its documentation concerned with the operation of a data processing system.

software

In Ad-hoc software development, the process to be followed is unpredictable and can be changed over time as the
product development progress.

true
Software engineering is the application of a systematic, disciplined, quantifiable approach to the design,
development, operation, and maintenance of software.
True

What is the first step in Requirement Engineering?

Requirements elicitation

______ is the process of establishing the services the system should provide and the constraints under which it must
operate.

Requirement analysis

The main aim of the analysis phase is

To identify what the system is supposed to do

During which phase the cost constraints, time constraints, practical difficulty of the project to be implemented and
resources are analysed?

Feasibility study

Entity represent

Real world object

ER diagram does not represents conceptual level of a database system.

False

Relationship specifies association between two

Entities

Testing is the process to identify differences between expected and actual results.

True

Who performs testing?

programmer and tester

Choose the phases of Testing Life Cycle.

Test Plan

Test Design

During Test Plan, what are the steps involved?

Test Environment

Resource Allocation

Testing can be used to show the presence of

defects

what are different levels of testing?

Unit

Acceptance

Which testing is used to check whether a particular module is implementing its specification.
Unit

Testing that checks both functional and non functional aspects of the system to ensure that the system works as per
the agreed specifications is called as .....

System testing

Two modules are developed customerRegisteration and viewProducts. Customer was unable to choose his city field
while registering, this is a bug.Now after the Bug is fixed by the Development team, the Testing team checks that,
fixed bug does not affect other modules. What type of testing is performed?

Regression testing

Integration testing is mainly done to check for the interface errors

True

Inspection involves step by step reading of the product, with each step checked against a predefined list of criteria.

True

_______ testing is the testing of the software work products manually to find errors.

Static

What are the techniques in Dynamic Testing?

Black box testing

White box testing

During System testing ...... kind of testing is performed to check that the system adheres to the agreed requirement
specification

Black box

Equivalence class and Boundary value analysis can be used to test during all levels of testing

True

White-Box testing does not deals with the internal logic and structure of the code.

False

Maintenance done to correct the existing errors found in the software when the software is used for longer time is
called as -------- maintenance

Corrective

Changes done to add new features or to improve the look and feel of the software is maintenance _____.

Perfective

Storage web site was designed by Allen team. Initially 5GB was allocated to each user who is registered with the
website. As users started to use the storage heavily and anticipating storage shortage might happen the client wants
to do increase the storage capacity. What kind of maintenance should be carried out

Preventive

Maintenance cost will be higher than the development cost or both cost will be equal.

True

Maintenance that involves in platform change or policy change or standards is- maintenance kind of

Adaptive maintenance
Document that is technically reviewed and formally approved by CCB and can make changes only after a formal
approval process is called as

Baseline

Configuration management is required only during the development phase.State true or false

False

Design document is an ----------- object

An Aggregate

All CM information should not be maintained in a configuration database.

False

_________ helps to ensure that parallel changes, performed by two different people, don't overwrite each other.

Synchronization Control

An operation used to make a developer's object version available to other users is called

check in

DSDM stands for _______.

Dynamic system development method

Agile methodology is a conceptual framework where software is developed in iterations.

True

how many principles are there in DSDM?

________ divides the development into short cycles called sprint cycles

Scrum

DSDM focuses on delivering solutions quickly and efficiently

True

which advocates daily team meetings for coordination and integration?

Scrum

Training for both developers and the users is required this is one of the drawback of DSDM.

True

___________ is the application of lean manufacturing principles when developing software

Lean software development

What are the colours involved in crystal methodology?

Yellow

Orange

In which methodology the team must hold both pre- and post- reflection with a strong preference for mid-project
reflection workshops?

Crystal
Feature driven development (FDD) is a short iteration framework for software development.

True

___ is a disciplined approach to deliver high-quality software quickly and continuously.

XP

"Technical Environment with Automated Tests, Configuration Management, and Frequent Integration is the property
of ______ methodology."

Crystal

Extreme Programming (XP) eliminates defects early, thus reducing costs.

True
XML AND JSON
1. What is the correct syntax in HTML for creating a link on a webpage?
<a herf=”mcqsets.html”
2. What are the new features in HTML5?
New form controls like calendar, date, time, email, URL, search
Better support for local storage
Video and audio elements are available for media playback
Canvas element is provided for 2D drawing
3. ____________ is the HTML5 attribute that specifies a regular expression against which the field should be
validated.
pattern
4. ___________ is an HTML5 element, which is used to specify multiple media resources for media elements like
audio and video.
source
5. Within a table cell <td>:
<form></form>
<ol></ol>
<table></table>
<p></p>
All tags could be used
6. State True or False.
Is the following XML fragment a well-formed one?
<?xml version="1.0"?>
<data>
<name>Sandy</name>
<location coast-west>California</location>
<dateofjoin>07/05/2001</dateofjoin>
</data>
False
7. Which of the following options are best suitable for an XML document?
It is a platform independent way to represent data
All of the leading methods of Web services, SOAP, REST, and even XML-RPC, are based on XML
It is a W3C Standard to complement HTML
8. Which one of the following options are best suitable for an XML document?
XML tags are case sensitive
XML elements must be properly nested
XML documents must have a root tag
9. _________ validates the xml document against the schema/dtd.
Parser
10. _________ schema tag allows to specify elements in any order.
all
11. _________ schema tag is used to specify the order in which the tags should appear.
Sequence
12. While declaring an element using XSD schema <xsd:element...>, the default values of minOccurs and maxOccurs
are --------- and --------- respectively.
1,1
13. State True or False.
Reusable schemas can be created by including parts of other schemas or even whole schemas into a parent
schema
True
14. State true or False.
JSON structure is same for all the languages.
True
15. Which of the following datatypes are supported by JSON?
Number
String
Object
16. State true or False.
JSON is a lightweight data-interchange format.
True
17. Which one of the following options represent a JSON array?
{“alphabets”:[“a”,”x”,”z”]}
18. What is the purpose of Schema?
To verify and validate XML elements
19. Which of the following is a well formed XML document?
<?xml version=”1.0”>
<employee>
<empname>amina</empname>
<address location=”north”>ramnagar</address>
<phone>2234678</phone>
</employee>
20. JSON object value is accessed by using ________.
dot(.) notation
21. State True or False.
JSON is data oriented and does not provide display capabilities.
True
22. Which one of the following indicators define that either one of the child element must occur within the
element?
Choice
UNIX
Introduction to Unix
Predict the output of this command, who | wc -|

It displays the number of users logged in

In the following example, the option “-i” is used for the case insensitive search

$ls -l | grep -I “carol.*aug”

True

What option is used in cut command to display the second character from each line of a file employeedetails.txt?

-c

Which command is used to search based on a given pattern?

grep

$ls -l | awk ‘{print $2}’ is used to return the second item($2) from each line of the output from a ls -l listing.

True

The current line needs to be printed five times in the same file. Identify the command that will execute this task?

yy

In cursor movement command, the w option is used to move the cursor to the beginning of the next word.

True

In Vi editor, a wrong file has been opened for editing. What command should be used to close the file without saving
it?

‘sed’ is an interactive editor

False

Which sed command deletes the specified address range?

[address range]/d

Which is the correct syntax for sed on command line?

Sed [options][‘command’][filename]

Create a new file “neq.txt”, which is a concatenation of “file1.txt” and “file2.txt”. Which command would do the
given task?

cat file1.txt file2.txt>new.txt

Which file should be updated so that the changes made will get reflected in all the sessions?

.bash_profile

Which command is used to remove a variable from the list of variables to redefine it?

Unset

Consider the given scenario where the output of the command "$cat file1 file2" is
Displays the content of file1

cat: file2: No such file or directory. Now if we execute the command "cat file1 file2 1>2 2>&1", what would be the
output?

No output is displayed

Identify the output of the given shell script:

set Have a Nice Day echo $1 $10 $*

Have Have0 Have a Nice Day

Consider the given snippet and fill in the blanks with the correct option.

set 10 20 30

echo ____

output should be:3

$#

Identify the output of the given command: cat < f1 >> f2

syntax error

Consider the command, cmd 2>&1 >out and identify its output.

Write standard output to out & standard error to monitor

1. Which will inform the kernel about the c program compilation command which is executed in the
prompt?
System class
2. The ______ part of the operating system will interact directly with the computer hardware.
Kernel
3. What is the option to display the calendar using Sunday as the first day of the week.
-s
4. In df command, -H is used to print the disk space size in human readable format.
False
5. Syntax of a Unix command is:
Command [+/-options] [arguments]
6. Which command should be used to know more about the command “whoami”?
man whoami
7. What will be the output of the given code snippet?
~]$ dc
4
5
+
3
P
3
8. Fill the specific date format in the given echo statement, to print the date in dd/mm/yyyy format.
echo `date +[%d]/[%m]/[%Y]`
9. Predict the output for the following command, if the current date is 21-04-2000.
date '+%B %H'
April 21
10. What is the option used in ls command to list all entries in the current directory including hidden files?
-a
11. Single user mode shell has _____ prompt.
# Root user
12. What is the default maximum number of processes that can exist in Unix?
32768
13. Write the command to display the current date in the form dd/mm/yyyy.
date +%d/%m/%Y

File System
14. What command is used to check the current users?
who
15. Choose the umask value which doesn’t allow execute permission for directories by default.
111
16. In which structure on the disk are file attribute information stored?
Inode
17. rm command will remove a file in Unix. Then the file ____________________.
cannot be recovered by a user
18. ________________ is the command to set the execute permissions to all the files and subdirectories
within the directory /home/client1/temp.
chmod –R +x /home/client1/temp
19. Which command will allow the user to search contents of a file for a particular pattern?
grep
20. Code Fillup:
___________ command is used to remove a directory?
rmdir
21. Code Fillup:
______________ is a form of interprocess communication.
redistribution
22. Which symbol is used in pipe command to group two commands?
|
23. Match the Following:
read and write → rw-
read, write and execute → rwx
read and execute → r-x
write and execute → -wx
24. Which command will take backup of "Employee.dat" file to "Employee.log" file?
cp Employee.dat Employee.log
25. A pipe redirects the output of one command as an input to another command.
True
26. Choose the correct symbol which represents the user home directory.
~
27. By default, the reference count for any regular file is 1?
True
28. By default, the cp command will now copy the meta data of the file, but the mv command preserves
the metadata.
True
29. Which directory in the file structure holds the printer details?
/dev
30. Create a hard link “hlink.txt” and a soft link “slink.txt” for “myfile.txt”. Now delete the source file
“myfile.txt”. What will happen to the link files?
Able to access the file ”hlink.txt” but not “slink.txt”
31. If a link is created using command “ln myfile linkfile”, what will be the reference count for the files?
2
32. If two files in the same partition point to the same inode structure, they are called _______.
Hard links
33. What would happen if we try to remove a read only file, rm filename?
file will be deleted with confirmation - interactively
34. What is the bare minimum permission required to get into a directory?
execute
35. If umask value is set to 0002, then what will be the default permissions set for the files?
664
36. Find the equivalent octal notation for the given permission:
Symbolic Notation : r - x r - - r - -
Octal Notation :
544
37. cp command is like [copy‑paste] and mv command is like [cut‑paste] .
The Octal notation for the given permission "-rwxr-xr–x" is represented as ________ .

755

Match the following:

command < file → Command reads its input from file,

command >> file → Output of command is appended to file,

command > file → Output of command is redirected to file

___________command is used to display only the directory attributes and not its contents.

ls -l -d

__________ stamp is not stamped for a file in a traditional Unix file system.

Creation Time

In ls command -R is the option to list sub directories recursively. Say yes/No.

Yes

When mv first.dat second.dat is executed, the inode of __________ file is freed.

second.dat

In cut, which two options come together?

-d, -f

The last change time of the file is updated, if a user does a chmod operation on a file.

'True'
Code FillUp
To refer a field or column in the current line, ___________ symbol is used in awk command.
$

In tee command, if the standard input was successfully copied to all output files, it returns ______.

Consider the directory structure "PARENT/CHILD/GRANDCHILD". Which option in rmdir command will help us to
remove all the directories "PARENT/CHILD/GRANDCHILD"?

–p

Predict the output of the following command.


$ chmod o+w data.txt
grant write permission to others

grep with the option -n prints __________.

list all lines which match with the given pattern with line numbers

What is the option in filter command grep, which removes any entries from the list by excluding any lines that
start with a leading "d"?

grep -v "^d"

Match the following:

cd . → current Directory,

cd - → will switch to previous visited directory,

cd .. → will move to immediate parent directory

Filters
A pipe redirects the output of one command as an input to another command.

True

Which symbol is used in pipe command to group two commands?

What command is used to check the current users?

Who

______________ is a form of interprocess communication.

redistribution

Which command will allow the user to search contents of a file for a particular pattern?

Grep

Pick the odd man out:

Using cat command, content of a file can be modified, but other commands won't effect the original file.
Cat

In Cut command, ______ option is used to identify the column, when the file has fixed length records.

-c
Match the following:

command < file → Command reads its input from file,

command >> file → Output of command is appended to file,

command > file → Output of command is redirected to file

In ls command -R is the option to list sub directories recursively. Say yes/No.

Yes

tee command, if the standard input was successfully copied to all output files, it returns ______.

In cut, which two options come together?

-d, -f

grep with the option -n prints __________.

list all lines which match with the given pattern with line numbers

Code FillUp
To refer a field or column in the current line, ___________ symbol is used in awk command.
$

What is the option in filter command grep, which removes any entries from the list by excluding any lines that
start with a leading "d"?

grep -v "^d"

Vi Editor
Code Fill up:
___________ command is used to close the vi editor.
:wq or :q

Which command searches the string in file opened in Vi editor?

/ or ?

Match the following

dd → Deletes the line,

yy → Copies the current line,

cc → Removes the content of the file

If no file is specified in sed command, then _____________________.

sed reads from standard input

Which of the following statements is not true?

vi editor commands are not case sensitive

sed maintains the hold space (a buffer) to __________ .

save the data for later retrieval

Which command sets the number for all lines?

:set nu
Arrange the statement.

• $ sed
• 's/
• UK/
• United Kingdom/
• g'
• Country.txt
• > UK.txt

Match the following:

L → moves the cursor to the last line of the screen.,

yy → yank,

dw → deletes from the character selected to the end of the word.,

:wq → save & quit

Which command is used to replace word ‘cat’ (already present in the file) with ‘mouse’ at all places in a file
‘old.txt’ and save the result in a new file ‘new.txt’?

sed ‘s/cat/mouse/g’ old.txt > new.txt

State True / False


In Vi Editor the / command searches downwards in the file.
True

The substitution command (:s/) helps to quickly replace words or groups of words within your files.

True

Which option will provide the current line number, along with the total number of lines in the file at the bottom of
the screen?

^g

Which cursor movement command is used to move the cursor to the last line in file?

$<return>

Which sed command deletes the specified address range?

[address range]/d

Bourne Shell
Which variable is used to display number of arguments specified in command line?

$#

How can you feed standard output of one command to standard input of another in a single shell session?

The pipe operator provided by the shell can be used

Which command can be used to test various file attributes?

test

State True/False
Shell is a wrapper for all the commands and utilities.
True
Which of the following commands allows definition and assignment of environment variables under bash?

env

Which variable contains current shell process id?

$$

Code Fillup
__________is NOT a valid variable in bash.
var1-var2

Match the following:

The number of arguments → $#,

The exit status of the last command executed → $?,

The process number of the current shell → $$,

The filename of the current script → $0

Arrange the code snippets.

• $ name='Williams'
• $ age=21
• echo "Student name is
• $name
• and age is
• $age"

Match What will be the output of the given code snippet?

~]$ val1=10
~]$ val2=9
~]$ test $val1 -gt $val2; echo $?
~]$ [0]
For every successful login, which script will be executed?

/etc/profile

Choose the correct option which matches with the given extended regular expression ab?c*

abbcde , acb , abc , abbc

Predict the output of the following command: $ echo "The process id is $$ $$"

The process id is <pid><pid>

When the return value of any function is not specified within the function, what will it return?

exit status of the last command executed

State True / False.


BASH shell stands for Bourne-again Shell.
True

Fillup
_________ command prints the lines between 5 and 10 (inclusive of line number 5 and 10).
cat filename | head | tail -6
What would be the current working directory at the end of the following command sequence?

$ pwd

/home/user/project

$ cd source

$ cd code

$ cd .

$ pwd

/home/user/project/source/code
Algorithm Analysis and Design Concepts
Data Structure and Algorithms
Rearrange the below algorithm for finding the Maximum of Three Numbers.
Input: Three numbers a, b, and c
Output: x, the largest Number

• procedure max(a, b, c)
• x := a
• if b>x then
• x := b
• if c>x then
• x := c
• return(x)
• end max

• Predict the output of following Program:


• class Test {
protected int x, y;
}

public class MainClass {


public static void main(String[] args) {
Test t = new Test();
System.out.println(t.x + " " + t.y);
}
}
00

Which of the following data structures are indexed structures?

Linear arrays

Consider the following code.


int number[ ]=new int[10];

After execution of this statement which of the following are true:


i. number[0] is undefined
ii. number[10] is 0
iii. number[4] is null
iv. number.length is 10
iv only

Predict the output:


public static void main(String[] args) {
int[] arr;
arr = new int[5];
arr[4]=40;
System.out.println(arr[2]);
System.out.println(" "+arr[4]);
}

0 40
The post fix form of the expression (A+ B)*(C*D- E)*F / G is?

AB+ CD*E – FG /**

Let the following queue can accommodate maximum six elements with the following data:
front = 2; rear = 4;
queue = __ , __ , L, M, N, __ ;
What will happen after an enqueue operation takes place?

front = 2 rear = 5
queue = __ __ , L, M, N, O

Which of the following is a mathematical-model with a collection of operations defined on that model and their
implementations are hidden?

Abstract Data Type

The process of accessing data stored in a serial access memory is similar to manipulating data on a particular
data structure. Which is that data structure?

Stack

Which of the following data structure is better for storing the sorted data on which often insert and deletion
operations are performed?

Linked list

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. What is the
maximum number of parentheses that will appear on the stack AT ANY ONE TIME when the algorithm analyzes:
(()(())(()))

Analysis of Algorithms
What is the purpose of the following code snippets?

for (int i = 0; i < arr.length-1; i++)


{
for (int j = i+1; j < arr.length; j++)
{
if( (arr[i].equals(arr[j])) && (i != j) )
{
System.out.println(arr[i]);
}
}
}
Print the duplicate elements in the array

Rearrange the below algorithm for computing n Factorial.


Input: n, an integer greater than or equal to 0
Output: n!

• procedure factorial(n)
• if n = 0 then
• return(1)
• return(n * f actorial(n - 1))
• end factorial

Select the code snippet which performs unordered linear search iteratively?
The correct answer is: public int UnorderedLinearSearch(int[] arr, int size, int data)
{
int index=0;
for(int i = 0; i < size; i++)
{
if(arr[i] == data)
{
index = i;
break;
}
}
return index;
}

Choose the scenario(s) when we need to use Linear search?


When the list has only a few elements,

When performing a single search in an un-ordered list

Jane has created a special type of linked list. That linked list contains no NULL values in its links. If so, what
type of linked list is Jane has created?

Circular Linked List

If the given array is {6,2, 5, 1, 9 }, the 3rd number from the left while doing bubble sort in the 2nd iteration
5
is Answer

Rearrange the below algorithm for Bubble Sort.


Input: A is the list of elements and n is the size of the list
Output: A1, A2,...,An, arranged in increasing order

• procedure bubbleSort(A,n)
• for i = 0 to n-1
• for j = 0 to n-i-1
• if A[j] >A[ j+1 ]
• swap a[j] <-> A[j+1]
• end bubbleSort

You have to sort a list 'L' which consists of some sorted elements and few “random” elements. Which of the
following sorting methods would be especially suitable for such a task?

Insertion sort

What is the time complexity for executing merge sort on an array of size n which is already sorted is

O(n log n)

Time complexities of three algorithms are given. Which should execute the slowest for large values of N?

O(n^2)

A linear collection of data elements where the linear node is given by means of a reference is called
Linked list

Choose the correct data structure whose size is fixed and insertion and deletions are bit difficult because we have to
shift the elements upward or downward to avoid the wastage of memory.
Array
________ is a header list where the last node points back to the header node.
Circular header list

which of the following is a logical description of how we view the data and the operations that are allowed without
regard to how they will be implemented?

Abstract Data types

operation is not performed in linear list.

1. Insertion 2. Deletion 3. Retrieval 4. Traversal


None

Match the following items with their descriptions:


pop() Deletion in stack

dequeue() Deletion in queue

peek() Access topmost element on stack

push() Insertion in stack

enque() Insertion in queue

Choose the Linear Data types:


Stack

Arrays

Queue

Choose the correct real-time application which uses Queue for its implementation?
Process Scheduling

Which of the following form of access is used to add and remove nodes from a queue?
FIFO, First In First Out

Which Data Structure Should be used for implementing LRU cache?


Queue

What is the Worst case scenario occur in linear search algorithm?

Item is the last element in the array or is not there at all

Which of the following is the correct list where we can apply Binary search algorithm.

Sorted Array

Team leader wanted Raj to develop an efficient algorithm for an application. To check the efficiency of the algorithm
which Raj developed, what are the two main factors he needs to consider?

Time and space

The time factor when determining the efficiency of algorithm is measured by

counting the number of key operations

Match the following:

1. Completeness Is the strategy guaranteed to find the solution when there in one
2. Accuracy producing the correct solution

3. Space Complexity How much memory need to perform the operation

4. Time Complexity How long does it take to find a solution

choose the correct algorithm which is efficient for smaller data sets but not for larger sets

Insertion sort

The running time of quicksort depends on selection of

Pivot element

Match the following items with their descriptions:

Bubble sort-compare adjacent data

Heap sort-complete binary tree based

Quick sort-pivot value

Insertion sort-best for small data sets

The number of interchanges required to sort 6,2,7,3,5 in ascending order using Bubble sort is ________

How many number of comparisons are required in insertion sort to sort a file if the file is sorted in reverse order?

N^2
Introduction To Java
JRE consists of ____________ and Java API.

JVM

The java source code is compiled by the ____________ command.

javac

__________ converts the byte code into machine language and executes it.

JVM

Drag and drop the words to their places:

JDK consists of JRE and tools.

Which of the following features make(s) Java robust?

Automatic garbage collection

________________ makes java platform independent.

Byte code

Observe the below statements.

i. Using java we can develop a Web Application


ii. ii. Using java we can develop a Desktop Application

Which of the following statements is/are true?

Both i and ii are true

Identify the feature(s) of java.

Automatic garbage collection

Platform independent

Identify the edition(s) of Java.

J2SE

J2EE

J2ME

All the options

Which of the following statements is/are valid?

int num1 =10; long num2=num1;

char x=’a’; int num1=x;

Match the comments to their corresponding types.

/*Welcome to Java */ Multi Line Comment

/** * * */ Java Documentation Comment

//Welcome to Java Single line comment

Match the following.


int value = 20; long Ivalue=value; Implicit Conversion

long Ivalue=20;int value = (int)lvalue; Explicit Conversion

Which of the following is a/are primitive data types?

float

int

Which of the following is are valid identifiers?

A12b#

_ab123

Match the following with the correct operators.

&& || ! Logical Operator

?: Conditional Operator

| ^ >> << >>> Bitwise Operator

!= > < <= >= Relational Operator

If there are two operators of equal priority in an expression, it gets evaluated based on

Associativity

Associativity for which of the following operators is/are right to left?

Conditional Operator

Assume num1=10. Which of the following is not a valid statement?

num1<<<2

Say true or false.

In java boolean true value is a non zero value and false value is zero.

False

Select the correct order of precedence in the following (Highest to lowest) O ll && ?:

&& || ?:

A _________ statement will skip executing a loop further and exit from that loop.

break

Identify the selection statement(s).

if

Observe the below code.

int num1-10;

if(num1)

System.out.println("Hello");

else

System.out.println("Hai");
What is the output of the following code?

Compilation Fails

Which of the following statements will get executed at least once even if the condition statement is true or false?

do…while

Identify the jump statements that can skip processing remainder of code in its body for that particular iteration.

continue

Which of the following statements can be used to test equality alone?

switch

Given a class with the name Trainee. Which of the following instantiated an object for this class?

Trainee t = new Trainee()

Choose the correct answer in each drop-down list:

A class defines the attributes of objects and methods used to control an object's behaviour.

Drag and drop the words to their places:

Class is a template for a collection of objects that share a common set of attributes and behaviour. Object is the
instance of class

The methods of a class with the ________ access specifier cannot be accessed in another class of the same package.

private

How to access the members of a class?

<objectName>.<memberName>

In a class, an attribute needs to be accessed from any class in that application. What should be the access specifier
for that attribute?

Public

Which concept is used to implement Information Hiding?

Access specifier

__________ is used to change the state of a private field in a class.

Mutator

Consider a class Student. It has a method - public float calculateTotalFees(). Which of the following
method signatures is/are valid for method overloading?
public int calculateTotalFees(float busFees,float messfees)
public float calculate TotalFees{float busFees)

Which of the following keywords acts as a reference variable to the current object?

this

Assume a class person identify the correct signature for the constructor.

public Person()

A wrapped data can be unwrapped using ____________ method where xxx is the corresponding primitive.

XXXValue()
For every primitive data type other than character, there is a corresponding wrapper class.

False

Which of the following package has the object class?

java.lang

default delimiter for the scanner class is ____________.

White space

observe the code :

float f=9.5f;

double d=new double(f);

system.out.println(d);

what will be the output?


9.5

Fill the correct options in the appropriate places.

There are many in built methods in java, which can work only on objects and not on Primitives where wrapper
class can be used.

Which package is imported by default in java?

java.lang

In Java, grouping of semantically related classes is done using _____________.

Packages

Compiler searches for the .class files in few directories. These directories are known to the compiler based on
__________.

Class path

Observe the below command

javac -d. Test.java

Which of the following statements is/are true?

The package structure is created in the current directory

Which of the following represents package level accessibility?

Default

Assume there is a class Employee in package pack1 and this class is dependent on Project class which is in package
pack2. Which statement should be included in Employee class?

import pack2.Project;

Observe the following code snippet.

package model

public class Employee {............)

Assume you have compiled the code correctly. How will you execute the code?

Java model.Employee
Identify the incorrect statement(s) about packages.

Name collision problem will exist if we use packages

Packages cannot have interfaces

To apply binarySearch method to an array, it needs to be a sorted array. If not sorted, then it will result in

Unpredictable output

which of the following is a/are valid method signatures(s)

int findProduct(int value, int … num)

Assume an array price of size 20. which of the following can be used to access the 5th position element?

price[4]

Choose whether the statement is true or falsw:

Arrays can be created only for primitive data types.

False

To which of the following can the sort method in Arrays class be applied?

Both options

Array of primitive data types

Array of objects

which of the following can be used if the number of arguments passed to a method are of same data type, but the
number of arguments is unknown?

Varags

Identify the valid array initialization(s).

int[] arr = new int[10];

int arr[] = new int[10];

which property gives the number of elements in an array?

length

Declare an array as int numlist =new int 10. which of the following statements will be executed without any
errors/exception?

numlist[0]=10;

numlist[1]=10;

observe the code.

String name= “welcome”;

char c = name.charAt(7);

system.out.println(c);

What will be the output?

StringIndexOutOfBoundsException

Choose the correct answer in each drop-down list:


string objects are Immutable

observe the code.

String name = “Welcome”;

name.concat("Sam");

System.out.println(name);

What will be the output?

Welcome

Which of the following are thread safe?

StringBuffer

_______ makes java more memory efficient?

String pool

The string method in java which is used to match with a pattern is __________.

matches

which operator is used to match any non word character?

\W

\d is a short code for ___________

[0-9]

which of the following are the classes available in java.util.regex package?

Pattern

Matcher

Consider this relationship - Iphone is a smart phone. Which of the following statements is/are correct for this
relationship?

class Iphone extents SmartPhone

If a sub class has a method with the same name, parameter list and return type as declared in the parent class with a
different implementation, then it will lead to

Method overriding

What should be the relationship between two classes, so that inheritance relationship exists between them.

Is A

which of the following inheritance is/are not supported by java?

Multiple inheritance

state true or false

A child class will inherit the properties and methods of the parent class and it cannot possess any special properties
of its own.

False

_____________ is the process in which one object can acquire the properties and behaviour of the parent object.
Inheritance

Which of the following statements is/are not true?

constructor of superclass is inherited by subclass

members declared as protected in super class will be inherited only by the sub classes within the same package

how should a class be declared to make that class is ‘not inheritable’?

final

if a method in a super class should not be overridden by the subclass then it should be declared as _______.

Final

_________ keyword is a reference variable that refers to the immediate parent of a class.

Super

Which of the following statements is/are true about super keyword?

super keyword is used to invoke immediate parent class method

All the given options are correct

super() should be the first statement in the constructor

super() is used to invoke immediate parent class constructor

State true or false Final keyword can be used with variable and method, but not with a class.

False

casting a reference of parent class to one of its child class is called __________.

Downcasting

Assume Employee is the parent class of PermanentEmployee.

Employee empObj-new PermanentEmployee();

This statement leads to ___________.

Upcasting

Observe the following code.

class Parent

public void display(String name)

System.out.println("In Parent class");

class Child extends Parent

public void display(String firstName)


{

System.out.println("In Child class");

public void printMessage()

System.out.println("Welcome to learing ");

public static void main(String args[])

Parent f= new Child();

f.printMessage();

Compilation error

Drag and drop the words to their places:

Static binding is achieved through Method Overloading and Dynamic binding is achieved through Method overriding.

State true or false.

The child class of abstract class can be either abstract or concrete class.

True

A class is an abstract class if it has _________ abstract methods.

Zero or more

When a class inherits an abstract class and it does not implement all the abstract methods in that abstract class, then
that class should be ____________.

An abstract class

Consider the following statements.

Statement 1: An abstract class cannot be instantiated Statement 2: An abstract class cannot have a constructor
Which of the following is true about these statements?

Statement 1 alone is correct

Drag and drop the words to their places:

A class can Extend only one class and implement one or more interfaces

Choose the correct answer in each drop-down list:

A class can implement more than one interface.

All methods in an interface are by default ______________

Public and abstract


When a class that implements the interface does not provide implementation for all the methods in the interface,
then that class ______________.

Should be declared as abstract class

A class can extend _________ and implement _______________

Only one class, many interfaces

____________ is a contract which the implementing class should adhere to.

An interface

Assume an interface Bluetooth implemented by the class Samsung.

Bluetooth b=new Samsung();

b.sendFile();

Here sendFile() is an abstract method in Bluetooth implemented by Samsung. What does the above code depict?

Run time polymorphism

A static method in an interface can be accessed ____________.

Only by the interface name

State true or false. Default methods in an interface should have method body.

True

A default method is _________ by default.

Public

Lambda expression avoid unwanted anonymous inner class?

True

What is the output of below code?

interface MyLambda

void display();

class Test

public static void main(String a[])

MyLambda aBlockOfCode = () - > System.out.println("Hello World");

aBlockOfCode.display();

Hello world
Which of the following are true regarding Function Interfaces?

It can have only one abstract method

It can have default or static methods.

Which of the following are built-in functional interfaces?

Predicate

Consumer

HashSet is an ______________ collection

Unordered

_______________ allows to scan a list both forward and backward

ListIterator

which package contains all classes and interfaces related to collection?

java.util

__________ stores the elements as key/value pairs

HashMap

TreeMap

Predict the output

Map map=new HashMap();

map.put("John","India");

map.put("Pinky","California");

map.put("Tina","Germany");

map.put("Pinky","Russia");

Set mapset=map.entrySet();

System.out.println(mapset);

[John=India, Pinky=Russia, Tina=Germany]

Which of the following facts are true about list in collection.

List allows index based addition and retrievel of items

List is ordered collection

Which of the below method is used to iterate over each element of the stream.

forEach

Which of the below does Stream filter() operates on

Predicate

Which of the below option best explain the purpose of limit method of Stream

Reduce the size of the stream

In which of the below package Streams API of java 8 is available


java.util.stream

A pipeline is a sequence of what operations in java 8

Stream

To handle the exception, enclose the code that might throw an exception within a _______ block

try

Choose the correct answer in each drop-down list:

Checked exceptions should be explicitly handled or properly propagated

Exception is an abnormal event or error that occurs during __________

Runtime

Which of the following is / are unchecked exceptions

RuntimeException

ArrayIndexOutOfBoundsException

Which block always executes whether or not an exception occurs?

Finally

Which of the following is / re checked exceptions

SQLException

FileNotFoundException

Which of the following statements are not true?

A try block has multiple catch black, then those exception handlers can be in any order

A try block must be followed only by at least one catch block

Drag and drop the words to their places:

Unchecked exceptions are automatically propagated.

To propogate Checked exception, the method should explicitly throw the exception using the throws keyword

To use a class in try with resources, that class should have implemented ________ interface.

AutoCloseable

A program can explicitly throw an exception using ________ statement.

Throw

When a method overrides the method in the parent class, which of the following are valid?

It can throw any of the exceptions.

It can throw any of the exceptions thrown by the overridden method

It can throw sub classes of the exceptions thrown by the overridden method

Identify the valid code snippet?

try{ Path path=Paths.get("dolphinsBorn.txt");

String text=new String(Files.readAllBytes(path));


LocalDate date=LocalDate.parse(text);

System.out.println(date); }

catch (DateTimeParseException | IOException e) { e.printStackTrace(); }


JVM is independent of OS

False

How was Java initially named?


The Oak

To compile, debug and execute a program written in java, _______________ is required.


JDK

Who is the father of Java?


James Gosling
What is Polymorphism?
ability to have many forms

Java is _____________________________.
Platform independent

State true or false. Java is a structured programming language.

False

French curly braces { } is a must if the for loop executes more than one statement. State true or false.

True

looping structure should be used when the iterations are known.

[for]

loops will execute the body of loop even when condition controlling the loop is initially false.

do-while

What value is stored in i at the end of this loop?


for(int i =1;i<=10;i++)
The program control will exit the for loop only when the condition specified in the for loop has failed. Hence, the
value of i will be 11.
11
Fill in with appropriate datatype.
byte
switch( )
{
case value1 : ..........................
case value2 : ..........................
.......................................

default:
System.out.println("Hello");
}

byte
What will be the output of the program?
for(int i = 0; i < 3; i++)
{
switch(i)
{
case 0: break;
case 1: System.out.print("one ");
case 2: System.out.print("two ");
case 3: System.out.print("three ");
}
}
System.out.println("done");

Switch takes the values 0, 1 and 2.


Case 0 has nothing to execute.
Execution of Case 1 is followed by 2 and 3 since there's no break statement encountered. So, one two three.
Execution of Case 2 is followed 3 since there's no break statement encountered like before. So, two three.
This is followed by "done".

one two three two three done


What will be the output of the program?
int i = 1, j = -1;
switch (i)
{
case 0, 1: j = 1; /* Line 4 */
case 2: j = 2;
default: j = 0;
}
System.out.println("j = " + j);

One can not specify multiple case labels with commas, as in line 4. Hence compilation error.
Compilation fails.
The break statement causes an exit ___________

from the innermost switch. , from the innermost loop

What will be the output of the program?


Given:
10. int x = 0;
11. int y = 10;
12. do {
13. y--;
14. ++x;
15. } while (x < 5);
16. System.out.print(x + "," + y);
What is the result?
x is assigned 0 and y, 10 initially. During each iteration x is incremented by 1 and y is decremented by 1.
The iteration stops when x equals 5. At this stage y also would have reached the value 5. Hence the output 5 5.
5,5
What is the output of this program?
class selection_statements {
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2);
}
}
Observe the if construct. var 2 is assigned 1. 1 does not equal 5, hence else block will get executed. Pre
increment to var2 results in 2 (var2 variable now has the value 1, not 6). Hence 2 gets printed.
2
What is the output of this program?
1. class Crivitch {
2. public static void main(String [] args) {
3. int x = 10;
4.
5. do { } while (x++ < y);
6. System.out.println(x);
7. }
8. }

Which statement, inserted at line 4, produces the output 12?


The output expected is 12 (value of x). In line 5, the condition has to fail when the value of x is 11 (x gets
incremented by 1 only after the condition checking).
If the condition has to fail when the value of x is 11, then y (the value which is going to remain unchanged in all
stages) has to be 11.
int y=11;
Identify the features of java.
Exception Handling, Multithreading

In a for loop, if the number of statements are greater than one, which of the following needs to be inserted at the
beginning and the end of the loop?

French curly braces{ }

The main method in java should ___________.

be public static

What will be the output of the program?


public class Sample {
final static short a = 2;
public static int b = 0;
public static void main(String [] args) {
for (int c=0; c < 4; c++)
{
switch (c) {
case a: System.out.print("a ");
default: System.out.print("default ");
case a-1: System.out.print("a-1 ");
break;
case a-2: System.out.print("a-2 ");
}
}
}
}
a-2 a-1 a default a-1 default a-1

A continue statement makes the execution jump to ______________.


the next iteration of the loop

JRE comprises of ___________ and ___________.

API,

JVM

Using Java we can develop ___________________.

Both the options (desktop application, web application)

The ________________ statement causes the program execution to stop and JVM to shut down.

System.exit( )

The break statement cannot be present for _____________ construct.


If

Classes and Objects, Packages


State True or False
When using eclipse whichever classes are needed for the present class can be imported automatically.
True

Predict the output.

public class Test {


public static void main(String args[])
{
int a = 2, b = 0;
for ( ; b < 20; ++b) {
if (b % a == 0)
continue;
else if (b == 10)
break;
else
System.out.print(b + " ");
}
}
}
Whenever b is even the first if statement is true so continue statement gets executed. Hence when b is odd and
less than 20, it gets printed.
1 3 5 7 9 11 13 15 17 19
switch(a)
{
default:
System.out.println("Welcome");
}
Of which data types can the variable ‘a’ be?
1. long
2. byte
3. int
4. char
5. float
6. short
The variable used in a switch statement can be a byte, short, int, char or String type only.
2,3, 4 and 6
What will be the output of the following code?
int i=20;
if(i>10)
{
System.out.println( "The value of i is "+i);
i++;
if(i%2!=0)
break;
}
Compilation fails
In Eclipse IDE, if we provide a workspace, it should already exist. If not, it will not open.

False

Hands On - Classes and Objects, Packages


___ and _____ are the access specifiers that can be applied to top level Class.
default, public

class Sample{
private double num = 100;
private int square(int a){
return a*a;
}
}
public class Test{
public static void main(String args[]){
Sample obj = new Sample();
System.out.println(obj.num);
System.out.println(obj.square(10));
}
}
Compile time error

Choose the appropriate access specifier for the attribute value so that it can be accessed from anywhere.
class Test
{
public
int value;
}
Public

Choose the appropriate return type for the getters and setters provided below.
class Test
{
private int value;
void
public setValue(int value){//some code}
int
public getValue(){//some code}
}
Void

Int

Analyze the below program, and fill the correct code so that it produces the below output:
0
0.0
101

public class Book {


private int bookId;
private double bookPrice;
public int getBookId() {
return bookId;
}
public void setBookId(int bookId) {
this.bookId = bookId;
}
public double getBookPrice() {
return bookPrice;
}
public void setBookPrice(double bookPrice) {
this.bookPrice = bookPrice;
}

class Test
{
public static void main(String a[])
{
Book bobj=new Book();
}
}
[System.out.println(bobj.getBookId());]
[System.out.println(bobj.getBookPrice());]
[bobj.setBookId(101);]
[System.out.println(bobj.getBookId());]
Consider the below code snippet and determine the output.
class Student
{ private int studentId;
private float average;
}
class Test
{
public static void main(String a[])
{
Student s=new Student();
s.studentId=123;
System.out.println(s.studentId);
}
}
Private variables can be accessed only within the class. They cannot be accessed outside the class.
Compile time error
The below code snippet shows an error

cannot find symbol:

System.out.println("BookId:"+bobj.getId());

public class Book {

private int bookId;

private double bookPrice;

public int getBookId() {

return bookId;

public void setBookId(int bookId) {

this.bookId = bookId;

public double getBookPrice() {

return bookPrice;

public void setBookPrice(double bookPrice) {

this.bookPrice = bookPrice;

}
public class Test {

public static void main(String[] args) {

Book bobj=new Book();

bobj.setBookId(123);

bobj.setBookPrice(500);

System.out.println("BookId:"+bobj.getId());

System.out.println("BookPrice:"+bobj.getBookPrice());

Analyze the above code and select the correct reason for the error.

When we specify the methodname or variablename or classname wrongly,then we will get an error “cannot find
symbol”. The compiler tries to fetch the methodname "getId" from the book class, where it is not defined.
getId method is not present in the book class
Arrange the code in the correct sequence, so that the program compiles successfully.

• public class Employee {


private int employeId;
private float salary;
• public void setSalary(float salary1) {
• if(salary>0){
salary=salary1;
}
• }
}

Drag and Drop the code so that the constructor for Student class is overloaded correctly.

public class Student {

private int studentId;

private String name;

private float grade;

public Student(int studentId, String name) {

[ ]

public Student(int studentId, String name, float grade) {

[ ]

[ ]

}
this.studentId = studentId; this.name = name;

this(studentId,name);

this.grade = grade;]

Observe the below code.


public class Student {
private int id;
private String name;
private char grade;
//Constructor 1
public Student() {
id=0;
name= " ";
}
//Constructor 2
public Student(int id, String name) {
this.id=id;
this.name=name;
}
}
Choose the constructor that is invoked, when an object is created as shown below.
Constructor 1
new Student();
Constructor 2
new Student(54, "John");
Constructor 1

Constructor 2

You are given with few classes.

Match the code with the type of constructor available in the class.

public class Student {

public Student(int studentId, String name) { BLANK

public class Student {

public Student( ) { BLANK

public class Student { BLANK

Parameterized Constructor
No-argument Constructor

Default constructor

Observe the code below.


public class Student {
int studentId;
String name;
char grade;
public Student(int studentId, String name, float mark) {
this.studentId = studentId;
this.name=name;
calculateGrade(mark);
}
public void calculateGrade(float mark){
if(mark>90)
grade='A';
else
grade='B';
}
}
For the code
Student s = new Student(1,"Peter",95);
What will be the output?
Compiles successfully

Observe the below class.


class Product{
int productId;
String productName;
Product( ) {
productId=0; productName=” ”;
}
Product(int id, String name) {
//access Account() ---- Line 1
productId=id;
productName=name;
}
}
Identify the valid option which is used to invoke the no argument constructor, Product(), at Line 1.
this() invokes the current object's no argument constructor.
this();
Observe the below code
public class Product
{
int productId;
String productName;
static int count = 0;

public Product(int pid,String name){


productId = pid;
productName=name;
count++;
}

public static void main(String arg[]){

Product p1=new Product(101,"Screws");

Product p2=new Product(102,"Nuts");


Product p3=new Product(103,"Nails");

}
}
Drag and drop the options correctly so that the output will be
Count is 1
Count is 3
System.out.println("Count is "+Product.count);

System.out.println("Count is "+p3.count);

Choose the correct option :


public class Flight{
int flightId;
static int noOfSeats;
public static void display(){
System.out.println("No of seats "+noOfSeats);

}
}
Non static members cannot be accessed from static methods. If we want to access non static members from a
static method it is possible by creating an object. Hence, only "noOfSeats" can be accessed, not "flightId".

System.out.println("No of seats "+noOfSeats);

Match the following :


static method → Can access static members only,

non static method → Can access both static and non static members

Observe the code :


public class Employee {
String name;
static int employeeCount;
//Line 1
}
Which of the following code can be included in Line 1?
From a static method, we can access only static members. Non static members cannot be accessed from static
methods.
However, from a non static method, we can access both static and non static members.

public static void display(){


System.out.println("Employee count "+employeeCount);
},
public void display(){
System.out.println("Employee count "+employeeCount);
},
public void display(){
System.out.println("Employee Name"+name);
}
For the below code, what are the valid ways to invoke display method in the main method.
public class Test {
public static void display(){
}
}
public class Main {
public static void main(String a[]){
//Invoke the display method
}
}
Static method can be invoked either by using the object instance or using the class name.
Test.display();
new Test().display();
Given the below code :

public class AreaCalculator {


public double calculateArea(double radius) {
double area = PI * radius * radius; //Instead of Math.PI
return area;
}
}
Drag and drop the correct statement to use the static variable PI.
import static java.lang.Math.PI;

Assume class Calculator in package p1 and CalculatorService class in package p2 as shown below.
package p1;
public class Calculator {
__________ static void calculate(){
//some code here
}
}
package p2;
import p1.Calculator;
public class CalculatorService {
public void display(){
Calculator.calculate();
}
}
What can be the valid access specifier for the calculate method in Calculator class so that it can be accessed
from CalculatorService class?
If a method defined within a class in one package has to be invoked from outside, then that method has to be
declared public.
public
Given the class Book in packages p1 and class Main in package p2. In main to create an object of Book, which
of the following are valid.

Since the Book class is present within p1 package, it has to be accessed as "p1.Book", everytime, from package
p2.
p1.Book bookObj=new p1.Book();
Given the class Book and Library in two different packages :
1. package model;
2. public class Book {
3. private static void countBook( ) { }
4. }

1. package util;
2. public class Library {
3. public static void main(String[] args) {
4. // insert code here
5. }
6. }
What is required at line 4 in class Library to use the countBook method of Book class?

countBook() cannot be invoked since the method is declared private.


Library class cannot use the countBook method in Book class.
Rearrange this code correctly.

• package test;
• import java.util.Scanner;
• public class Main
• {
//Some code here
}

Given classes defined in two different files:


1. package p1;
2. public class Test {
3. public static void display(String [] a) { /* some code */ }
4. }

1. package p2;
2. public class TestMain {
3. public static void main(String[] args) {
4. String [] names = new String[10];
5. // insert code here
6. }
7. }

Identify the statement to be written in line 5 in class TestMain to call the display method of class Test.
p1.Test.display(names);
What is the outcome of the code?

public class Item {


private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public static void modifyDesc(Item item,String desc) {
item=new Item();
item.setDescription(desc);
}
public static void main(String[] args) {
Item it=new Item();
it.setDescription("Gobstopper");
Item it2=new Item();
it2.setDescription("Fizzylifting");
it.modifyDesc(it,"Scrumdiddlyumptious");
System.out.println(it.getDescription());
System.out.println(it2.getDescription());
}
}
Gobstopper
Fizzylifting
What is the output of following Java Program?
class Test {
int x = 10;
public static void main(String[] args) {
System.out.println(x);
}
}
“x” is non static. It cannot be accessed in a static method, main. If needed, can be accessed through an object,
as, new Test().x
Compile Time Error
Given:
public class Message {
String msg;
int noOfWords;
public Message() {
msg += " Thank you";
}
public Message(int noOfWords) {
this.noOfWords = noOfWords;
msg = "Welcome";
Message();
}
public static void main(String args[]) {
Message m = new Message(5);
System.out.println(m.msg);
}
}
Compilation fails
Predict the output.
class X
{
void display(int a)
{
System.out.println("INT");
}

void display(double d)
{
System.out.println("DOUBLE");
}
}
public class Sample
{
public static void main(String[] args)
{
new X().display(100);
}
}
INT
Integer x1 = new Integer(120);
int x2 = 120;
System.out.println( x1 == x2 );

What will be the output of the above code fragment?


True
The methods of a class with the ____________ access specifier cannot be accessed in another class of different
package.
Default
Which of the following is not a Java modifier?
Virtual

Arrays and Strings


Which members of a class can be accessed by other classes is determined by the ________________
Access specifier
What does this() mean in constructor chaining concept?
Used for calling the no argument constructor of the same class.
package edu.ABC.model;
public class Account {
public static final float INTERTEST_RATE = 7.5;
}
Identify the correct options from the classes provided below.
import static edu.ABC.model.Account.*;
public class Loan {
public double getInterest() {
return INTEREST_RATE; \
}
}
import edu.ABC.model.Account ;
public class Loan {
public double getInterest() {
return Account.INTEREST_RATE;
}
}
Given:
public class ItemTest
{
private final int id;
public ItemTest(int id) {
this.id = id;
}
public void updateId(int newId) {
id = newId;
}
public static void main(String[] args) {
ItemTest fa = new ItemTest(42);
fa.updateId(69);
System.out.println(fa.id);
}
}
What is the result?
CompileTime Error
Identify the true statement(s).
Statement 1 : When no constructor is written in a class, the compiler creates a default constructor
Statement 2 : The default constructor will implicitly invoke the default / no-argument constructor of the super
class
Statement 3 : If a class has a parametrized constructor alone, then the compiler will create the default
constructor
Statement 4 : If a class has a parametrized constructor, it is mandatory to write a no-argument constructor
1 and 2
Identify which statement is true about construtors.
Constructor can be overloaded
A JavaBeans component has the following field:
private boolean enabled;
Which two pairs of method declarations follow the JavaBeans standard for accessing this field? (Choose two.)
When writing getters and setters, setters return type is void and getters return type is the corresponding data
type. Naming convention is camelcase notation. For setters start with set followed by field name and for
getters start with get followed by field name. For boolean return type, it should start with 'is' or 'are' followed by
field name.
public void setEnabled( boolean enabled )
public boolean isEnabled(),
public void setEnabled( boolean enabled )
public boolean getEnabled()
Predict the Output of following Java Program.
class Test {
int x = 10;
public static void main(String[] args) {
System.out.println(x);
}
}
Compile Time Error

Hands On - Strings
Determine the output:
public class Test
{
public static void main(String[] args)
{
int[] x = {1, 2, 3, 4};
int[] y = x;
x = new int[2];
for(int i = 0; i < x.length; i++)
System.out.print(y[i] + " ");
}
}
Array x is initialized with 4 values and this means reference "x" contains the starting address of the array. This
address is copied to the array reference "y". This mean the 4 values can now be accessed with "y" as well. Then
the reference x is assigned with a new array's starting address whose length is 2. Hence the iteration outputs 1 2
12
class Output
{
public static void main(String args[])
{
int a1[] = new int[10];
int a2[] = {1, 2, 3, 4, 5};
System.out.println(a1.length + " " + a2.length);
}
}
Array a1 is created so as to contain 10 integer elements. Hence, the length is 10.
Array a2 is initialized with 5 values. . Hence, the length is 5.
10 5
Determine the output:
public class A
{
public static void main(String argv[])
{
int ary[]=new int[]{1,2,3};
System.out.println(ary[1]);
}
}
The array ary is initialized with 3 elements and the element at the first index is 2.
2
Determine the output
public class Trial
{
public static void main(String[] args)
{
int arr[4]={};
System.out.print(arr[0]);
}
}
int arr[4] is syntactically wrong
Compile time error
Determine the output: (MCQ)
public class Test
{
public static void main(String[] args)
{
int[] x = new int[3];
System.out.println("x[0] is " + x[0]);
}
}
The "new" keyword allows memory for storing integer elements in an array to be created in the "heap" and the
memory is initialized with "default of integer" which is 0.
The program runs fine and displays x[0] is 0.
Determine the output
class array_output
{
public static void main(String args[])
{
char array_variable [] = new char[10];
for (int i = 0; i < 10; ++i)
{
array_variable[i] = 'i';
System.out.print(array_variable[i] + "");
}
}
}
array_variable is a character array that can hold 10 characters. The for loop gets iterated for 10 times. During
each iteration, the array index is assigned with the character "i" and printed alongside. Hence the output "iiiiiiiiii".
iiiiiiiiii
Determine the output:
class Evaluate
{
public static void main(String args[])
{
int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n = 6;
n = arr[arr[n] / 2];
System.out.println(arr[n] / 2);
}
}
arr is an integer array that is initialized with 10 values.
When n is initialized with value 6, n = arr[arr[n] / 2] evaluates to n = 3. Now, printing arr[n] / 2 will output 1.
1
What will be the content of array variable table after executing the following code?
public class Trial
{
public static void main(String[] args)
{
int []table[]=new int[5][5];
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 3; j++)
{
if(j == i)
{
table[i][j] = 1;
System.out.print(table[i][j]);
}
else
{
table[i][j] = 0;
System.out.print(table[i][j]);
}

}
System.out.println("\n");
}
}
}
"table" is a 2 dimensional array with 5 rows and 5 columns. It is iterated from 0 through 3 and during each
iteration j==i (iteration variables) is checked. When j==i evaluates to true, the index is assigned the value "1" and
printed. Else, assigned "0'" and printed.
100
010
001
Given a one dimensional array arr, what is the correct way of getting the number of elements in arr
arr.length
is
arr.length
Column size is mandatory to create an array in java. State true or false
False
is used to allocate memory to array variable in Java
new
is used to find string length
length()
Fill in appropriately.
String st1 = new String("JAVA");
String st2 = new String("JAVA");
String st3="JAVA"
3 2 1
objects, in heap memory and in string pool
The "new" keyword allows memory for storing String to be allocated in the "heap" . Otherwise, memory is
allocated in string pool.
[3] objects, [2] in heap memory and [1] in string pool
What is special about string objects as compared to objects of other derived types?
You can concatenate two string objects using ‘+’,
You can create string objects without or without using new operator,
Java provides string constant pool to store the string objects
Given:
1. public class MyLogger {
2. private StringBuilder logger = new StringBuuilder();
3. public void log(String message, String user) {
4. logger.append(message);
5. logger.append(user);
6. }
7. }
The programmer must guarantee that a single MyLogger object works properly for a multi-threaded system.
How must this code be changed to be thread-safe?
StringBuffer is synchronized and therefore thread-safe. StringBuilder is compatible with StringBuffer API but
with no guarantee of synchronization. Because it’s not a thread-safe implementation, it is faster and it is
recommended to be used only in places where there’s no need for thread safety.
Replace StringBuilder with StringBuffer
is the string contained in s after following lines of code?
StringBuffer s new StringBuffer(“Hello”);
s.deleteCharAt(0);
ello
String s1 = null;
is the valid declaration of a String.
String s1 = null;
Predict the output
class String_demo
{
public static void main(String args[])
{
char chars[] = {'a', 'b', 'c'};
String s = new String(chars);
System.out.println(s);
}
}
A character array is initialized with 'a', 'b' and 'c' and the array reference is chars. Printing this reference will
output abc.
A "new" string object is initialized with this reference and this object is referred by "s". Printing this reference will
output abc.
abc
Predict the output
class String_demo
{
public static void main(String args[])
{
int ascii[] = { 65, 66, 67, 68};
String s = new String(ascii, 1, 3);
System.out.println(s);
}
}
An integer array is initialized with values 65, 66, 67 and 68. Its reference is "ascii". A new string object is
initialized with this reference such that the elements from index 1 through 3 alone gets copied as "characters".
This object is referred by "s". Printing this object will output BCD which are the char-equivalents of 66, 67 and
68.
BCD
+ operator can be used to concatenate two or more String objects in java. State true or false.
True
What will s2 contain after following lines of code?
String s1 = “one”;
String s2 = s1.concat(“two”);
The string "two" referred by s2 is "concatenated to" the string "one" referred by s1.
onetwo
Select the correct choice so that the below statement returns true, if the input provided contains any alphabet
other than xyz.
[a-z&&[^xyz]]
Pattern.matches(" ", "d")
Select the correct choice so that the below statement returns true, if the input provided contains any alphabet
other than xyz.
[a-z&&[^xyz]]
Which of the following matches X occurs n or more times?
X{n,}
Assume that the ID of an employee should start with "CBE" or "BLR" or "HYD" followed by hyphen (-) followed by
4 digits.
Choose the apt regular expression that matches this text.
(CBE|HYD|BLR)[-][0-9]{4}
String Objects are mutable. State true or false.
False
What is the output of this program?
class Output {
public static void main(String args[]) {
int a1[] = new int[10];
int a2[] = {1, 2, 3, 4, 5};
System.out.println(a1.length + " " + a2.length);
}
}
10 5
String name="teknoturf";
String cname="teknoturf";
String compname=new String("teknoturf");
1.if(name==cname)
2.if(name.equals(cname))
3.if(name==compname)
4.if(name.equals(compname))
Identify the output.
Line 1,2,4 will return true.
State True or False.
Advanced for loop is better as it is less error prone as we don't need to deal with index.
True
List the correct ways of declaring an Array.
int [ ]studentId;
int studentId[ ];
String [ ] name [ ];
StringBuffer is used to create ______________.
a mutable String
Consider the below statements.
Statement 1 : Matcher class interprets the pattern in a String
Statement 2 : Matcher class matches the regular expression against the text provided
Which of the following is true?
Both Statement 1 and 2 are correct
class TestArray {
public static void main(String args[]) {
int arr_sample[] = new int[2];
System.out.println(arr_sample[0]);
}
}
What will be the result of compiling and executing the above code?
The program compiles and prints 0 when executed.
In which of the following packages can you find String class?
Lang
The first name of a person should contain only alphabets and space.
Which of the following regular expression will match the requirement?
[a-zA-Z ]+
Predict the output of the below code :
import java.util.regex.*;
public class TestRegEx{
public static void main(String args[]) {
Pattern p = Pattern.compile(".ech");
Matcher m = p.matcher("tech");
boolean b = m.matches();
System.out.println(b);
}
}
True
Given a one-dimensional array arr, what is the correct way of getting the number of elements in arr?
arr.length
StringBuilder is less efficient and slower than StringBuffer. State true or false.
False
Which of the following text when matched with the regular expression “[a-zA-Z&&[^aeiou]]+” will return true?
My,
Cry
class ArrayTest {
public static void main(String args[]) {
int[] primes = new int[10];
primes[0] = "a";
System.out.println(primes[0]);
}
}
What will be the result of compiling and executing the above code?
compile time error

Inheritance, Polymorphism, Abstract class, Interface


What will be the output of the program?
public class Test {
public static void main (String args[]) {
String str = NULL;
System.out.println(str);
}
}
String str=NULL is invalid. It should be either String str=null or String str="NULL"
Compile time error
Choose correct answer – true / false
String[] cities = new String[]{"London", "Paris", "NewYork", "HongKong", "Tokyo"};
String[] metros = new String[]{"London", "Paris", "NewYork", "HongKong", "Tokyo"};
String[] capitals = cities;
System.out.println("cities == metros : " + (cities == metros));
System.out.println("cities == capitals : " + (cities == capitals));
System.out.println("cities.equals(metros) : " + cities.equals(metros));
System.out.println("cities.equals(capitals) : " + cities.equals(capitals));
System.out.println("Arrays.equals(cities, metros) : " + Arrays.equals(cities, metros));
System.out.println("Arrays.equals(cities, capitals) : " + Arrays.equals(cities, capitals));
What will be the correct answer for the following?
true
cities.equals(capitals) :
true
Arrays.equals(cities, metros) :
false
cities == metros :
true
true
false
Given:
21. public String makingStrings() {
22. String str = "Welcome";
23. str = str.substring(1, 5);
24. str = str.toUpperCase();
25. return str;
26. }
How many String objects are created in the heap when this method is invoked?
str.substring(1,5) and str.toUpperCase() returns String object. String str="Welcome" is created in String
pool. Hence number of objects is 2.
2
Given:
public class Main {
public static void test(String str) {
if (str == null | str.length() == 0) {
System.out.println("String is empty");
}
else {
System.out.println("String is not empty");
}
}
public static void main(String a[]) {
test(null);
}
}
What is the result?
str == null return true but when str.length() is executed, as str is null, it throws NullPointerException
An exception is thrown at runtime.
Predict the output:
public class Trial {
public static void main(String[] args) {
int arr[4]={ };
System.out.print(arr[0]);
}
}
int arr[4] is not correct way to declare an array.
Compile time error
In Java, what happens if you try to compile the below code :
class MyStringDemo extends String {
}
String class is final and hence cannot be inherited.
The code does not compile because the String class is final.
To copy elements from one array to another array, Java provides efficient built-in methods in ________ class.
Arrays
What will be the output of the program?
String str = "welcome";
str.toUpperCase(); /* Line 2 */
String s1 = str.replace('C', 'c');
s1 = s1 + " to Java";
System.out.println(s1);
Line 2 returns WELCOME, but is not stored. So s1 takes value as “welcome” and not “WELcOME”
welcome to Java
Observe the code.
int arr[]={12,14,22,5,1,66};
int position = Arrays.binarySearch(arr,5);
System.out.println(position);
What will be the output of the above code snippet?
Unpredictable
Observe the code
public class StringDemo {
public static void main(String[]args) {
String s1=new String("java");
String s2=new String("java");
System.out.println(s2.compareTo(s1));
}
}
The output of the code is
0
Determine the output:
public class Test {
public static void main(String[] args) {
int[] arr1 = {11,12,13,14,14,15};
int[] arr2 = arr1;
arr1 = new int[3];
for(int i = 0; i < arr1.length; i++)
System.out.print(arr2[i] + " ");
}
}
11 12 13

Hands On - Inheritance, Polymorphism, Abstract class, Interface


public class ArithmeticOperation{
private void add(int operand1, int operand2)
{
System.out.println(operand1 + operand2);
}
}
public class Addition extends ArithmeticOperation
{
public void show()
{
add(10, 12);
}
public static void main(String args[])
{
Addition ob = new Addition();
ob.show();
}
}
What will be the output of above code when compiled and executed?
The method add cannot be invoked from anywhere since it's declared private

Compile time error


What will be the output of the following program ?
class FourWheeler
{
public FourWheeler()
{
System.out.println("Class FourWheeler");
}
}
class Car extends FourWheeler
{
public Car()
{
System.out.println("Class Car");
}
}
class Audi extends Car
{
public Audi()
{
super();
System.out.println("Class Audi");
}
}
class Driver
{
public static void main(String args[])
{
Audi cc=new Audi();
}
}
The first statement that always gets executed from within any constructor is super() which means the
invocation of super class no-parameterized constructor.
FourWheeler is the parent of Car and Car is the parent of Audi. The no-parameterized constructor call of Audi
happens from the driver class. Followed by the no-parameterized constructor call of Car. Followed by the no-
parameterized constructor call of FourWheeler. Hence, the output "Class Four WheelerClass Car Class Audi".

Class FourWheeler
Class Car
Class Audi
10. class FourWheeler {
11. blank void display() { }
12. }
13. class Car extends FourWheeler {
14. blank void display() { }
15. }
Which method at line 14, will correctly complete class Car?
Private
protected
Given:
class FourWheeler
{
public FourWheeler ()
{
System.out.print(1);
}
}
class Car extends FourWheeler
{
public Car()
{
System.out.print(2);
}
}
class Audi extends Car
{
public Audi()
{
System.out.print(3);
}
}
public class Driver
{
public static void main( String[] argv )
{
new Audi();
}
}
What is the result when this code is executed?
The first statement that always gets executed from within any constructor is super() which means the
invocation of super class no-parameterized constructor.
FourWheeler is the parent of Car and Car is the parent of Audi. The no-parameterized constructor call of Audi
happens from the driver class. Followed by the no-parameterized constructor call of Car. Followed by the no-
parameterized constructor call of FourWheeler. Hence, the output "123".
123
The class Employee is declared in a package mainpack and the Derived classes PermanentEmployee and
TemporaryEmployee are declared in another package subordpack. The basicPay attribute should be accessed
only by means of a derived class object.
How to ensure that the basicPay attribute is not accessed directly by the other classes in the subordpack?
Employee.java
mainpack
package ;
public class Employee{
protected
int basicPay;
}
/*PermanentEmployee.java*/
subordpack
package ;
public class PermanentEmployee extends Employee{
.....
}
//TemporaryEmployee.java
subordpack
package ;
public class TemporaryEmployee extends Employee{
.....
}
For a child class that is residing in a package to access a variable of its parent that is residing in a different
package, the variable in the parent has to be declared "protected" so that it will be visible to all its children
across packages. The "protected" basicPay attribute is not accessed directly by the other classes in the
subordpack, in our case.
Mainpack
Protected
Subordpack
Subordpack
class FourWheeler{
protected FourWheeler getObject()
{
//logic with return statement
}
}
class Car extends FourWheeler
{
blank
}
class Driver
{
public static void main(String args[])
{
FourWheeler object = new Car();
object.getObject();
}
}
Java 5.0 onwards it is possible to have different return type for a overriding method in child class, but child’s
return type should be sub-type of parent’s return type. The visibility of a method can only be increased as we
traverse down the hierarchy.
protected Car getObject() {}
Say that there are three classes: Computer, AppleComputer, and IBMComputer. What are the likely relationships
between these classes
Computer is the super class, AppleComputer and IBMComputer are subclasses of computer
can
Constructor of the superclass be invoked by from its subclass.
cannot
A default member of a super class in one package be accessed in its own subclass which is in a
different package.
can
A protected member of a super class in one package be accessed by its own subclass which is
in a different package.
Can
Cannot
Can
State True or False
Child class objects can be instantiated when the parent class constructor is protected
True
blank is the most restrictive access modifier that will allow members of one class to have access to members
of another class in the same package.
Default Access

private
Given a method in a public class, access modifier must be used to restrict access to that
method to only the other members of the same class.
Private
Interpret which of the following statements are correct with respect to inheritance relationship in java?
object of subclass referenced by super class type can invoke super class methods,
object of subclass referenced by super class type can invoke overridden sub class methods,
object of subclass referenced by super class type can access super class variables
PREDICT THE OUTPUT
Observe the following code
class FourWheeler
{
public void display()
{
System.out.println("FourWheelers displayed");
}
public void get()
{
System.out.println("Get FourWheelers");
display();
}
}
class Car extends FourWheeler
{
public void display()
{
System.out.println("Cars displayed");
super.display();
}

public static void main(String [] args)


{
FourWheeler f=new Car();
f.get();
}

}
What is the output of the above code ?
The main method has child object referred by parent reference. In this case, on invoking any method, only when
a method is unavailable in the child, it is searched for in the parent.
The functions get executed in the following order.
get() of FourWheelers class
display() of Car class
diaplay() of FourWheelers class

Get FourWheelers
Cars displayed
FourWheelers displayed
Predict the output
Class Icecream{
public void displayName(String...s){
System.out.println(s+” “ +“Icecream");
}
public void describe(String s) {
System.out.println(s+” “ +"Icecream: Ice cream is a sweetened frozen food typically eaten as a snack or
dessert. ");
}
}
class Faloodeh extends Icecream {
public void displayName (String s){
System.out.println(s+” “ +"Faloodeh ");
}

public void describe (String s) {


System.out.println(s+” “ +"Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice
cream ");
}
}
public class Test {
public static void main(String arg[]) {
Icecream a=new Faloodeh ();
Faloodeh b=( Faloodeh)a;
a.displayName ("test"); b.displayName ("test");
a. describe ("test");b. describe ("test");
}
}
The main method has child object(Faloodeh) referred by parent reference(Icecream).
Then the parent reference is downcasted to child type reference and assigned to the new child reference.
On invoking displayName() with downcasted parent and child reference, the definition in child is implemented.
On invoking describe() with downcasted parent and child reference, the definition in child is implemented.

test Faloodeh
test Faloodeh
test Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream
test Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream
What will be the output of the program?
class Tree { }
class Pine extends Tree { }
class Oak extends Tree { }
public class Forest1
{
public static void main (String [] args)
{
Tree tree = new Pine();
if( tree instanceof Pine )
System.out.println ("Pine");
else if( tree instanceof Tree )
System.out.println ("Tree");
else if( tree instanceof Oak )
System.out.println ( "Oak" );
else
System.out.println ("Oops ");
}
}
Since Pine object is held by Tree type reference - tree, the first condition in the if construct evalutes to true and
hence, "Pine".
Pine
Given:
1. class Dog { }
2. class Beagle extends Dog { }
3.
4. class Kennel {
5. public static void main(String [] arfs) {
6. Beagle b1 = new Beagle();
7. Dog dog1 = new Dog();
8. Dog dog2 = b1;
Beagle b3 = (Beagle) dog2;
9.
10. }
11. }
Which, inserted at line 9, will compile?
Beagle b4 = dog2; is wrong because a child type reference can never old the parent object or parent reference.
Beagle b3 = (Beagle) dog2; is right because a downcasted parent reference can be assigned to a
child reference.
Beagle b3 = (Beagle) dog2;
What will be the output of the following program ?
class A
{
public void test()
{
System.out.println("Class A");
}
}
class Trial extends A
{
public void test()
{
System.out.println("Class Trial");
}
public static void main(String args[])
{
Trial object = (Trial)new A();
object.test();
}
Trial object = (Trial)new A(); produces compile time error because a parent object can never be referred by a
child type reference.
Runtime Error
class Calculator
{
Calculator()
{
System.out.println("Basic arithmetic operation ");
}
Calculator (int x)
{
this();
System.out.println(x + " " + "is the only operand supplied");
}
Calculator(int x, int y)
{
this(5);
System.out.println("Two operands supplied are multiplied and the resultant is "+ x * y);
}
public static void main(String args[])
{
new Calculator(8, 10);
}
}
The main method has the two parameterized constructor call. the first statement within this definition is one
parameterized constructor call. And the first statement within this is no parameterized constructor call.
Hence the output : Basic arithmetic operation , 5 is the only operand supplied, Two operands supplied are
multiplied and the resultant is 80.

Basic arithmetic operation


5 is the only operand supplied
Two operands supplied are multiplied and the resultant is 80
The equals() method takes the reference of Object as parameter. State true or false.

True

final methods
can't be overridden.

final methods

Which three statements are true?


A protected method in class X can be overridden by any subclass of X.,

A public static method in class X can be called by a subclass of X without explicitly referencing the class X.,

A method with the same signature as a private final method in class X can be implemented in a subclass of X.

If you have - final class Test {} how to create a reference for the class “Test” while inheriting it?

Compilation Error : we can't inherit the class which is “final”.

10. abstract public class Employee {


11. protected abstract double getSalesAmount();
12. public double getCommision() {
13. return getSalesAmount() * 0.15;
14. }
15. }
16. class Sales extends Employee {
protected double getSalesAmount() { return 1230.45; }
17.
18. }
Which method, inserted at line 17, correctly complete the Sales class?
Since the Sales class is not abstract, it must have the implementation for the abstract method in Employee
class. We must not reduce the visibility of the method in the child class. Hence, protected double
getSalesAmount() { }

protected double getSalesAmount() { return 1230.45; }

Predict the output of the following program:


abstract class Demo
{
public int a;
Demo()
{
a = 10;
}
abstract public void set();
abstract final public void get();
}
class Test extends Demo
{
public void set(int a)
{
this.a = a;
}
final public void get()
{
System.out.println("a = " + a);
}
public static void main(String[] args)
{
Test obj = new Test();
obj.set(20);
obj.get();
}
}
Compilation error

Will the following code get executed successfully ?


abstract class Shape
{
int i = 111, j = 222;
abstract void calcArea();
abstract void calcVolume();
}
abstract class Square extends Shape
{
void calcVolume() { System.out.println(j); }
void calcArea(){ System.out.println(j); }
}
public class Test
{
public static void main(String[] args)
{
Square c = new Square();
c.calcArea();
c.calcVolume();
}
}
Compilation error. Object cannot be created for the class Square as "Square c = new Square() ".

Will the below code will execute successfully ?


abstract class Shape
{
final abstract int calcArea();
}
Since the abstract method within the abstract class is declared final, it can never be implemented in any of its
child classes. Hence, it is an error.
'False'
What is the output of the given code?
abstract class Shape
{
int i = 111, j = 222;
abstract void calcArea();
abstract void calcVolume();
}
abstract class Quadrilateral extends Shape
{
void calcArea()
{
System.out.println(i);
}
}
class Square extends Quadrilateral
{
void calcVolume()
{
System.out.println(j);
}
}
public class Test
{
public static void main(String[] args)
{
Square c = new Square();
c.calcArea();
c.calcVolume();

}
}
Here is multilevel inheritance. The main method has object created for class Square, referred by Square type
reference.
The abstract methods clacArea() and calcVolume() in parent have their implementation within their children.
Only when an implementation is not found child class, it is searched for in parent class and executed. Hence
111, 222.
111
222
What is the Output of following Java Program?
abstract class Demo
{
public int a;
Demo()
{
a = 10;
}
abstract public void set();
}
class Test extends Demo
{
final public void get()
{
System.out.println("a = " + a);
}
public static void main(String[] args)
{
Test obj = new Test();
obj.get();
}
}
The program produces compile time error because the abstract set method in the parent has not found its
implementation in child class (which has the main method too).
Compile Time Error
can
An abstract class have non abstract methods also.
Can

cannot
Abstract methods be final.
Cannot

Predict the output


abstract class Vehicle
{
abstract void calcPremium(Number N);
}
interface Insurance
{
abstract void calcPremium (Object O);
}
class Car extends Vehicle implements Insurance
{
public void calcPremium (Object O)
{
System.out.println("Object");
}
void calcPremium (Number N)
{
System.out.println("Number");
}
}
public class Test
{
public static void main(String[] args)
{
Vehicle a = new Car();
a. calcPremium (new Integer(121));
Insurance b = new Car();
b. calcPremium (new Integer(121));
Car c = new Car();
c. calcPremium (new Integer(121));
}
}
a. calcPremium () with an integer object invokes this method within the Car class that takes Number argument.
This is because a is the Vehicle type reference and Vehicle class has calcPremium () with a Number argument
declared abstract. Hence, Number.
b. calcPremium () with an integer object invokes this method within the Car class that takes Object argument.
This is because b is the Insurance type reference and Insurance interface has calcPremium () with an Object
argument declared abstract. Hence, Object.
c. calcPremium () with an integer object invokes this method within the Car class that takes Number argument.
Hence, Number.

Number
Object
Number
The type Vehicle has drive functionality. The classes Car and Bike implements the drive functionality and can be
further subclassed. Fill in the given code with appropriate access specifier so that the subclasses of Car and
Bike do not modify the Drive functionality.
interface Vehicle{
void drive();
}
class Car implements Vehicle{
public final
void drive() {
//drive }
}

public

final

If a class extends two interfaces and they both have a method with same name and signature but different
return type, then a conflict will arise because the compiler will not able to link a method call due to ambiguity.
State true or false.

True

11. public interface Status {


public static final
12. double PI = 3.14;
13. }
Fill the correct choice.
public static final

An interface can contain public, static, final fields (i.e., constants) default and static methods with
True
bodies
False
An instance of interface can be created.
True
A class can implement multiple interfaces.
True
Many classes can implement the same interface.
True

False

True
True

Predict the output


class Car implements Insurance
{
public int calcPremium(int i)
{
return i = i * i;
}
}
interface Insurance
{
int calcPremium(int i);
}
public class MainClass
{
public static void main(String[] args)
{
Insurance b = new Car();
System.out.println(b.calcPremium(2));
}
}
b.calcPremium(2) will look for the method within the interface - b being the reference of interface type.
The definition of this method is given in the Car class that has implemented this interface. With i=i*i, the output
is 4.
The output will be 4
Predict the output:
interface Employee
{
int a=90;
}
class PermanentEmployee implements Employee
{
public void f1()
{
a=10;
}
}

Variables within interface are static and final by default. They can not be assigned a value in the classes that
implement this interface.
error, since variable a is assigned a value
public abstract interface Insurance{
public void insuranceDescription(String s);
}
Which is the correct class?

public abstract class Car implements Insurance { }

Predict the output.


interface DoStuff2
{
float getRange(int low, int high);
}
interface DoMore
{
float getAvg(int a, int b, int c);
}
abstract class DoAbstract implements DoStuff2, DoMore
{}
class DoStuff implements DoStuff2
{
public float getRange(int x, int y)
{
return 3.14f;
}
}
interface DoAll extends DoMore
{
float getAvg(int a, int b, int c, int d);
}
The file will compile without error.

interface ICalculate
{
public int add(int a,int b);
}
extends
interface IScientificCalculator Calculator
{
public int calcSine(double value);
}
Extends

interface ICalculate
{
public int add(int a,int b);
}

implement
class Test ICalculate
{
public int add(int a,int b)
{
//some code
}
}
Implements

Drag and drop the correct option.


interface Bluetooth
{
public void sendFile();
}
abstract class Mobile
{
abstract public void makeCall();
}
extends Mobile implements Bluetooth
class IPhone
{

//some code
}
Extends

Mobile

Implements

Bluetooth

Which of the following are valid statements about interfaces?

All methods that are declared in an interface are by default public and abstract.,

Interface can contain any number of default methods which needs to be provided with implementation.

interface Loan
{
double issueLoan(double salary);
double repayLoan(double loanAmt,double amount);
}
class Employee implements Loan
{
double issueLoan(double salary) {
System.out.println("Issue Loan");
return salary * 0.10;
}
double repayLoan(double loanAmt,double amount) {
System.out.println("Repay Loan");
return loanAmt - amount;
}
}
What is the output of the above code when executed as :
Employee e = new Employee();
e.issueLoan(500000);
Compilation error
Observe the below code

interface A {
public void printNumber(int a);
public default void display()
{
System.out.println("Hello");
}
}

class Test{
public static void main(String args[])
{
A a1= (num) -> System.out.println(num);
a1.printNumber(20);
}
}

What will be the output of the above code?


20

Predict the output of the below code


interface ITest{
public float calculate(int a,int b);
}
public class Test{
public static void main(String args[])
{
ITest test=(int a,int b)->{return a+b;};
System.out.println(test.calculate(5, 4));
}
}
Prints 9

If a method in an interface is implemented in it, then that method should be either _______ or _________.

static, default

Observe the below interface.


interface B{
public float display();
}
Which of the following are valid lambda expression for the above interface?
B b1=( )->{ float a=10.5f; return a; };f
int a=15;
B b1=( )->{ return a; } ;
If a class inheriting an abstract class does not provide definition for all abstract methods in the parent class,
then it will be known as _______________.
Abstract

Predict the output:


public abstract class Abs {
public Abs(){
System.out.println("Constructor from Abstract class");
}
}
public class Test extends Abs {
public static void main(String args[]){
Abs obj=new Test();
}
}
Constructor from Abstract class

____________ can be achieved through inheritance.


both run time polymorphism & code reusability

Given:
1. public class Employee {
2. String name;
3. double baseSalary;
4. Employee(String name, double baseSalary) {
5. this.name = name;
6. this.baseSalary = baseSalary;
7. }
8. }
And:
11. public class Salesperson extends Employee {
12. double commission;
13. public Salesperson(String name, double baseSalary,
14. double commission) {
15. // insert code here
16. }
17. }
Which code, inserted at line 17, completes the Salesperson constructor?
super(name, baseSalary);
this.commission = commission;

Predict the output of the below code :


interface A{
public void display();
public void printNumber(int a);
}
class Test{
public static void main(String args[])
{
A a1={ ( ) -> System.out.println("Hai");
(a) -> System.out.println(a);
};
a1.printNumber(20);
}
}
Compilation error

If a method in a super class is overridden by the sub class, then the overridden method can be invoked using
____________ keyword.

Super

Assume Book is a parent class and Magazine class is the child of Book class.
Match the following:
Book b = new Magazine();
Magazine m = (Magazine) b;
Book b = new Magazine(); → Upcasting,

Magazine m = (Magazine) b; → Downcasting

Which would declare a compilable abstract class?


In a class, if a method is just declared without providing any definition, it needs to be declared as abstract. In a
class, if there are any abstract methods it needs to be made abstract. Even if a class has no abstract methods, that
class can be declared as abstract .
public abstract class Shape { public Square draw() { } }

A default method in an interface can be either private or public or protected. State True or False.

False

Which of the following are valid lambda expression ?


(int a)->a+2;

(int a, int b)->a+b;

( )->System.out.println("Welcome");

public abstract class Shape {


private int x; private int y;
public abstract void draw();
public void setAnchor(int x, int y) {
this.x = x;
this.y = y;
}
}
Which two classes use the Shape class correctly? (Choose two.)
public abstract class Circle extends Shape {
private int radius;
}

public class Circle extends Shape {


private int radius;
public void draw() {/* code here */}
}

class A {
String name="A";
public String getName() {
return name;
}
String greeting() {
return "class A";
}
}
class B extends A {
String name="B";
String greeting() {
return "class B";
}
}
public class Test {
public static void main(String arg[]) {
A a=new A();
A b=new B();
System.out.println(a.greeting()+" has name "+a.getName());
System.out.println(b.greeting()+" has name "+b.getName());
}
}
Place the names "A" and "B" in the following output.

class has name

class has name


AA

BA

Which of the following represents the correct lambda expression for the Functional method :
int findMin(int a,int b) ?
(int a,int b) -> {
int min = a>b ? a : b;
return min; }

Which of the following are valid functional interface ?


@FunctionalInterface
interface Test
{
public void calculate(int a,int b,char oper);
public default void display(){
System.out.println("default method");
}
}

@FunctionalInterface
interface Test
{
int a=10;
public void display();
}

@FunctionalInterface
interface Test
{
public void display();
}

A class can be declared as __________ if it should not be sub classed.

Final

Exception Handling
Observe the statements.
Statement 1 : An abstract class cannot have non abstract methods
Statement 2 : An abstract class should have a minimum of one abstract method in its class.
Abstract class can have attributes and normal methods along with abstract methods.
For a class to be abstract, it can have zero or more abstract methods.
Statement 1 and Statement 2 are false
If the access specifier of the display method in super class is protected, then what could be the valid specifier
for the overriding display method in sub class?
The subclass overridden method cannot have weaker access than super class method. Which means, when
overriding a method, the access level cannot be more restrictive than the overridden methods access level. In
parent class the method is protected, then in child class it can be protected or public.

protected and public


__________________ is the best example for Runtime Polymorphism.
Method Overriding

If the sub class overrides the method in the parent class, the overridden method can be invoked by using either
‘this’ or ‘super’ keyword. State true or false.
False

Observe the code.


interface A1 {
public abstract void a11();
public abstract void a12();
}
interface A2 extends A1 {
void a21();
void a22();
}
public class C implements A2 {
}
In the above scenario, which methods should class C override?
In an interface when a method is just declared, by default they are public and abstract. So when the methods in
an interface are overridden they need to be public (access level cannot be more restrictive). If not it leads to
compilation error.
public void a11() { }
public void a12() { }
public void a21() { }
public void a22(){ }
Predict the output.
class Parent {
public void display() {
System.out.println("In Parent");
}
}
class Test extends Parent {
public void display() {
System.out.println("In child");
}
public void testMethod() {
System.out.println("In test method");
}
public static void main(String[] args) {
Parent p = new Test();
p.display();
p.testMethod();
}
}
Compile Time error

Predict the output.


abstract class Sample {
public int x;
Sample() {
x = 10;
}
abstract final public void display();
}
class Test extends Sample {
final public void display() {
System.out.println("x = " + x);
}
public static void main(String[] args) {
Test t = new Test();
t.display();
}
}
If a method is abstract it should be overridden by the child class. If a method is final it cannot be overridden. So
a method cannot be both abstract and final. If so, it results in compilation error.
Compile Time error

Hands On - Exception Handling


When a dynamic linking failure happens or a hard failure in the Java virtual machine occurs, the virtual machine
Error
throws a/an

Error

blank class is highest in hierarchy in java

java.lang.Object

Class
Exception is a

Class

Which is valid about java.lang.Exceptions?

The class Exception and all its subclasses that are not also subclasses of RuntimeException are checked
exceptions,

The class RuntimeException and all its subclasses are unchecked exceptions

Which of the given facts are true with respect to the blocks and order of execution of blocks in "Exceptions"?

One or more catch blocks which are exception handlers are placed immediately after the try block,

The finally block always executes when the try block exits or when an exception occurs,

Catch block has an argument which can accept an argument of any exception type and it is the name of a class
that inherits from the Throwable class

What will happen when catch and finally block both return value?
method will return value returned by finally block

Predict the output


public class Exception1
{
public static void main(String[] args)
{
System.out.println("method return -> " +m());
}
static String m()
{

try
{
int i= 10/0;
}
catch(ArithmeticException e)
{
return "catch";
}
finally
{
return "finally";
}
}
}
"method return ->" is followed by the function call. The try block within the function raises an exception. It is
caught and handled. This is followed by the execution of the finally block.
When there's a return statement in both catch and finally block, then return in finally is what is actually returned
to the function. Hence, "method return -> finally."

method return -> finally


What will be output of following program ?
public class Test {
public static void main(String[] args) {
String str = null;
System.out.println((String)str);
}
}
NullPointerException (null)

84. try {
85. ResourceConnection con = resourceFactory.getConnection();
86. Results r = con.query("GET INFO FROM CUSTOMER");
87. info = r.getData();
88. con.close();
89. } catch (ResourceException re) {
90. errorLog.write(re.getMessage());
91. }
92. return info;
Which statement is true if a ResourceException is thrown on line 86?

The resource connection will not be closed on line 88.


Predict the output
import java.io.IOException;
public class Exception1{
public static void main(String[] args)
{
try
{
throw new IOException();
}
catch(IOException | Exception ex)
{
System.out.println(ex + " handled ");
}
}
}
program won't compile

What will be the output of the program?


public class Exception1
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (Exception ex)
{
System.out.print("B");
}
finally
{
System.out.print("C");
}
System.out.print("D");
}
public static void badMethod() { }
}

There's no exception raised within the try block. Hence, the print statement within try, finally and the statement
outside try and finally, all get executed in sequence. Hence, ACD.

ACD
What will be the output of the program?
public class RTExcept
{
public static void throwit ()
{
System.out.print("throwit ");
throw new RuntimeException();
}
public static void main(String [] args)
{
try
{
System.out.print("hello ");
throwit();
}
catch (Exception re )
{
System.out.print("caught ");
}
finally
{
System.out.print("finally ");
}
System.out.println("after ");
}
}

The first statement within try is executed. Hence hello.


Then, the throwit() gets invoked. Hence the first statement throwit.
On creating RuntimeException object, it is caught and handled in the catch block. Hence caught.
Finally block is executed whether or not an exception is raised. Hence finally.
The statement that is independent of try will surely get executed. Hence after.

hello throwit caught finally after


Predict the output.
public class Sample {
public static void main(String args[]) {
try {
int i = 10,j=0,k=0;
System.out.println ("i="+i+" j="+j);
k = i / j;
System.out.println ("k=" + k);
}
catch(ArithmeticException e) {
System.out.println ("Divide by zero");
}
finally {
System.out.println ("finally block gets executed");
}
}
}
i=10 j=0
Divide by zero
finally block gets executed

Predict the output


class Parent{
public int display(String str, int... data)throws Exception{
String s = "(String, int[])";
System.out.println("Parent "+str + " " + s);
return 1;
}
}
class Child extends Parent{
public int display(String str, int... data){
String s = "(String, int[])";
System.out.println("Overridden: "+ str+" " +s);
return 0;
}

public static void main(String... args) {


try {
Parent sb = new Child();
sb.display("Welcome", 5);
}
catch(Exception e) {

}
}
}
Overridden: Welcome (String, int[])

class ProductNotFoundException extends Exception {


//Some code
}
class Shop {
public void findProduct(int productId) throws ProductNotFoundException {
//some code
throw new ProductNotFoundException();
//some code
}
}
class ABCShop{
public void findProductsList(){
new Shop().findProduct(101);
}
}
Which of the following statements are true for the above code?
This code will compile if we add a try-catch block in findProductsList().,

This code will compile if we add throws ProductNotFoundException in the signature of method
findProductsList().

The ________________ statement automatically closes all resources opened in the try clause.
Try with resources

Observe the code.


public class Sample {
public static void main(String args[]) {
int i=10,j=0,k;
try {
k=i/j;
}
catch(Exception e) {
System.out.println("Exception");
}
catch(ArithmeticException e) {
System.out.println("Arithmetic exception");
}
}
}
Predict the output.
Compilation Fails

An exception can be thrown explicitly by using the ________________ keyword.

Throw

When a code needs to be executed whether or not an exception occurs, that code can be written in _____ block.

Finally

Collection, Generics and Stream API


To use a class as a resource in try-with-resources that class should have implemented _____________ interface.
AutoClosable

IOException is a ______________________ exception


Checked

Which of the following is / are checked exceptions?


Exceptions whose handling is not verified during Compile time are unchecked exception and whose handling is
checked during compile time are checked exceptions.
FileNotFoundException,
ClassNotFoundException
Predict the output
public class Main {
public static void main(String arg[]){
System.out.println(display());
}
public static String display(){
try
{
}
catch(Exception e)
{
return "Welcome";
}
finally{
return "Hai";
}
}
}
When display method is invoked, the finally block gets executed whether or not an exception occurs. Hence it
returns "Hai".
Hai
In which version of Java was Try with multi catch introduced ?
Java 7
Which of the following is / are unchecked exceptions?
Exceptions whose handling is not verified during Compile time are unchecked exception and whose handling is
checked during compile time are checked exceptions.
NumberFormatException,
NullPointerException
Observe the following
Statement I : Multiple resources cannot be used in try-with-resource
Statement II : Code need not be written explicitly for closing the resources
Multiple resources can be used in try-with-resource;
Example :
try ( BufferedReader br = Files.newBufferedReader(some_path);
BufferedWriter w = Files.newBufferedWriter(some_path); )
{
//some code here
}
II alone is correct

Hands On - Collection, Generics and Stream API


int[] myArray = new int[] {1, 2, 3, 4, 5};
What allows you to create a list from this array?
List myList = Arrays.asList(myArray);

java.util.Map
interface provides the capability to store objects using a key-value pair ?

java.util.Map

Which two statements are true about the hashCode method?


The hashCode method for a given class can be used to test for object inequality, but NOT object equality, for
that class.,

The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into
hash buckets for swift retrieval.

Given:
11. public class Person {
12. private String name;
13. public Person(String name) {
14. this.name = name;
15. }
16. public int hashCode() {
17. return 420;
18. }
19. }
Which statement is true?
The time to find the value from HashMap with a Person key depends on the size of the map.

Given
1. import java.util.*;
2. public class WrappedString {
3. private String s;
4. public WrappedString(String s) { this.s = s; }
5. public static void main(String[] args) {
6. HashSet<Object> hs = new HashSet<Object>();
7. WrappedString ws1 = new WrappedString("aardvark");
8. WrappedString ws2 = new WrappedString("aardvark");
9. String s1 = new String("aardvark");
10. String s2 = new String("aardvark");
11. hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);
12. System.out.println(hs.size()); } }
What is the result?
3

ListIterator
nextIndex() and previousIndex() are methods of interface
ListIterator

Which of the following methods is / are available in Collections class?


shuffle,

binarySearch

Which of these are core interfaces in the Java collections framework?


Set<E>,

Collection<E>,

Map<K,V>
Observe the below code
List<Integer> markList = Arrays.asList(68,34,21,42,85,72,60);
markList.stream().filter((mark) -> mark > 60).sorted().forEach(System.out::println);
Which intermediate methods of stream API are used in the above code?
filter,

sorted

Assume we have a class Product as :


public class Product {
int productId;
String productName;
String productType
double price;
char category;
//few code
}
If the objects of Product are to be manipulated in a TreeSet and sort based on productType, price and category,
Comparator compare
the product class should implement interface and implement method.
Comparator

Compare

Choose the methods in Collection interface used to create a stream.


stream(),

parallelStream()

To traverse a collection using get(int index), it should be a collection of type ____________


List

State True or False.


When performing operations on a stream, it will affect the original stream.
False

Predict the output


Set set=new TreeSet();
set.add(9);
set.add(8);
Iterator it=set.iterator();
while(it.hasNext())
System.out.print(it.next()+” “);
89

Which interface should a class implement so that it can be sorted based on many fields / criteria?
Comparator

Predict the output


Map<String,String> map=new HashMap();
map.put("tina","Devpt");
map.put(null,"Test");
map.put(null,"Admin");
System.out.println(map);
{null=Admin, tina=Devpt}

Eclipse IDE
Which of the following options remain true for case constants in a switch construct?

If no case matches but there is a default label, then all statements after the matching default label in the switch
block are executed in sequence,

The code with the switch construct gives a compilation error when there is a duplicate case label,

If any one of the case constants has a match with the expression, then all statements after the matching case
label in the switch block are executed in sequence

Predict the output


int a=0;
if(a)
System.out.println( "Hello");
else
System.out.println( "Hai");
Compilation Fails

__________ generates the byte code for a given file with .java extension.
JDK

Which edition of java is used for developing web application?

J2EE

State True or False


For compiling a java code we have separate compilers for different OS.
False

What will be the output of the program?


public class Sample
{
public static void main(String [] args)
{
int i = 10;
do while ( i < 10 )
System.out.print("The value of i is " + i);
while ( i > 10 ) ;
}
}
No output is produced.

In a nested for loop, the continue statement in an inner loop can be used to bypass the current iteration of
outerloop .
False

Who executes the byte code in java?

JVM

State True or False.


When typing the code in code editor, it fixes the compilation error. It also assists in how to fix that error.

True

We can move an already existing project in eclipse to another location by compressing it. This we call as
________ the project.
Exporting

A project developed on one machine can be included in the current workspace by ___________ that project.
Importing

In Eclipse, the plugin that is needed for Java Development is ______________.


JDT
RDBMS

RDBMS Concepts
Information is stored in flat files which are maintained by the file system under the _____ control.

Operating system

Database approach is the representation of complex relationships between data.

True

"Software that enables users to define, create and maintain the database and provides controlled access to the
database."

DBMS

In traditional approach, _____ go through the file system in order to access flat files.

Application programs

"A shared collection of logically related data, designed to meet the needs of an organization is called as _________.”

Database

In hierarchical data model, data is represented by a ______ structure.

tree

In which model is data represented by records and pointers?

network

Which user interacts with the system by forming their requests in a database query language?

Specialized User

Which user interacts with the system by invoking one of the permanent application programs that have been written
previously?

End users

A data model is a way of explaining the logical layout of the data and the relationship of various parts to each other
and the whole.

True

Which data model is more flexible and easy to use?

Relational

SQL statements are case sensitive.

False

SQL is an ANSI standard computer language for accessing and manipulating database systems.

True

________ defines the structure of the table.

DDL

What data type is used to store Fixed length character data?

char
Table name can have only letters, numbers and underscore.

True

what are all the DDL commands?

Alter

Rename

Which data type is used to store both integer and float value?

number

Primary key is the combination of _____ and _____.

not null, unique

Constraints are the rules enforced on data columns on the table.

True

Foreign key is used to enforce the link between tables.

True

A table can have ______ primary key.

In which built in table are the constraint names stored?

user_constraints

When a table is linked with other table it can be truncated.

False

What command is used to change the structure of the table?

Alter

Can we drop a table or a column from a table which has a primary key?

Yes

User cannot override the default constraint name with the user defined constraint name.

False

Column level constraints are applied to _____ column.

Data for date, char and varchar types should be always enclosed within single quotes.

True

What command is used to delete the data from the table without deleting the table structure?

delete

Select DML commands.

delete

update
Deletion is not possible if the row to be deleted is referred in the child table.

Yes

which command is used to modify existing rows?

Update

Truncate removes all rows from the table and cannot be reverted back

True

The MERGE statement is deterministic.

Yes

_______ provides the ability to conditionally update or insert data into a database table.

Merge

_______ is performed automatically and requires no user action.

Locking

Transaction should end with either commit or rollback.

Yes

DML commands are by default auto commit.

False

Deleted record can be retrieved back by using ________ command.

Rollback

Which SQL statement is used to fetch the data from a database table?

SELECT

Which query will return all the rows and columns from the table?

Select * from table_name

Arithmetic expressions cannot be used in SELECT statement.

False

Which operator is used to concatenate columns or character strings?

||

In SELECT statement, alias name should be in double quotes, if it contains more than ____ word.

one

SQL Statements are _______, but the data stored in the database is _______.

case insensitive/case sensitive

SELECT statement can be used for retrieving only specific values from the table.

False

Which clause is used to extract only those records that fulfil a specific condition?

WHERE
Which keyword in the SELECT clause is used to eliminate duplicate rows?

DISTINCT

Which clause is used to retrieve the data in ascending order?

ORDER BY

Which query is used to get the current date?

select sysdate from dual;

Single-row functions can be nested to any level and nested functions are evaluated from the deepest level to the
least deep level.

TRUE

Which character function returns specified characters from the character value starting at character position m, n
characters long?

substr()

Which number function returns the largest integer value that is equal to or less than a number?

floor()

Which date function is used to add calendar months to date?

add_months

Which function compares two expressions and returns null if they are equal or the first expression if they are not
equal?

NULLIF()

Which function returns the first not null expression in the expression list?

COALESCE()

Which conditional expression facilitates conditional inquiries by doing the work of a CASE or IFTHEN- ELSE
statement?

Decode function

Which conditional expression facilitates conditional inquiries by doing the work of an IF-THEN-ELSE statement.

Case expression

We can use the group functions to return summary information for each _____.

group

The ______ clause divides the rows in a table into groups.

GROUP BY

Group function can be used in where clause.

False

All columns in the SELECT list must be in the GROUP BY clause apart from the group function.

True

When you join a table without any condition, it will lead to Cartesian product.

True
When two tables are joined using operator in the join condition it is called as _________.

equi join

A ______ is a join condition containing something other than an equality operator.

non equijoin

Which clause is used to combine records from two or more tables, based on a common field between them?

JOINS

All rows in the first table joined to all rows in the second table is called a Cartesian product.

True

The _____ returns all rows from both the tables.

FULL OUTER JOIN

“The ______ returns all the rows from the left table, with the matching rows in the right table.”

LEFT OUTER JOIN

“The ____ returns all the rows from the right table, with the matching rows in the left table.”

RIGHT OUTER JOIN

“____________ returns rows only when there is at least one row from both the tables that matches the join
condition.”

equi join

“________ returns all the rows from one of the tables mentioned in the FROM clause even if the condition is not
matched.”

outer join

________ is a type of EQUI JOIN that compares the common columns of both the tables with each other.

NATURAL JOIN

________ joins the table to itself. It is done by creating alias names for the same table.

self join

________ clause specifies which columns to test for equality when two tables are joined.

USING

Single row subquery returns ________ row.

one

<ANY means _____________.

Less than the maximum

A subquery is a query that is nested inside a SELECT, INSERT, UPDATE, or DELETE statement, or inside another
subquery is done the subquery result the main query will be executed.

TRUE

Operators used in multiple row subqueries are ________.

any
in

Operators used in single row subqueries are ________.

<>

The subquery returns a temporary table in the database server’s memory and then it is not only used by the outer
query for further processing.

False

When you insert a select statement into a FROM clause, it becomes a subquery.

True

________ subquery that uses values from the outer query.

Correlated subquery

which is used to create privileges to allow users to access and manipulate the database?

DCL

which command is used to remove a privilege from a user?

REVOKE

which command is used to give privilege to the user?

GRANT

which view derived data from only one table?

simple view

which view does not always allow DML operations through the view?

Complex view

we can insert update or delete the records from the original table using Complex view.

no

You cannot remove a row if the view contains _______, ______ and _______:
Group functions
GROUP BYClause

An inline view is a subquery with an alias that can be used within an SQL statement.

True

“_____ is a virtual table that provide a view a window through which one can see data (stored in a base relation).”

View

Views contain no data of their own but can be operated on as real relations.

True

________ generate unique numbers automatically.

Sequence

which is used to create an alias name?


Synonym

NEXTVAL returns a unique value every time it is referenced, even for different users.

yes

_______ create an index which sorts the data file in the order of the index file.

Clustered Index

_______ is used by the Oracle service to speed up the retrieval of rows by using a pointer.

Index

Index can be created if a column contains a wide range of values.

yes

Which of the following are DML statements?


SELECT,

INSERT

Which of the following are data models?


Hierarchical,

Network,

Relational

Which of the following represents the degree of the relation?


No of Attributes

Database is a shared collection of logically unrelated data, designed to meet the needs of an organization. State
True or False.
FALSE

Which of the following are considered as constraints?


NOT NULL,

Unique,

Check

Which of the following is not a valid relational database?


Unify

Choose Correct Option

Data is represented in the form of a table - relational


Answer 1
Data is represented in the form of a graph - network
Answer 2
Data is represented in the form of a tree - hierarchical
Answer 3
Data is represented in the form of a table - → relational,
Data is represented in the form of a graph - → network,
Data is represented in the form of a tree - → hierarchical
SQL is a case sensitive language and the data stored inside the table are case in-sensitive. Say true or false?
False
Terms of Relational

______ refers to the rows of the table Tuples


Answer 1
________ refers to number of rows in the table cardinality
Answer 2
______ refers to the columns of the table Attribute
Answer 3
_______ refers to the range of values that can be stored for an attribute Domain
Answer 4
_______ refers to number of columns in the table Degree
Answer 5
______ refers to the rows of the table → Tuples,

________ refers to number of rows in the table → cardinality,

______ refers to the columns of the table → Attribute,

_______ refers to the range of values that can be stored for an attribute → Domain,

_______ refers to number of columns in the table → Degree

Tom has designed a payroll software for XYZ technology.The software will store the salary details into the
database and later he can retrieve the same for future references. Tom falls under which category of user.

Application Programmer

Data Definition Language


_____ is called as meta data.
Data Dictionary

A relational database consists of a collection of


Tables

Column header is referred as


Attributes

Which of the following is not modification of the database


Sorting

In a relational database a referential integrity constraint can be done using


foreign key

An emp table contains fields employ name, desig and salary. How do you drop column salary?
alter table emp drop column salary;

Choose the correct option

validitydate not null


Answer 1
cardholdername not null
Answer 2
creditcardno primary key
Answer 3
cardholderphoneno unique
Answer 4
creditcardtype should be silver or platinum only check
Answer 5
validitydate → not null,

cardholdername → not null,

creditcardno → primary key,


cardholderphoneno → unique,

creditcardtype should be silver or platinum only → check

Which of the following options is not correct?


alter table emp drop column_name;

We need to ensure that the amount withdrawn should be less then the credit card limit amount, to ensure this
integrity what type constraint will be used?
table level check constraint

How would you add a foreign key constraint on the dept_no column in the EMP table, referring to the id
column in the DEPT table?
Use the ALTER TABLE command with the ADD clause on the EMP table.

A table consists of ______ primary keys.


1

Tom , the administrator gets an error when executing the following scripts in the Oracle server. He finds that the
SQL statements placed are not in the correct order.
Help Tom to place the statements in the correct order. The script starts from the creation of course table. The
schema diagram is given below

• CREATE TABLE course


(
courseid char(4) primary key,
coursename varchar2(40),
coursecategory varchar2(20),
coursefees number(10,2),
courseduration number(3)
);
• CREATE TABLE student
(
sid char(4) primary key,
sname varchar2(20),
sdob date,
scity varchar2(20),
squal varchar2(20),
semail varchar2(30),
sphone varchar2(20)
);
• CREATE TABLE batch
(
batchid char(4) primary key,
bsdate date ,
bstrength number(3),
courseid char(4),
foreign key(courseid) references course(courseid)
);
• CREATE TABLE enrollment
(
batchid char(4),
sid char(4) ,
edate date,
primary key(batchid,sid),
foreign key(sid) references student(sid),
foreign key(batchid) references batch(batchid)
);

Tom, the administrator should create the table "CSR_Registration" with the following rules

• Whenever a row in the CSR_Student table is deleted, the row from the CSR_Registration must be deleted
• When deleting the row from the CSR_course table link column of the CSR_registration must be made to
null
• Drag and drop the correct keyword for the below given query.

• create table CSR_registration(courseid number(4) references


on delete set null
CSR_course(courseid) ,studid number(4) references
on delete cascade
CSR_student(studid) ,doj date);
on delete set null

on delete cascade

Data Manipulation Language


To permanently remove all the data from the STUDENT table, and you need the table structure in the future.
Which single command performs this?
TRUNCATE TABLE student;
Which CREATE TABLE statement is valid?

CREATE TABLE ord_details


(ord_no NUMBER(2),
item_no NUMBER(3),
ord_date DATE DEFAULT SYSDATE NOT NULL,
CONSTRAINT ord_pk PRIMARY KEY (ord_no,item_no));

The EMPLOYEES table has these columns:


LAST NAMEVARCHAR2(35)
SALARYNUMBER(8,2)
HIRE_DATEDATE
Management wants to add a default value to the SALARY column. You plan to alter the table by
using this SQL statement:
ALTER TABLE EMPLOYEES
MODIFY (SALARY DEFAULT 5000);
What is true about your ALTER statement?
A change to the DEFAULT value affects only subsequent insertions to the table.

Which statement would you use to add a primary key constraint to the patient table using the id_number column,
immediately enabling the constraint?

ALTER TABLE patient


ADD CONSTRAINT pat_id_pk PRIMARY KEY(id_number);

When we attempt to create the salary table with this command:


1.CREATE TABLE salary
2.(employee_id NUMBER(9)
3.CONSTRAINT salary_pk PRIMARY KEY,
4.1995_salaryNUMBER(8,2),
5.manager_name VARCHAR2(25)
6.CONSTRAINT mgr_name_nn NOT NULL,
7.$salary_96NUMBER(8,2));
Which two lines of this statement will return errors?
7, 4

Examine the structure of the Employee table:


Column Name DataType Constraint
Empname Varchar2(20) Not Null
EmpId Number(10) PK
Phoneno Number(10) NotNull
DeptId Number(10) FK

Data in the Department table:


DeptId Dname Location
1 Sales Mumbai
2 Marketing Kolkata
Which update statement produces the following error?
ORA-02291: integrity constraint (SYS_C23) violated - parent key not found

UPDATE Employee SET Deptid=3 WHERE Empid = 101;

DELETE FROM dept WHERE dept_id = 901;


The above delete statement throws an integrity constraint error because a child record was found. What could
we do to make the statement execute?

Delete the child records first.

Consider the below table structure:


Column Name DataType Constraint
Empname Varchar2(20) Not Null
EmpId Number(10) PK
Phoneno Number(10) NotNull
insert into employee(empid,empname)values('123','John');
When we issue the above insert command and if the statement fails,
what would be the reason.
Value for phoneno is missing.

Which SQL statement needs both insert and update privilege on the target table and select privilege on the
source table?
merge

Examine the structure of the STUDENT table:


Column Name DataType Constraint
Stud_id Number(3) PK
Name Varchar2(20) NotNull
Address Varchar2(30)
DOB Date
Which statement inserts a new row into the STUDENT table?

INSERT INTO student (stud_id, address, name, dob)


VALUES (101,'100 Main Street','Smith','17-JUN-99');

blank statement/command would not cause a transaction to end

select

Match appropriately.
Drop Removes the table itself from the database.
Answer 1
Delete Removes all or only the rows specified from the table.
Answer 2
Truncate Removes the entire data from the table, while the structure remains intact.
Answer 3
Drop → Removes the table itself from the database.,

Delete → Removes all or only the rows specified from the table.,

Truncate → Removes the entire data from the table, while the structure remains intact.

It is possible to update more than one column with a single UPDATE statement. State true or false.
True
To have all the rows deleted from the table using delete statement, you must specify the query with WHERE
clause that specifies all the rows. State true or false.
False

ALTER TABLE
To change the structure of the table we use Syntax.

ALTER TABLE

Select Statement
You need to remove all the data from the employee table while leaving the table definition intact.
You want to be able to undo this operation. How would you accomplish this task?

DELETE FROM employee;

Which statement is true when a DROP TABLE command is executed on a table?


The table structure and its deleted data cannot be rolled back and restored once the DROP TABLE command is
executed.

Which statements are true regarding constraints?


A constraint can be disabled even if the constraint column contains data.,

A columns with the UNIQUE constraint can contain NULL values.

The SQL statements executed in a user session as follows:


create table product(pid number(10),pname varchar(10));
Insert into product values(1,'pendrive');
Insert into product values(2,'harddisk');
savepoint a;
update product set pid=20 where pid=1;
savepoint b;
delete from product where pid=2;
commit;
delete from product where pid=10;
Which statements describe the consequence of issuing the ROLLBACK TO SAVE POINT a command in the
session?

No SQL statements are rolled back., The rollback generates an error.

Which statement about SQL is true?


Null values are displayed last in ascending sequences.

How to retrieve department_id column without any duplication from employee relation?
select distinct department_id from employee;

Select the suitable option for retrieving all the employees who have a manager?
select empname, manager_id from employee where manager_id is NOT NULL;

Select the suitable option for retrieving all the employees whose salary range is between 40000 and 100000?
select name,salary from employee where salary between 40000 and 100000;,

select name,salary from employee where salary>=40000 and salary<=100000;

Select the missing keyword, to complete the select query for the given scenario
select the student details whose firstname starts with 'A' or whose city is 'Chennai' and firstname ends with 'n'
OR AND
select * from CSR_STUDENT where firstname like 'A%' city ='Chennai' firstname like
'%n';
OR

AND

Select the suitable option for retrieving all the employees whose last name is "kumar"?
select * from employee where empname like '%kumar';

View the Exhibit and examine the structure of the PROMOTIONS table. You need to generate a report of all
promos from the PROMOTIONS table based on the following conditions:
1. The promo name should not begin with 'T' or 'N'.
2. The promo should cost more than $20000.
3. The promo should have ended after 1st January 2001.
Rearrange the WHERE clause to obtain the required result?

• WHERE promo_name
• (NOT LIKE 'T%' OR
• NOT LIKE 'N%')
• AND promo_cost > 20000 AND promo_end_date >
• '1-JAN-01'

Observe this table.


The above query produces an error on execution. What is the reason for the error?
An alias cannot be used in an expression

The SELECT statement is used to describe the table and the table data from a database. State true or false.
False

blank should be used if you want to select all the fields available in the table.

Which of the following are the correct syntaxses for displaying the StudentName and Department from Student
table?

SELECT STUDENTNAME, DEPARTMENT FROM Student;,

select studentname, department FROM Student;,

SELECT StudentName, Department FROM Student;,

select studentname, department FROM STUDENT;

Function - Scalar & Aggregate


To generate a report that shows an increase in the credit limit by 15% for all customers. Customers whose
credit limit has not been entered should have the message "Not Available" displayed.
Which SQL statement would produce the required result?
SELECT NVL(TO_CHAR(cust_credit_limit*.15),'Not Available') "NEW CREDIT"
FROM customers;

To display the names of employees that are not assigned to a department.

Evaluate this SQL statement:

SELECT last_name, first_name

FROM employee

WHERE dept_id = NULL;

Which change should you make to achieve the desired result?

Change the operator in the WHERE condition.

Generate a list of all customer last names with their credit limits from the CUSTOMERS table. Customers who do
not have a credit limit should appear last in the list. kindly note that customers who do not have credit card will
have NULL against credit limit.
Which query would achieve the required result?
SELECT cust_last_name,cust_credit_limit
FROM customers
ORDER BY cust_credit_limit;
ABC company wants to give each employee a $100 salary increment. You need to evaluate the
results from the EMP table prior to the actual modification. If you do not want to store the results in the
database, which statement is valid?
You need to give the arithmetic expression that involves the salary increment in the DISPLAY
clause of the SELECT statement.

Select the suitable option for fetching the output of the following query. select substr("Oracle World",1,6) from
dual;

Oracle

To calculate the number of days from 1st Jan 2007 till date:
Dates are stored in the default format of dd-mm-rr.
Which SQL statements would give the required output?
SELECT SYSDATE - TO_DATE('01/JANUARY/2007') FROM DUAL;,

SELECT SYSDATE - TO_DATE('01-JANUARY-2007) FROM DUAL;

Which statement is true regarding the default behavior of the ORDER BY clause?
In a character sort, the values are case-sensitive

To display the names of all promos done after January

1, 2001 starting with the latest promo.

Which query would give the required result? (Choose all that apply.)

SELECT promo_name,promo_begin_date "START DATE"


FROM promotions
WHERE promo_begin_date > '01-JAN-01'
ORDER BY "START DATE" DESC;,

SELECT promo_name,promo_begin_date
FROM promotions
WHERE promo_begin_date > '01-JAN-01'
ORDER BY 2 DESC;

The CUSTOMERS table has these columns:


CUSTOMER_ID NUMBER(4) NOT NULL
CUSTOMER_NAME VARCHAR2(100) NOT NULL
CUSTOMER_ADDRESS VARCHAR2(150)
CUSTOMER_PHONE VARCHAR2(20)
You need to produce output that states "Dear Customer customer_name, ".
The customer_name data values come from the CUSTOMER_NAME column in the
CUSTOMERS table.
Which statement produces this output?
SELECT 'Dear Customer ' || customer_name || ',' FROM customers;

To update the CUST_CREDIT_LIMIT column to NULL for all the customers, where
CUST_INCOME_LEVEL has NULL in the CUSTOMERS table. Which SQL statement will
accomplish the task?
UPDATE customers
SET cust_credit_limit = NULL
WHERE cust_income_level IS NULL;
Select the suitable option for displaying the average commission percentage of all employees, where the
commission percentage column of certain employees include NULL value.

select AVG(NVL(commission_pct,0)) from emp;

All columns in the SELECT list that are not in group functions must be in the GROUP-BY clause. State True or
False.
TRUE

SELECT lot_no "Lot Number", COUNT(*) "Number of Cars Available"


FROM cars
WHERE model = 'Fire'
GROUP BY lot_no
HAVING COUNT(*) > 10
ORDER BY COUNT(*);
In the above statement which clause restricts which groups are displayed?
HAVING COUNT(*) > 10

Evaluate these two SQL statements:


1. SELECT CONCAT(first_name, last_name),
LENGTH(CONCAT(first_name, last_name))
FROM employee
WHERE UPPER(last_name) LIKE '%J'
ORUPPER(last_name) LIKE '%K'
ORUPPER(last_name) LIKE '%L';
2. SELECT INITCAP(first_name) || INITCAP(last_name),
LENGTH(last_name) + LENGTH(first_name)
FROM employee
WHERE INITCAP(SUBSTR(last_name, 1, 1)) IN ('J', 'K', 'L');
How will the results differ?
The statements will retrieve different data from the database.

The PART table contains these columns:


ID NUMBER(7) PK
COST NUMBER(7,2)
PRODUCT_ID NUMBER(7)
Evaluate these two SQL statements:
1.SELECT ROUND(MAX(cost),2),
ROUND(MIN(cost),2),ROUND(SUM(cost),2),
ROUND(AVG(cost),2)
FROM part;
2.SELECT product_id, ROUND(MAX(cost),2),
ROUND(MIN(cost),2),ROUND(SUM(cost),2),
ROUND(AVG(cost),2)
FROM part
GROUP BY product_id;
How will the results differ?
Statement 1 will only display one row of results; statement 2 could display more than one.

Group functions can be used in the where clause. State True or False.
FALSE

We need to create a report to display the order id, ship date and order total of your ORDER table. If the
order has not been shipped, your report must display 'Not Shipped'. If the total is not available,
your report must display 'Not Available'.
In the ORDER table, the SHIPDATE column has a datatype of DATE. The TOTAL column has a
datatype of INT.
Which statement do you use to create this report?
SELECT ordid, IFNULL(shipdate, 'Not Shipped') SHIPDATE,
IFNULL(total,'Not Available')TOTAL FROM order;

We need to analyze how long your orders take to be shipped from the date that the order is
placed. To do this, you must create a report that displays the customer number, date ordered, date
shipped, and the number of months in whole numbers from the time the order is placed to the time
the order is shipped. Which statement produces the required results?
SELECT custid, orderdate, shipdate,
ROUND(MONTHS_BETWEEN (shipdate, orderdate))
"Time Taken" FROM ORD;

Single row functions can be nested to any level. State true or False.

TRUE

Rearrange and display the correct order of execution of a query.

• from
• where
• group by
• having
• select
• order by

Single row function accepts only a single argument. State true or false.
False

You need to generate a report that displays the IDs or all products in the COSTS table whose unit price is at least
25% more than the unit cost. The details should be displayed in the descending order of 25% of the unit cost.
You issue the following query:

• SELECT prod_id
• FROM costs
• WHERE unit_price >= unit_cost*1.25
• ORDER BY unit_cost*0.25 DESC;

Using the CUSTOMERS table, you need to generate a report that shown the average credit limit for customers in
WASHINGTON and NEW YORK. Which SQL statement would produce the required result?
SELECT cust_city,AVG(cust_credit_limit) FROM customers WHERE cust_city IN ('WASHINGTON','NEW YORK')
GROUP BY cust_city;
ORDER BY must be the clause in the SELECT statement. You specify any combination of numeric positions
and column names in the order by clause.

Last

can

Joins & Subquery


Which statements are true regarding the USING and ON clauses in table joins?

The ON clause can be used to join tables on columns that have different names but compatible data types.,

The WHERE clause can be used to apply additional conditions in SELECT statement
containing the ON or the USING clause.

To create a report displaying employee last names, department names, and locations. Which query should you
use to create an equi-join?

SELECT e.last_name, d.department_name, d.location_id


FROM employees e, departments d
WHERE e.department_id =d.department_id;

SELECT cust_city. COUNT(cust_last_name)


FROM customers
WHERE cust_credit_limit > 1000
GROUP BY cust_city
HAVING AVG(cust_credit_limit) BETWEEN 5000 AND 6000;
Which statement is true regarding the outcome of the above query?

It executes successfully.

To display the names of employees who earns more than the average salary of all
employees.
SELECT last_name, first_name
FROMemployee
WHEREsalary > AVG(salary);
Which change should you make to achieve the desired results?

Use a subquery in the WHERE clause to compare the average salary value.

The COMMISSION column shows the monthly commission earned by the employee.
Emp_Id Dept_Id Commission
1 10 500
2 20 1000
3 10
4 10 600
5 30 800
6 30 200
7 10
8 20 300

Which tasks would require sub queries or joins in order to be performed in a single
step?

Listing the employees who earn the same amount of commission as employee 3,

Finding the number of employees who earn a commission that is higher than the average commission of the
company

Which statements would execute successfully?

SELECT SUM (DISTINCT NVL(subject1,0)),MAX(subject1)


FROM marks
WHERE subject1 > subject2;,

SELECT SUM (subject1+subject2+subject3)


FROM marks
WHERE student_name IS NULL

Which statement would display the highest credit limit available in each income level in each city in the
Customers table?
SELECT cust_city, cust_income_level,MAX(cust_credit_limit)
FROM customers
GROUP BY cust_city, cust_income_level;

The following query is written to retrieve all those product IDs from the SALES table that have more than 55000
sold and have been ordered more than 10 times:
SELECT prod_id FROM sales WHERE quantity_sold > 55000 AND COUNT(*)>10
GROUP BY prod_id HAVING COUNT(*)>10;
Which statement is true regarding this SQL statement?
It produces an error because COUNT (*) should be only in the HAVING clause and not in the
WHERE clause.

Which SQL statement produces an error?


None of the statements produce an error; all are valid.

Consider the below tables:


Promotions Table
Column Name Datatype Constraint
Promo_id Number PK
Promo_name Varchar
Promo_begin_date Date
Promo_end_date Date
Sales Table
Column Name Datatype Constraint
Promo_id Number FK
Cust_id Number FK
Time_id Date
Customer Table
Column Name Datatype Constraint
cust_id Number PK
cust_name Varchar
The Below query will generate a report showing the promo name along with the
customer name for all products that were sold during their promo campaign and before 30th October 2007.
SELECT promo_name,cust_name FROM promotions p JOIN sales s
ON(time_id BETWEEN promo_begin_date AND promo_end_date)
JOIN customer c ON (s.cust_id = c.cust_id) AND time_id < '30-oct-2007';
Which statement is true regarding the above query?

It executes successfully but does not give the required result.

Which operator is NOT appropriate in the join condition of a non-equi join SELECT statement?

equal operator

Evaluate this SQL statement:


SELECT first_name, commission
FROM employee
WHERE commission =
(SELECTcommission
FROMemployee
WHEREUPPER(first_name) = 'SCOTT')
What would cause this statement to fail?

There is more than one employee with the first name Scott.

Consider the following table:


Product Table
Column Name DataType Constraint
prod_name Varchar2(20)
prod_id Number(10) PK
Customer Table
Column Name DataType Constraint
cust_last_name Varchar2(20)
cust_id Number(10) PK
cust_city Varchar2(20)
Sales Table
Column Name DataType Constraint
prod_id Number(10) FK
cust_id Number(10) FK
quantity_sold Number(10,2)
Generate a report that gives details of the customer's last name, name of the product and the quantity sold for
all customers in 'Tokyo'.
Which two queries give the required result? (Choose two.)
SELECT c.cust_last_name,p.prod_name,s.quantity_sold
FROM sales s JOIN products p
USING (prod_id)
JOIN customers c
USING (cust_id)
WHERE c.cust_city='Tokyo';,

SELECT c.cust_last_name,p.prod_name,s.quantity_sold
FROM products p JOIN sales s
ON(p.prod_id=s.prod_id)
JOIN customers c
ON(s.cust_id=c.cust_id)
WHERE c.cust_city='Tokyo';

The NOT operator can be used with ______ operators.


IN,

ANY,

ALL

In which two cases would you use the USING clause? (Choose two)
The tables to be joined have columns of the same name and different data types.,

The tables to be joined have columns with the same name and compatible data types.

Which SELECT statement displays all the employees who do not have any subordinates?
SELECT e.ename
FROM emp e
WHERE e.empno NOT IN (SELECT m.mgr
FROM emp m
WHERE m.mgr IS NOT NULL);

Consider the below tables:


Employee Table
Column Name DataType Constraint
Name Varchar2(20)
Empno Number(10) PK
salary Number(10,2)
Tax Table
Column Name DataType Constraint
Taxgrade Number
Lowsal Number(10)
highsal Number(10,2)
We want to create a report that displays the employee details along with the tax category of each employee.
The tax category is determined by comparing the salary of the employee from the EMP table to the lower and
upper salary values in the TAX table.
Which SELECT statement produces the required results?
SELECT e.name, e.salary, t.taxgrade
FROM emp e, tax t
WHERE e.salary BETWEEN t.lowsal AND t.highsal;

In which cases would you use an outer join?


The tables being joined have both matched and unmatched data.

SELECT last_name, first_name


FROM employee
WHERE salary IN
(SELECT salary
FROM employee
WHERE dept_no = 3 OR dept_no = 5);
Which values are displayed?

last name and first name of all employees with the same salary as employees in department 3 or 5

To display the names of employees who earns more than the average salary of all
employees.
SELECT last_name, first_name
FROMemployee
WHEREsalary > AVG(salary);
Which change should you make to achieve the desired results?

Use a subquery in the WHERE clause to compare the average salary value.

.
You issue the following SQL statement on the CUSTOMERS table to display the customers who are in the same
country as customers with the last name 'king' and whose credit limit is less than the maximum credit limit in
countries that have customers with the last name 'king'.

. Which
statement is true regarding the outcome of the above query?

It executes and shows the required result.

Rearrange the statement so as to obtain the names of products whose list price is the second highest in the
table

• SELECT prod_name FROM products


• WHERE prod_id IN(
• SELECT prod_id FROM products
• WHERE prod_list_price=(
• SELECT MAX(prod_list_price) FROM products
• WHERE prod_list_price<
• (SELECT MAX(prod_list_price) FROM products)));

Where can subqueries be used?

Field names in the SELECT statement.,

The FROM clause in the SELECT statement,

The HAVING clause in the SELECT statement,

The WHERE clause in the SELECT as well as all DML statements

The NOT operator can be used with IN, ANY, and ALL operators in multiple-row subqueries. State true or false.

True

different
Main query and subquery can/must get data from tables.

Different

Data Control Language & Database Objects


Consider the below tables:
Customer Table
Column Name Datatype Constraint
custNo Number PK
custname Varchar
custaddress varchar
Cust_credit_limit Number
Grade Table
Column Name Datatype Constraint
Grade Varchar
Startval Number
Endval Number
To display names and grades of customers who have the highest credit limit.
Which SQL statements would accomplish the task?

SELECT custname, grade


FROM customers, grades
WHERE cust_credit_limit = (SELECT MAX(cust_credit_limit)
FROM customers)
AND cust_credit_limit BETWEEN startval AND endval;,

SELECT custname, grade


FROM customers, grades
WHERE (SELECT MAX(cust_credit_limit)
FROM customers) BETWEEN startval and endval
AND cust_credit_limit BETWEEN startval AND endval;

The _______ join produces the cross product of two tables.


Cross

Equijoin is called as ______.


Simple Join

Mr. John is the president of a company. Five managers report to him. All other employees report to these
managers.
Examine the code:
SELECT employee.ename FROM emp employee
WHERE employee.empno NOT IN (SELECT manager.mgr
FROM emp manager);
The above statement returns no rows selected. as the result. Why?

A NULL value is returned from the subquery.

The _______ join is based on all columns in the two tables that have the same column name.
Natural

To delete rows from the SALES table, where the PROMO_NAME column in the
PROMOTIONS table has either blowout sale or everyday low price as values.
Which DELETE statements are valid? (Choose all that apply.)

DELETE
FROM sales
WHERE promo_id = (SELECT promo_id
FROM promotions
WHERE promo_name = 'blowout sale')
OR promo_id = (SELECT promo_id
FROM promotions
WHERE promo_name = 'everyday low price');,

DELETE
FROM sales
WHERE promo_id IN (SELECT promo_id
FROM promotions
WHERE promo_name = 'blowout sale')
OR promo_name = 'everyday low price';,

DELETE
FROM sales
WHERE promo_id IN (SELECT promo_id
FROM promotions
WHERE promo_name IN ('blowout sale','everyday low price'));

Joining a table to itself is called as ______.


Self Join

Consider the below orders table:


Column Name Datatype Constraint
order_id Number PK
Order_date Date
Order_mode varchar
Customer_id Number
Order_total Number(8,2)
There is only one customer with the CUST_LAST_NAME column having value Roberts. Which INSERT statement
should be used to add a row into the ORDERS table for the customer whose CUST_LAST_NAME is Roberts and
CREDIT_LIMIT is 600?

INSERT INTO orders VALUES( 1,'10-mar-2007','direct', (SELECT customer_id FROM


customers WHERE cust_last_name ='Roberts' AND
credit_limit =600) ,1000 );

_____ is used to retrieve records that do not meet the join condition
Outer Join

Consider the below table:


Products Table
Column Name Datatype Constraint
Prod_id Number PK
Prod_name Varchar
Prod_list_price varchar
Cust_credit_limit Number
What would be the outcome of executing the below SQL statement?
select prod_name from products where prod_id in(
select prod_id from products where prod_list_price=(
select max(prod_list_price) from products where prod_list_price<(
select max(prod_list_price)from products)));
It shown the names of products whose list price is the second highest in the table

Which SQL statement would you use to remove a view called EMP_DEPT_VU from your schema?
DROP VIEW emp_dept_vu;

Which object privileges can be granted on a view?


DELETE, INSERT, SELECT, UPDATE

You need to create the patient_id_seq sequence to be used with the patient table's primary key column. The
sequence should begin at 1000, have a maximum value of 999999999, never reuse any numbers, and increment
by 1.
Which statement would you use to complete this task?

CREATE SEQUENCE patient_id_seq


START WITH 1000
MAXVALUE 999999999
NOCYCLE;

A/an ______ index is based on expressions.


Function Based

The owner has all the privileges on the object. State true or False.
True

An owner can give specific privileges on the owner's objects to others. State...
True

CREATE INDEX emp_dept_id_idx


ON employee(dept_id);
Which of the following statements are true with respect to the above index?

May reduce the amount of disk I/O for SELECT statements.

Which SQL statement grants a privilege to all the database users?


grant select on department to PUBLIC;

Web Technology
In the login page, the user does not enter the password and gets an error

"Password cannot be empty". This scenario is an example for:

Static page

Which of the following is true about Client Side Scripting?

Generates content based on the user input in client machine

_________ can be referred as an html document displayed as a single page in a browser.

Web page

The term "internet" is also called as "internet super highway". state true or false.

False

______ is called as an area of www that is identified by its own address.

Website

Choose the correct HTML tag for the largest heading.

<h1>

Which of the following is the comment line in HTML5?

<!-- -->

When the user clicks on a sign up image, the login page should be displayed in the same window. Which of the
following options will do this?

<a href="newpage.html" target="_self"><img src="signup.png"></img></a>

In the webpage, we have an image to be displayed on the left corner of the webpage. Certain browsers might not
support the image, and in that case a message should be displayed as "Image cannot be displayed". Which of the
following will suit the above requirement?

<img src="image.png" alt="Image cannot be displayed"></img>

Consider the given code snippet:

<body>

<form action="success.html">

User Name <input type="text" name="uname"/> <input type="submit" value="Login"/> <input type="reset"
value="reset"/> </form></body>

Password <input type="password" name="password"/>

What is the use of form tag in HTML?

To collect user’s input

Which of the following form inputs is used to send information to theserver?

<!doctype html>

Which attribute allows you to specify your browser to complete the input based on what you may have been
entered in the browser previously?
autocomplete

The default input type in HTML5 is text. State True or False.

True

Which of the following is true about 'audio' tag in HTML5?

Both

The current HTMLS draft specification does not specify the types of audio formats that browsers should support in
the audio tag.

HTML5 supports-audio> tag which is used to embed sound content in an HTML or XHTML document.

Select the correct element to show a video on a web page

<video src=”filename.ext” controls=”controls”></video>

Which of the following form inputs is used to send information to the server?

<input type="submit">

Which of the following input fields allow the user to select multiple values?

datalist

Checkbox

Select the Doctype that should be specified at the top of all HTML5 documents.

<!doctype html>

To display the text as in default font style, which of the following styles should be apply?

font-style:normal;

CSS selectors are used to select element(s) to apply different styles. State true or false.

True

choose the appropriate inline CSS font style to display the given text in cursive.

<h1 style=”font-family:cursive”>Welcome</h1>

which of the following code snippet will display a square box in the web page?

<html>

<head>

<style type=”text/css”>div

height: 100px;

width: 100px;

background:blue;

</style>

</head>
<body>

<div>square></div>

</body>

</html>

Consider the given code snippet:

<style type="text/css">
*{ color: yellow;}
p{ color:blue;}
</style>

Which of the following statements are true with respect to the above code?
=*{} is a universal selector and p{} is a type selector.
The entire HTML page contents will be displayed in yellow color, expect the content
present inside <p> tag.

A HSLA color type is specified with _______.

hue, saturation, lightness, alpha

Which of the following property is used as a shorthand to specify a number of other background properties?

Background

Each parameter of rgb() defines the intensity of colors between 0 to 256. State true or false.

False

state the given Syntax as true or false. “background-repeat:no repeat”.

True

________ layout allows to set multiple columns of text like in newspapers.

multi-column

“Bootstrap is built on responsive 10-column grids, layout and components”

State whether true or false:

False

using which version developers can change and build their own version of bootstrap with all the provided styles?

source code version

which of the following is a mobile first front-end Framework for web development?

Bootstrap

which class combines sets of .btn-group into a button toolbar for including more Complex components?

.btn-toolbar

The __________ part is used to set the initial zoom level when the page is first loaded by the browser.

initial-scale=1

when you want to apply the style on an HTML element’s text same as heading, with bootstrap class you need to
choose?

.h1 to .h6
_________ class helps us to stand out a paragraph.

.lead

John wants to show a warning text in his web page. Choose the correct Bootstrap contextual class that helps to
perform the task.

text-warning

which of the following displays the text inside an <abbr> element in a slightly smaller font size?

.initialism

which bootstrap class is used to create a dropdown functionality to a paragraph?

.caret

which of the following creates bootstrap’s stripped table?

<table class="table table-striped"> …… </table>

The ________ classes hide the element when the viewport is at the given breakpoint on a wider.

.hidden-*-up

when you want to indicate a big box for calling extra attention to some special content or information, you have to
apply the bootstrap's ________ class to a <div> tag

.jumbotron

The _________ class adds a rounded border around an element with a gray background color and some padding.

.well

Choose the common Standard rules for all form layouts provided by Bootstrap:

Add class .form-control to all textual <input>, <textarea>, and <select> elements

Wrap labels and form controls in <div class="form-group"> (needed for optimum spacing)

Which HTML tag is used to embed the JavaScript code?

<script>
Dynamic web pages are created using ________.

server-side scripting
Where can you write the script tag inside the HTML?

Both the <head> and <body>

JavaScript is an example for ______.

client-side scripting
which of the following is true about typeof in javascript?

its value is a string that indicates the data type of the operand.

when the variable scope is available only within the method it is define, then that variable is called as local variable.

True

what is the main use of JavaScript?

To provide interactivity to HTML Pages.


what does the expression "2"+ 1 + 5 evaluate?

215

Which is not an event handler attribute?

parselnt

Which of the following is true?

If onkeyDown returns false, the key-press event is cancelled.

______ is an event that happens when the user moves the mouse away from an element.

onmouseout
The name for all the Radio Objects must be the same, State True or False.

True

Will reset() clear the contents of form elements?

No, it resets the form elements to its default values.

How do we access the elements of a form using form object?

document.form.formName

document.formName

Which of the following refers to an event handler?

Function

Which of the following is not a property of select object?

Option

The statement "var x=new Boolean(null);" refers to the __________.

Initial value x as false

Which of the following functions returns the number downwards to its nearest integer value?

floor()

Which method of the array removes and returns the last element?

pop()

Which is the correct way to write a JavaScript array?

var arr1 = new Array("john","ram","tom")

Predict the output of the given code snippet.

str="Find the last occurence";

var y=str.lastIndexOf("a");

10

Every web page displayed can be considered as _________.

An object

Choose the correct output:


<script language="javascript">

function x()

var s= "TekStac 100%";

var pattern = /\d/g;

var output=s.match(pattern);

document.write(output);

1,0,0

Which of the following is correct about the regexp "\d"?

A meta character represents a digit[0-9]

______ is an object / web browser that can be executed by the user.

Navigator

In regular expression, which expression represents "{0,}" ?

Assume you have been assigned to develop a web site with lot of animations and effects, where you have to use
jQuery libraries. But for applying certain effects, you will have to make some changes in the library files. If so, which
version of the jQuery libraries should you use?

Development version

Choose the correct symbol that represents jQuery function?

John, a web developer wants to select a single paragraph Element with the id 'p_id'. Help the John to choose the
correct code to perform the above task.

$(‘#p_id’)

Here is a jquery code:

$(document).ready(function()();

Why do we place all jQuery methods inside this code?

To prevent jQuery code from running before the document is fully loaded.

Look at the following jQuery selector: $("div #intro .head"). What does it select?

All div elements with id="intro" or class="head"

Which JavaScript function is equivalent, when you refer an HTML element using # (pound or hash) at the beginning?

getElementById

Which of the following methods helps us to attach one or more event handlers to a selected element?

on()

Ron, a web page designer, is developing a web page, where he wants to display one message when the mouse
pointer enters into a text field and display another message when the mouse pointer leaves the text box. Which
event will help him to perform these two operations together?
hover()

What is the correct jQuery code to set the background color of all paragraph elements to red?

$("p").css("background-color","red");

Which event will help to prevent any jQuery code from running before the document is finished loading (is ready)?

$(document).ready(function(){});

$(function(){ });

HTML 5
HTML stands for __________
Hyper Text Markup Language

Which of the following is / are the new features of HTML5?


Performs Client-Side validation,

Supports offline Storage

What element is a container for all the head elements, and may include the document title, scripts, styles, meta
information, and more?
<head></head>

An application that lets you search and see material on the internet is
Browser

Identify the correct type of tags:


Semantic tag
<footer> -
Formatting tag
<code> -
Formatting tag
<pre> -
Formatting tag
<sup> -
Semantic tag
<header> -
Semantic tag
<aside> -
Formatting tag
<del> -
<footer> - [Semantic tag]
<code> - [Formatting tag]
<pre> - [Formatting tag]
<sup> - [Formatting tag]
<header> - [Semantic tag]
<aside> - [Semantic tag]
<del> - [Formatting tag]
Arrange the code in the order to get given below output:
:

• <!DOCTYPE html>
<html>
<head>
<style type="text/css">
body
{
background-color:#DDFFAA;
}
h1{
font-style:italic;
text-align:center;
}
form
{
margin : 0 auto;
width:300px;
}
</style>
• </head>
<body >
<h1>Employee Appraisal Form</h1>
<form >
<table>
<tr>
<td>Employee ID</td>
<td><input type="text" name="employeeID" id="employeeID" required="required"> </td>
</tr>
• <tr>
<td>Employee Name</td>
<!-- Fill the attribute so that this text box takes a maximum of 30 characters -->
<td><input type="text" name="employeeName" id="employeeName" required="required" > </td>
</tr>
• <tr>
<td>Performance Rating</td>
<td><input type="number" name="rating" id="rating" min="0" max="10" ></td>
</tr>
• <tr>
<td>Email</td>
<td><input type="text" name="employeeEmail" id="employeeEmail" required="required" ></td>
</tr>
• <tr>
<td><input type="submit" name="submit" value="Save Appraisal"> </td>
<td><input type="reset" name="reset" value="Clear"> </td>
</tr>
• </table>
</form>
</body>
</html>

Fill in the blanks:


_blank
The attribute opens a linked page in a new window or in a tab.
_self
The attribute opens the linked page in the same frame as it was clicked. This is the default feature for
this attribute.
_parent
The attribute will open the linked page in the parent frame.
_top
opens the linked page in the full body of the window.
_blank
_self
_parent
_top
Match the Following:

href attribute : area tag


Answer 1
data attribute object tag
Answer 2
src attribute : audio tag
Answer 3
content attribute : meta tag
Answer 4
href attribute : → area tag,

data attribute → object tag,

src attribute : → audio tag,

content attribute : → meta tag

Drag and drop the correct options:


can be used for the content that can be distributed independently - just like news or blog entry that we share in
RSS feed.
represents a container for introductory content or a set of navigational links.
is intended for content that is not part of the regular flow of the text in which it appears, however is indirectly
related.
[article tag] can be used for the content that can be distributed independently - just like news or blog entry that
we share in RSS feed.
[header tag] represents a container for introductory content or a set of navigational links.
[aside tag] is intended for content that is not part of the regular flow of the text in which it appears, however is
indirectly related.
Ram designed a portal to get citizen feedback regarding the voting process in
India.The end user should choose either like or unlike image,so that it
should redirect to a page "thanks.html".
<form action="thanks.html">
<input type="image" src="like.jpg" value="submit"/>
<input type="image" src="unlike.jpg" value="submit"/>
</form>

Choose the relavant HTML input type attributes.

MobileNo number
Answer 1
Email-id email
Answer 2
PANNO text
Answer 3
Loan tenure range
Answer 4
Webaddress URL
Answer 5
Marital Status radio
Answer 6
MobileNo → number,
Email-id → email,

PANNO → text,

Loan tenure → range,

Webaddress → URL,

Marital Status → radio

The phone number should accept only 10 digit numbers. Which of the following
option will suit.
<input type="text" pattern="[0-9]{10}"/>

In the web page we have a field called phoneno,inside the textbox we should have a value "Only numbers are
allowed", once we type the phoneno it should get disappered automatically.
Which of the below option will suit for the above scenario.
<input type="text" placeholder="Only numbers are allowed">,

<input type="tel" placeholder="Only numbers are allowed">

Consider the below webpage:

Which of the following used to do this:

<input type="date" id="date" name="date" list="holidays">


<datalist id="holidays">
<option label="Republic Day">2017-01-26</option>
<option label="May Day">2017-05-01</option>
<option label="Independence Day">2017-08-15</option>
</datalist>

CSS 3

Which of the following option is used to display the range value in the image as shown above.
Mark Range(1to100)<input type="range" name="mark" id="markInputId" min="1" max="100"
oninput="markOutputId.value = markInputId.value">
<output name="markOutputName" id="markOutputId"></output>
Consider the below code snippet:
<form action="success.html" novalidate="novalidate">
<input type="checkbox" name="Qualification" value="UG">UG<br>
<input type="checkbox" name="Qualification" value="PG">PG<br>
<input type="checkbox" name="Qualification" value="12th" required="required"> 12th<br>
</form>
The validation code has been written to check atleast one checkbox. If the code is not working, what could be
the reason ?
In the form attibute, we have given novalidate.
Which of the following tag provides a hint to the user of what can be entered in the field, on placing the cursor on
the corresponding field?
Placeholder

A book is implemented as a web page which has many topics in it.To make navigation to each topic easy,
hyperlinks needs to be provided in the page. Which of the following option will do that?
<a href="topic1.html">Topic 1</a> <br />
<a href="topic2.html">Topic.2</a> <br />

Which of the following are non-semantic tag(s) of HTML5?


<div>,

<span>

- Each parameter specifies the intensity of the color ranging from 0 to 255.
- It has an additional parameter alpha to specify the opacity of a color.
- Colors can be defined in Hue-Saturation-Lightness model using certain.
- is similar to RGBA model with alpha as an additional parameter notation.
[RGB colors] - Each parameter specifies the intensity of the color ranging from 0 to 255.
[RGBA colors] - It has an additional parameter alpha to specify the opacity of a color.
[ HSL colors] - Colors can be defined in Hue-Saturation-Lightness model using certain.
[HSLA model] - is similar to RGBA model with alpha as an additional parameter notation.
Write the correct css code for dividing the text in the <p> element into 3 columns in the web browsers like
Chrome, Safari, Opera and Firefox.
p{
-webkit-column-coun
: 3;
3
-moz-column-count: ;
column-count: 3;

}
-webkit-column-count

column-count: 3;

inline
When the styles are directly embedded in the tag itself using the style attribute then it is known as style
internal external
, style will be used if that style needs to be applied for that web page alone and style is that a
single file can be used to change the look of all the web pages of the application.

Inline

Internal

External

Identify the selectors:

*{ font-family : Arial;} Universal selector


Answer 1
.colorChange { color : magenta} Class selector
Answer 2
#rollno { background-color: red } Id selector
Answer 3
h2 { color : green } Element selector
Answer 4
*{ font-family : Arial;} → Universal selector,

.colorChange { color : magenta} → Class selector,

#rollno { background-color: red } → Id selector,

h2 { color : green } → Element selector

Consider the below code snippet:


<!DOCTYPE html>
<html>
<head>
<style type="text/css">
p{
color: blue;
}
</style>
</head>
<body>
//line1 <p>Cascading Style Sheets (CSS).</p><br>
//line2 <p>HyperText Markup Language (HTML).</p><br>
//line3 <p>XML stands for eXtensible Markup Language.<p>
</body>
</html>
In above code for line1,2 and 3 the content will be displayed in blue color. What change we need to make so that
line 3 contents alone will be displayed in green color.
change the line 3 as <p style="color:green">XML stands for eXtensible Markup Language.</p>

Re-arrange the code below in a correct order to display the content inside <p> tag in the following format:
Uppercase,Lowercase then capitalize

• <html>
<head>
• <style>
• p.uppercase
{
• text-transform: uppercase;
}
• p.lowercase {
• text-transform: lowercase;
• }
• p.capitalize {
text-transform: capitalize;
}
• </style>
</head>
</html>

Which of the following are non-semantic tag(s) of HTML5?


<div>,
<span>

Which vendor-prefix we have to use to set specific CSS3 properties to work on Mozilla Firefox browsers
in order to avoid the inconsistencies between various implementations?
-moz-

Choose the correct declaration of the following CSS3


body{color:red;}

CSS 3 With Bootstrap


Which one of the following features is provided by bootstrap?
Plugins for Javascript

State True or False.


Bootstrap contains JQuery based design templates.

False

State True or False.


Bootstrap is supported by all browsers.

True

Which of the following is correct about Bootstrap?

Bootstrap's responsive CSS adjusts to Desktops, Tablets and Mobiles.,

Provides a clean and uniform solution for building an interface for developers.,

It contains beautiful and functional built-in components which are easy to customize.

Bootstrap is a framework designed for building website, web applications with less effort. Bootstrap framework
focus more on building mobile website and web applications. State whether true or false.
True

State True or False.


It is easy to create responsive designs using Bootstrap.
True
State True or False.
Bootstrap contains base styling for most HTML components.

True

Which of the following is bootstrap’s global default font-size ?

14px

Re-arrange the code to get the below output:

• <!DOCTYPE html>
<html lang="en">
• <head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
• <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
• <div class="container">
<h4>Input Groups</h4>
<form>
<div class="input-group">
• <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="email" type="text" class="form-control" name="email" placeholder="Email">
• </div>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
• <input id="password" type="password" class="form-control" name="password" placeholder="Password">
</div>
</form>
• </div>
</body>
</html>

Re-order the steps to create a default navbar in Bootstrap:

• Add the classes .navbar, .navbar-default to the tag


• Add role = "navigation" to the above element, to help with accessibility
• Add a header class .navbar-header to the element
• Include an element with class navbar-brand.
• To add links to the navbar, simply add an unordered list with the classes of .nav, .navbar-nav.

Arrange the basic structure of Bootstrap grid:

• <div class = "container">


• <div class = "row">
<div class = "col-*-*"></div>
• <div class = "col-*-*"></div>
• </div>
</div>

Match the following:

.jumbotron : → It indicates a big box for calling extra attention to some special content or information,

.caret : → It indicates dropdown functionality,

.well : → It is a container in that causes the content to appear sinking or an inset effect on the page,

.panel : → It provides a flexible and extensible content container with multiple variants,

.initialism : → Displays the text inside an element in a slightly smaller font size

Choose the right bootstrap classes to handle pagination:

[.pagination] : To get pagination on your page you have to add this class
[.disabled] : We can customize links by this class for unclickable links
[.active ] : We can customize links by this class to indicate the current page
[.pagination-Ig] : Use this class to get large size item
[.pagination-sm] : Use this class to get small size item
<div> <ul> <a> <li>
To create a list group with linked items, use instead of and instead of

<div>

<ul>

<a>
<li>

Which of the following code results : Light grey background color

<p class="bg-light text-dark"></p>

Match the following:

The class that can be used to make a button unclickable: → .disabled,

The class that can be applied to button group instead of resizing each button. → .btn-group-lg,

The class which is used for a basic button group → .btn-group,

The class that helps to draw a toolbar of buttons → .btn-toolbar

Write the code to use glyphicon search icon anywhere in your program:
Hint: Use span class and apply necessary class alone.

Answer:
<span class="glyphicon glyphicon-search"></span>

.hidden-*-up .hidden-*-down
You can combine one class with one class to show an element only on a given
interval of screen sizes.

.hidden-*-up

.hidden-*-down

Which of the following contextual class is used for showing a dangerous action purpose?

.danger

The _____ class is used to add headers inside the dropdown menu.

.dropdown-header

State True or False.


Another form of pagination is breadcrumb.

True

State True or False.


Button Group allows multiple buttons to be stacked together on a single line.

True

The ______ is a feature to add appropriate spacing around the headings on a page.

page header

State True or False.


Bootstrap provides Inverted Navigation bars.

True

Which of the following class/classes applies hover effect to a specific row or cell of a table ?

.active

Which of the following is correct about bootstrap wells?


You can change the size of well using the optional classes : well-lg or well-sm,

well-lg or well-sm classes are used in conjunction with .well class

In Bootstrap Jumbotron is used for content that you wish to highlight?

Yes

What is the main usage of Glyphicons?

Providing different icons

Java Script
When you want to enclose; some JavaScript statements to an HTML file, which is the correct tag you have
to use?
<SCRIPT>

Which of the below java script code helps to change the content of the paragraph tag dynamically?

<p id="pid1">Aim Higher.. Sky is your limit

document.getElementById("pid1").innerHTML = "Never give up!!";

David, a beginner in web development trying to perform one particular operation using client side
JavaScript. Choose the correct option(s) that he can't be done with client-side JavaScript?

Store the form's contents to a database file on the server

When a user views a page containing a JavaScript program, which machine actually executes the script?

The User's machine running a Web browser

Sita wishes to greet the user when the user clicks on "Greet Me" button. In which event does she need to write the
JavaScript code for greeting the user?

Onclick

Which of the below statements are used to comment a line in CSS file?

/* this is a comment */
Drag and Drop the correct options:
[isNaN(0)] returns true is zero is a legal number otherwise returns false.
[String(obj))] converts the Boolean object “obj” into String object.
[escape()] function computes a new String in which certain characters from the given string have been replaced
by hexadecimal values.
[encodeURI()] function makes the respective URI as portable, so that it can be used across any network to any
computers.
[isFinite( )] function returns true if the input given is a legal finite number, otherwise returns false.
[parseInt (obj)] function converts the string object “obj” to an integer value.
Choose the correct options:
Client Side Scripting Language
JavaScript :
Client Side Scripting Language
VBScript :
Server Side Scripting Language
ASP :
Server Side Scripting Language
Perl-CGI :
Server Side Scripting Language
Python :
Server Side Scripting Language
PHP :
Client Side Scripting Language

Client Side Scripting Language

Server Side Scripting Language

Server Side Scripting Language

Server Side Scripting Language

Server Side Scripting Language

Match the following:

It matches any decimal digit not from 0 through 9 → [^0-9],

It matches any character from lowercase a through uppercase Z → [a-Z],

Find any of the alternatives specified. x or y → (x/y),

Find any one character between the brackets → [abc], The Web page currently shown in the browser window →
Window

Rearrange the JavaScript code for storing and displaying the contents of two arrays.

• <script type="text/javascript">
• var n1=new Array(5);
var n2=new Array();
• for(var i=0;i<n1.length;i++)
• n1[i]=i;
for(var i=0;i<n1.length;i++)
• n2[i]=1;
displayArray(n1);
• displayArray(n2);
function displayArray(array){
• for(var i=0;i<array.length;i++)
• document.writeln(array[i]+" ");
}
</script>

Re-arrange the JavaScript code for checking whether a number is positive or negative or zero.

• <script type="text/javascript">
var no = 0;
• if( no==0) {
• document.write("The number is zero");
}
• else if(no>0) {
• document.write("The number is positive");
}
else {
• document.write("The number is negative");
}
</script>

Choose the correct JavaScript statement which helps you to write "World of JavaScript" in a web page?
document.write("World of JavaScript")
The parseInt() method converts the string to a integer. Before applying this function, Ram wants to know the
type of the argument that is passed to the function. Which operator in javascript would support this ?
typeof

Polson is allocated with the task of email validation in java script. He needs to extract character by character
and check for email validation like looking for @ . etc. Which method is best suited to extract every character
from the text?
charAt()
Ram is the developer of Allen Software company. He is designing the website for the banking application. There
is a button called 'check interest rates'. When that button is clicked, the user has to be redirected to a seperate
page to show the domestic interest rates. Help Ram in accomplishing this task using the javascript.

window.location

Predict the output of the following JavaScript code:


<html>
<head>
<script>
var txt= "pass 70% fail 30%";
var pattern = /\D/g;
var res= txt.match(pattern);
document.write(res);
</script>
</head>
</html>
p,a,s,s, ,%, ,f,a,i,l, ,%

Which of the below is the correct syntax for exectuing some code if "amt" is equal to 5000?

if (amt == 5000)

What is the output of the below code snippet


<script type="text/javascript">
amt=55+"55";
document.write(amt);
</script>
5555

Sita wishes to greet the user when the user clicks on "Greet Me" button. In which event does she need to write
the javascript code for greeting the user?

onclick

jQuery
When referencing an HTML element using jQuery preceded by a ‘ # ‘ , what JavaScript function is this equivalent
to?

getElementById

Which of the following is/are true about HTML?


Some of the tags are self closing while some of the tags must be explicitly closed in HTML5,
Browser does not throw any error even if we have mistaken in the HTML syntax

Which of the following is most appropriate tag in html 5 to divide the document into logical document groups?
<section></section>

If you want to change the color of a link to red when moving mouse pointer on top of it, which CSS property you
need to change?
a:hover{ color: red; }
The following elements are the new elements in HTML 5. These elements are called _____________
Semantic elements
Identify the correct jQuery events:
blur : → Form Event,
focus : → Form Event,
keypress : → Key Event,
hover : → Mouse Event,
scroll : → Window Event
Drag and drop the correct options:
[$("p > *") ] - This selector selects all elements that are children of a paragraph element
[$("div[p]")] - Selects all elements matched by <div> that contain an element matched by <p>
[$("p a.specialClass")] - This selector matches links with a class of specialClass declared within <p> elements
[$(":empty")] - Selects all elements that have no children
Re-arrange the jQuery code to hide and show the div tag with the id ‘div2’ which contains some html elements.
The form tag with the name ‘myForm’ contains a drop down box with the id ‘select1’ for setting the marital
status. When the user sets the marital status as ‘Married’ , then a div tag with the id ‘div2’ should be displayed
which contains the html elements for getting spouse name, no. of children, etc. If the user set the marital status
as ‘Unmarried’ , then it should hide the div tag.
Note:
<div> tag id : div2
Dropdown box id : #select1
Dropdown box name:mstate
Form name : myForm

• <script>
• $(document).ready(function() {
• $('#select1').change(function(){
var name=document.myForm.mstate.value;
• if(name=='Married'){
• $('#div2').show(); }
• else
• $('#div2').hide();
});
• });
</script>

Choose the correct options:

fadeTo
The method adjusts opacity for the matched element.
slideUp
The mehod hides the matched elements with slide.
slideDown
The method shows the matched elements with slide.
fadeIn
The method shows the matched elements by fading it to opaque.
fadeTo

slideUp

slideDown

fadeIn

Write the correct jQuery code to select the specified element below:
Selects all elements that are the parent of another element, including text.
$(":parent")
If you are using $ in your own code, or are using another library, such as prototype, that uses $, you can call
_______ to restore $ to its original value.
jQuery.noConflict()

Animates the space between letters for all paragraphs with default duration of 400 milliseconds. Which jQuery
code accomplishes this task?
$("p").animate({letterSpacing:"15px"});

$("#name").remove(); This will remove the text field when you click on the button. State true or false.
True
Bind an event handler to the "blur" JavaScript event on an element.
.blur()
Rhita wants to replace a jQuery code '$(document).ready(fun)' using another equivalent method. Help her to find
the correct method from the given options.
$(fun)
When you don’t want people to click a submit button twice on a form, or you only want to allow them to do
something once on a page, what kind of functions you have to use for this?
$("#myElement").bind ('click', function() {});
$("#myElement").unbind('click');
John wants to animate (moving effect) an element in the webpage he designed. For this, he set its CSS position
property to its default value and applied the animations. If there is no syntax error in the code, what would be
output he gets?
Animation failed because the CSS position property set to default value,
Animation failed because the CSS position property set to static
Some people don’t want animation to interfere with their web page experience. What do I do if I want to let a
user turn off the animation?

wire up a click button to this line of code:


$.fx.off = true;,

Use the jquery method:stop()


Logic Development
______________ by step procedure to solve any problem.
Algorithm
expression is a combination of _________, _________ and ____________.
Operators
constants
variables.
Order the algorithm to find the modulo of any two given numbers
Start
Declare 3 variables- multiplier & multiplicand and resultant modulo
Read the values of multiplier and multiplicand
resultant modulo multiplier % multiplicand
Display the resultant modulo
Stop
Map the symbols n flowchart to its appropriate functionality
Diamond - decision making
Rectangle - process
Parallelogram - input/output

You might also like