Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

JAVA - MCQ1 - SE - AD Accenture

Download as pdf or txt
Download as pdf or txt
You are on page 1of 89

Pre-request every one again to join in every following groups to

get further updates and if you leave groups after your TFA and
stream tests you will miss your further updates for sure so just
stay connected.

Dm - https://t.me/angelnndevil

Main group link - https://t.me/ad2group

Get more dumps here

Materials/Channel/dumps -
https://t.me/adaccenturematerial
1.which one of the following cannot be declared as static?
A)Class
b)Constructor
c)VAriable
d)Method
ANS: B

2.WHich one of the following is not a severity in sonarQube?


A)Major
B)Critical
C)Blocker
D)Issues
ANS: D

3.Refer the code given below


public class Tester {
public static void main(String[] args) {
String a[]={"ral","cal"}
String str="bat"
a[1]=str
str="mat",
for(int i=0,i<str.length(),i++)
{
//Line1
//Line2

}
}
Choose from below a valid option to complete the above code, in the order
as it appear, that will give the output as MAT
A) int x= str.charAt(i)-32,
System.out.print({char}x);
B)int x=str.chatAt(i)+32,
System.out.print(x);
C)char c=str.charAt(i)-32,
System.out.print(c);
D)int x=str.charAt(i)-32,
System.out.print(x);

ANS: A

4.who is responsible for prioritizing product backlog?


A)Product Owner
B)Project Manager
C)Lead Developer
D)Business Analyst

ANS: A

5.What will be the output of following java program?


public class ExceptionHandling {
public static void main(Stirng[] args)
{
try
{
System.out.print("Hello");
throw 89;
}
catch(Exception ex)
{
System.out.print("World");
}
}
}
Choose one correct answer
A)Compliation Error
B)Hello
C)HelloWorld
D)Runtime Error

ANS: A

6.Consider the code given below


class Base {
public int a=3;
public void addFive() {
a += 5;
System.out.print("Base ")
}
}

class Denved extends Base {


public int a=8,
public void addFive() {
this.a +=5,
System.out.print("Denved");
}
}
public class Test {
public static void main(String[] args) {
Base f= new Denved();
f.addFive();
System.out.print(t.a);
}
}
Choose from below a valid option
A)Denved 3
B)Denved 13
C)Base 3
D)Base 8

ANS: A

7. Consider the code given below


class Employee {
int salary=0;
Employee(){
salary=10;
}
public void changeSalary() {
salary=salary+1;
System.out.println(salary);
}
}
class PermanentEmployee extends Employee {
public void changeSalary() {
salary=salary+2;
System.out.println(salary);
}
}
public class Test {
public static void main(String[] args) {
Employee employee = new PermanentEmployee();
employee.changeSalary();
}
}
Choose from below a valid option
A)10
B)11
C)12
D)0

ANS: C

8.Refer the code given below


interface i1{}
interface i2{}
interface i3 extends i1,i2{}
class Two{}
class Three extends Two implements i3{}

public class Tester {


public static void main(String[] args) {
i3 obj=new Three();
if(obj instanceof i1)
System.out.println("Object created is an instance of i1");
if(obj instanceof i3)
System.out.println("Object Created is an instance of i3");
}
}
Choose from below a valid option
A) compilation fails at Line1 and Line2
B) Compilation fails at Line3 and Line4
C) Object created is an instance of i1
Object Created is an instance of i3
D) Object Created is an instance of i3

ANS: C

9.Refer the incomplete code given below


public class Tester {
public static void main(String[] args) {
int[][] intArray = {{1,2,3},{3,4},{5,6,7,8}},
int [] result=___Line1___;

for (int i=0;i<___Line2____;i++) {


int sum = 0;
for (int j=0;i<___Line3____;J++) {
sum = sum+____Line4____;
result[i] = sum;
}
}
for(int i=0;i<result.length;i++){
System.out.prinln(result[i]);
}
}
}
it is required to find the sum of values in each row of intArray and
populate it in result array. Choose from below a valid option to complete
the above code, in the order as it appears that will give the output as
6
7

A)new int[intArray.length]
intArray.length
intArray[i].length
intArray[i][j]
B)new int[intArray.length]
intArray.length
intArray.length
intArray[i][j]
C)new int[intArray.length]
intArray.length
intArray.length
intArray[j][i]
D)new int[][intArray.length]
intArray.length
intArray[i].length
intArray[i][j]

