Hello friends in this article we are going to discuss about MCQs related to Java,JavaScript, Dbms,Rdbms.
1.Consider the tables given below.
Customer(customerId,customerName)
Book(bookId, bookName)
Purchase(purchaseId, bookId, customerId)
bookId and customerId in purchase table are foreign keys referring to Book and Customer tables respectively. Which is the
CORRECT SQL statement to retrieve customer name and book name for all books purchased by customers.
Ans –
SELECT
c.customerName,b.bookName
FROM customer c INNER JOIN
purchase p
ON c.customerId=p.customerId
INNER JOIN book b
ON b.bookid=p.bookid;
2.What will be the output of the following Java code?
Employee.java
public class Employee {
private int employeeId;
private String employeeName;
public Employee(){
this.employeeName = null;
this.employeeId = 0;
System.out.println(“Employee Constructor”);
}
}
ArrayOfObjectsTester.java
public class ArrayOfObjectsTester {
public static void main(String[] args){
Employee[] employee = new Employee[3]; //Line-1
}
}
Ans – Compilation error at Line-1: Invalid
array declaration
3.Refer the code given below:
Employee emp = new Employee();
Employee emp1 = new Employee();
Employee emp2 = emp;
Employee emp3;
emp=null;
emp3=emp;
//Line1
Assume that class Employee is a valid Java class.
How many objects are eligible for garbage collection at Line1?
Choose the most appropriate option.
Ans – 0
4.Which is the correct CSS code to display the text “Accenture” in light grey back ground?
Ans –
<h2 style="background-
color:lightgrey">Accenture</h2>
5.Which of the following is/are TRUE with respect to method overloading?
a. Method name should be the same
b. Return type of the methods should be the same
c. Number of parameter and sequence of parameter must be different
Choose the most appropriate option.
ANS – Both (a) and (c ) are TRUE
6.Consider the table Project(projectId, projectType,budget).
Which is the CORRECT SQL statement to retrieve the count of projects which is of type ‘FIN’ or’ SALE’? It should count for ‘FIN’
and ‘SALE’ separately.
ANS – SELECT
projectType,COUNT(projectId)
FROM project
WHERE projectType IN(‘FIN’,’SALE’)
GROUP BY projectType;
7.Which of the folwwing are CORRECT statement?
a) onClick() and onFocus() are DOM events
b) The DOM method getElementByTagName(“name”) retrieves an array of all elements having the given tag name
c) In Java Script, a browser is represented by an implicit object called Document
ANS – a and b only
8.Assume that table Employee is created with foreign key column managerid referring to empid column of same table and the
following records are inserted.How many rows will be deleted after executing the below DML statement?
DELETE FROM employee WHERE empid=1001;
Select the most appropriated option.
ANS – 0
9.Consider the class Account and class Customer given below. Identify the relationship that exists (if any) between these two
classes.
Account.java
public class Account{
private int accountNumber;
private double balanceAmount;
}
Customer.java
public class Customer{
private String customerName;
Account account;
public Customer(){
this.account = new Account();
}
Choose the most appropriate option.
ANS – Composition
10.Performance feedback allows which of the following actions?
(1) To take action to improve your skills and performance so you are effective in your current and future roles
(2) To have your say about how you think your colleagues are performing
Choose the most appropriate option.
ANS – Only (1)
11.Assume that table Event is created using the below script.
CREATE TABLE Event(
EventId VARCHAR2(5) CONSTRAINT Event_PK PRIMARY KEY,
EventName VARCHAR2(20) CONSTRAINT Event_NN NOT NULL,
StageNumber NUMBER(2) DEFAULT 1,
NumberOfParticipants NUMBER(2));
Identify the correct insert statements which can be applied on Event table
ANS – a) INSERT INTO Event VALUES(‘E1′,’Dance’,NULL,2);
b)INSERT INTO Event(EventId,EventName) VALUES(‘E3′,’Drama’);
12.What will be the output of the following Java code?
public class Tester {
public static void main(String[] args) {
int itr=10;
int sum=0;
do{
itr=itr-2;
sum=sum+itr;
}while(itr>=0);
System.out.print(“Itr: “+itr+”, Sum: “+sum);
}
}
Choose the most appropriate option.
ANS – Itr: -2, Sum: 18
13.
Refer the JavaScript code given below.
<html>
<head>
<script>
function aFun(){
var num1=111;
var num2="111";
alert(num1==num2) //Line1
alert(num1===num2) //Line2
}
</script>
</head>
<button onclick='aFun()'>Click</button>
</html>
When the above code is executed, what will be the output produced by Line1 and Line2?
ANS – Output from Line1: true, Output from
Line2: false
14.What will be the output of the following Java code?
public class IfTester{
public static void main(String[] args) {
int number1 = 10;
if(number1 == 10) {
int number2 = 20;
} else {
int number2 = 30;
}
System.out.println(“Number2 :”+number2);
}
}
Choose the most appropriate option.
ANS – Compilation Error: number2 cannot be
resolved to a variable
15.Which of the following statement/s is/are VALID array decleration in JavaScript?
ANS – Both (1) and (2)
16.What will be the output of the following Java code? Assume that all classes are present in the same package.
class Account {
int balance;
public void createAccount() {
System.out.println(“Account created”);
balance = 500;
}
}
class SavingsAccount extends Account {
public void createAccount() {
System.out.println(“Savings account created”);
balance = 1000;
}
}
public class ApplicationTester{
public static void main(String[] args) {
Account account = new SavingsAccount();
account.createAccount();
System.out.println(“Balance: “+account.balance);
}
}
Choose the most appropriate option.
ANS – Savings account created
Balance: 1000
17.What will be the output of the following Java code?
public interface Bank{
void createAccount();
public void applyForLoan();
}
public class MyBank implements Bank{
void createAccount(){
System.out.println(“Account in MyBank”);
}
public void applyForLoan(){
System.out.println(“Loan in MyBank”);
}
}
public class BankTester{
public static void main(String[] args){
Bank b = new MyBank();
b.applyForLoan();
}
}
Ans – Compilation error at Line 7: Cannot
reduce the visibility of the inherited
method from Bank
18.Consider the following tables:
Nominee(NomineeId, NomineeName, DateOfBirth, Relationship)
Account(AccountNumber, OpeningDate, Balance, NomineeId)
Which is the CORRECT SQL query to display AccountNumber, OpeningDate, NomineeName, DateOfBirth, Relationship of
accounts including the accounts for which there are NO nominees?
Ans – SELECT
Account.AccountNumber,Account.Ope
ningDate,Nominee.NomineeName,
Nominee.DateOfBirth,Nominee.Relatio
nship FROM Account
LEFT OUTER JOIN Nominee ON
Account.NomineeId =
Nominee.NomineeId;
19.How many cells will be displayed when the page is displayed on the browser?
Refer the HTMLcode given below.
<html>
<body>
<table border="1">
<tr><th>A</th> <th colspan="2">B</th>
<tr> <th rowspan="3">C</th> <th>D</th> <th>E</th> </tr>
<tr> <th>A</th> <th rowspan="2">B</th></tr>
<tr> <th>D</th>
</table>
</body>
</html>
ANS – 8
20.Which of the following actions should be performed to ensure cyber safety at a user level?
(i) Automatic downloads from the websites should be enabled
(ii) Automatic security updates should be installed
(iii) Firewall should be turned off if the system has the latest security update
Choose the most appropriate option
ANS – Only (ii)
21.Consider the following Java code snippet.
String str1 = new String(“Accenture”);
String str2 = str1;
String str3 = new String(“LKM”);
String str4 = str3;
str1 = null;
str4 = null;
str3 = str4;
From the above code, identify how many object(s) are eligible for garbage collection.
Choose the most appropriate option.
ANS – 1.
22.Which of the following statment/s is/are TRUE with respect to Community Cloud?
(1) Exclusively owned and operated by a single organization
(2) Available for use by a shared community consisting of several organizations
Choose the most appropriate option.
ANS – Only (2)
23.Consider the table Account(accountId, accountType,balance).
Which is the CORRECT SQL statement to display all unique accountTypes from account table?
ANS – SELECT DISTINCT accountType
FROM account
24.What will be the output of the following Java code?
interface A{
void display(); // Line X
}
class B implements A{
void display(){ // Line Y
System.out.println(“B”);
}
}
public class Demo{
public static void main(String[] args) {
A a=new B(); // Line Z
a.display();
}
}
Choose the most appropriate option
ANS – Compilation error at Line Y: cannot
reduce the visibility of the method
25.What will be the output of the following Java code?
Note: Parent class is present in a package called ‘packageone’. The Child class and TestPackage class are present in a
package called ‘packagetwo’
Parent.java
package packageone;
public class Parent {
protected void display(){
System.out.println(“Hello! its from package one”);
}
}
Child.java (Assume that necessary packages are imported)
package packagetwo;
public class Child extends Parent {
public void display(){ //Line 1
System.out.println(“Hello! its from package two”);
}
}
TestPackage.java (Assume that necessary packages are imported)
package packagetwo;
public class TestPackage {
public static void main(String[] args) {
Parent p = new Parent();
Child c = new Child();
p.display(); // Line 2
c.display(); // Line 3
}
}
Choose the most appropriate option.
ANS – Compilation error at Line 2 : The
method display() from the type Parent
is not visible
26.What will be the output of the following Java code?
public class StringTester{
public static void main(String[] args) {
String s = “Welcome “;
s.concat(“to Accenture”);
System.out.println(s);
}
}
Choose the most appropriate option.
ANS – Welcome
27.Refer the code given below:
public class Vehicle {
private int vehicleId;
private String vehicleName;
public Vehicle(int vehicleId, String vehicleName) {
this.vehicleId = vehicleId;
this.vehicleName = vehicleName;
}
// Assume Getters and Setters are coded
}
public class Car extends Vehicle {
private String carModel;
private double average;
//Line1
// Assume getters and Setters are already coded…
}
Choose a valid Constructor implementation to be inserted at Line1 to make the above code compile successfully
Choose the most appropriate option.
ANS – public Car(int vehicleId, String
vehicleName, String carModel,double
average) {
super(vehicleId, vehicleName);
//Java code to initialize carModel and
average
}
28.Which testing technique tests the functionality of the application without looking at the internal structure of the code?
i. Black Box Testing
ii. Assembly Testing
iii. Product Testing
iv. White Box TestinG
Ans:Black Box Testing
29.Which is the CORRRECT SQL statement to add the new column “DateOfJoining” to an existing table “Employee”?
ANS – ALTER TABLE Employee ADD
DateOfJoining DATE;
30.What will be the output of the following Java code?
package mypackage1;
public class Parent {
protected Parent(){
System.out.print(“1 “);
}
}
package mypackage2;
import mypackage1.Parent;
public class Child extends Parent{
protected Child(){
System.out.println(“2”);
}
}
package mypackage2;
public class ApplicationTester {
public static void main(String[] args){
Child child = new Child();
}
}
ANS – 1 2
31.Consider table Employee(EmployeeId, EmployeeName,DeptCode) .
Which is the CORRECT SQL query to display the EmployeeId and EmployeeName of employees who are working in DeptCode
10 OR 20?
ANS – (i) SELECT EmployeeId,EmployeeName FROM Employee WHERE DeptCode IN (10,20);
(ii) SELECT EmployeeId,EmployeeName FROM Employee WHERE DeptCode = 10 OR DeptCode = 20;
32.What will be the output of the following Java code?
public class StaticTester{
private static int count;
public static void main(String[] args) {
count++;
new StaticTester().count++;
StaticTester.count–;
StaticTester s = new StaticTester();
s.count = s.count + 5;
StaticTester staticTester = new StaticTester();
System.out.println(“Count is ” +staticTester.count);
}
}
Choose the most appropriate option.
ANS – Count is 6
33.What will be the output of the following Java code?
class Base {
public void display() {
System.out.println(“Will I be displayed?”);
}
}
class Derived extends Base {
public void display() {
super.display();
System.out.println(“I will be displayed”);
}
}
public class ApplicationTester{
public static void main(String[] args) {
Derived derived = new Derived();
derived.display();
}
}
Choose the most appropriate option.
ANS – Will I be displayed?
I will be displayed
34.Consider the Java code given below. When the code is executed, how many times “1” will be printed?
public class Tester{
public static void main(String[] args){
for(int i=0; i < 5; i++){ if(i > 2){
continue;
}
System.out.print(” 1 “);
}
}
}
Choose the most appropriate option
ANS – 3 times
35.Consider the below tables are created and has some records.
Account(accountId,accountType,balance)
Transaction(transactionId,accountId,transactionType,amount)
AccountId in transaction table is a foreign key referring to accountId of account table.
Which is the CORRECT SQL statement to retrieve accountId and accountType for which more than three transactions are
recorded?
ANS – SELECT accountId,accountType
FROM account
WHERE accountid IN(
SELECT accountid FROM transaction
GROUP BY accountid HAVING
COUNT(transactionid)>3);
36.Which is the CORRECT SQL Query to display names of employees which has third character as ‘t’ and ends with ‘n’;
ANS- SELECT EmployeeName FROM
Employee WHERE EmployeeName
LIKE ‘__t%n’;
37.In HTML, Which is the CORRRECT code to display a hyper link “Click”?
[Note: While clicking on “Click” it should direct to accenture portal]
ANS - <a href="https://portal.accenture.com">
Click </a>
38.Assume that below code is present in the head tag of a HTML page. Which is the CORRECT way of using this style?
ANS - <h1 class="myclass">Welcome to My
Homepage</h1>
39.Which of the following statement/s is/are TRUE with respect to Agile?
(1) Focuses on an iterative, incremental, and flexible approach to software development
(2) Development of software takes place in sequential phases
Choose the most appropriate option
ANS-Only (1) is TRUE
40.What will be the output of the following Java code?
Vehicle.java
public class Vehicle {
private float enginePower;
public Vehicle(float enginePower){
this.enginePower = enginePower;
}
public float getEnginePower(){
return enginePower;
}
}
FourWheeler.java
public class FourWheeler extends Vehicle{
private String type;
public FourWheeler(){
this.type = “LMV”;
}
public FourWheeler(String type, float enginePower){
this.type = type;
}
public String getType(){
return type;
}
}
InheritanceTester.java
public class InheritanceTester {
public static void main(String[] args){
FourWheeler vehicle = new FourWheeler(“HMV”, 3.5F);
System.out.println(vehicle.getType() + ” ” + vehicle.getEnginePower());
}
}
ANS – Error in the code: Implicit super
constructor Vehicle() is undefined. Must
explicitly invoke another constructor
41.Which of the following statement(s) is/are TRUE?
1) GET method is the default form submission method
2) Check box is a multi select control
ANS – only 2
42.Arrange the following stages of Project Lifecycle according to SDLC.
(1) Planning
(2) Initiation
(3) Closing
(4) Execution
Ans:(2) – (1) – (4) – (3)
43.What will be the output of the following Java code?
class Employee {
public Employee() {
System.out.println(“From Constructor of Employee”);
}
}
public class Tester {
public static void main(String[] args) {
Employee[] employee = new Employee[5];
employee[0] = new Employee(); //Line2
}
}
ans – Prints the “From Constructor of
Employee” 1 times
44.What will be the output of the following Java code?
public class ApplicationTester {
public static void main(String[] args){
int count = 0;
do {
count++;
if (count == 3){
continue;
}
} while(count < 5);
System.out.println(count);
}
}
Choose the most appropriate option.
Ans – 5
45.What are the benifits of ADM?
(1) Project standardization and customization
(2) Common project management framework
ans – Both (1) and (2)
46.Consider table Project(projectId, projectType, budget).
Which is the CORRECT SQL statement to display projectId, projectType and budget of project which is having minimum budget
in each project type?
ans – SELECT p1.projectId,
p1.projectType,p1.budget FROM
project p1
WHERE p1.budget IN(
SELECT MIN(p2.budget) FROM
project p2
WHERE
p1.projectType=p2.projectType);
47.Which of the following statement(s) are FALSE regarding Java Architecture?
(i) Byte code or .class file is platform independent
(ii) JVM is platform independent
Ans – Only (ii) is FALSE
48.Which among the following are DevOps Principle?
(i) Automate Everything
(ii) Test early and often
(iii) Strong source control
ans – All (i), (ii) and (iii)
49.Consider the table Salesman(SalesmanId, SalesmanName, TotalSales).
Which is the CORRECT SQL query to display details in the decreasing order (highest to lowest) of TotalSales and in the
decreasing order of SalesmanId in case TotalSales is the same.
Ans – SELECT SalesmanId, SalesmanName,
TotalSales
FROM Salesman ORDER BY
TotalSales DESC, SalesmanId DESC
[…] friends if you are looking for MERN Techleap Multiple choice questions | MERN Techleap Question Answers | MERN Techleap MCQ with Answers | MERN Techleap Accenture Question […]