ANS: A

10. Refer the code given below


class Eaxmple{
public static void main(String args[]) {
String phone="APPLE",
switch(phone)
{
case "Apple",System.out.prinln("Apple");
case "APPLE",System.out.prinln("APPLE");
default: System.out.println("SAMSUNG");
}
}
}
Choose from below the valid option
A)Apple
B)Apple
APPLE
C)APPLE
SAMSUNG
D)APPLE

ANS: C

11.what data would be written in the file after execusion of below


snippet of code .
public static void main(String[] args)throws IOExeception {
try {
FileOutputStream fout= new FileOutputStream("file txt")
fout.write(65),
fout.close,
}catch(Exception e){
System.out.println(e)
}
}
A)A
B)B
C)C
D)D

ANS: A

12.Choose from below the CORRECT statements about main(STARTER)method


[choose 3]

A)Every class in java should have main method


B)The main method must be declared as public static void
C)java virtual machine calls the main method directly
D)Program execution starts from main method only
E)Main method can not be declared as final

ANS: BCD

13.what is the result?

class TechVersanlThread extends Thread {


public static void main(String[] args) threows Execption {

Thread.sleep(2000);
System.out.println("Accenture");
}
}

A)The program will result in compliation errors


B)An exception is thrown at runtime
C)The code executes normally and prints "Accenture"
D)The code executes normally, but nothing is printed.

ANS: C

14. What will be the output of the following java code?

public class ExecptionHandle {


public static void main(String[] args) {
try {
throw new IOException();
}
catch(IOException|Exception ex) {
System.out.println(ex + "handled");
}
}
}
Choose one correct answer

A)Java.lang.Execptionhandled
B)Compilation Error
C)Java.io.IOExceptionhandled
D)Java.io.IOExceptionhandled
Java.lang.Exceptionhandled

ANS: B

15.Consider below code snippet what other values can be added to mySet
without the program causing any errors. Select all that apply
public static void main(String[] args){
Set mySet= new HashSet();
mySet.add("Z");
mySet.add("P");
mySet.add("M");
}

A)mySet.add(null);
B)mySet.add(12.56);
C)mySet.add("A");
D)mySet.add(false);

ANS: All

16.Select most approprate statement

A)Anonymous class can be reused.


B)Anonymous class does not have a name.
C)We can not create object of anonymous class
D)Anonymous class can be only public

ANS: B

17.Refer the class given below


class Customer {
private int customerid,
private String customerName.
}
Identity the correct paramterized constructor declerations[Choose 2]

A) public Customer(int customrid){


this.customerid= customerid;
}

B) public void Customer(String customerName) {


this.customerName = customerName;
}

C) public void Customer(int customerid, String customerName) {


this.customerid= customerid;
this.customerName = customerName;
}

D) public Customer(String customerName) {


this.customerName = customerName;
}

ANS: A,D

18. Consider the following program and choose the best option

class ExamThread extends Thread {


System.out.print("Run! ");
}
public static void main(Stirng[] args) throws InterruptedException {
Thread examThread = new ExamThread();
examThread.start();
System.out.print("Eat! ");
examThread.join();
System.out.print("Relax! ");
}
}

A)when executed, it prints one of the following: Run! Eat! Relax! or Run!
Relax! Eat!
B)when executed, it prints one of the following: Eat! Run! Relax! or Run!
Eat! Relax!
C)when executed, it prints one of the following: Eat! Run! Relax!;Run!
Eat! Relax! or Relax! Eat! Run!
D)The program results in computer error(s)

ANS: B

19.Refer the incomplete code given below:


public class Tester {
public static void main(String[] args) {
int[] numbers = {216,214,238,189,222,293};
_A_(_B_:_C_){
System.out.println(number);
}
}
}
Choose from below a valid option to complete the above code, in the order
as it appears, to display all the items in the numbers array.
A)forEach, int number, numbers
B)for, int number, int numbers
C)for, int number, numbers
D)forEach, numbers, number

ANS: C

20.Refer the code given below, Choose the correct option.


interface A {
default void display() {
System.out.println("A");
}
}
class Demo implements A {
public void display() {
System.out.println("demo");
}
}
public class Test {
public static void main(String []args) {
A ref=new Demo();
ref.display();
}

A) A
B) demo
C) Compilation error
D) runtime error

ANS: B

You might also like