Java Techgenics MCQ 1


Hello guys if you are looking for Java Techgenics Multiple choice questions then here you will get Java Techgenics MCQ 1 Objective type questions | Java Techgenics MCQ 1 Accenture | Java Techgenics MCQ 1 Dumps | Java Techgenics MCQ 1


Select most appropriate statement
Ans:- Anonymous class does not have a name 
class Example {
public static void main(String[] args) { 
String phone = "APPLE"; 
switch(phone) {
case "Apple": System.out.println("Apple"); 
case "APPLE": System.out.println("APPLE"); 
default: System.out.println("Samsung"); 
}}}
Ans :- APPLE Samsung 

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 PemanentEmployee(); 
employee.changeSalary();
}}
Ans :- 12

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

class Derived extends Base{ 
public int a=8;
public void addFive() { 
this.a+=5;
System.out.println("Derived :"+a); } } 
public class Demo{
public static void main(String args[]) { 
Base b=new Derived();
b.addFive(); System.out.println(b.a); } } 
Ans :- Derived 13

public class Tester {
public void myMethod(){ 
System.out.println("Method"); }
{ System.out.println("Instance block"); } 
public void Tester(int num){
System.out.println("Constructor"); }
static{ System.out.println("Static block 1"); } 
static{ System.out.println("Static block 2"); } 
public static void main(String[] args) { 
Tester m =new Tester();
m.Tester(5);
m.myMethod(); } }
Ans:-  Static block 1
Static block 2 
instance block 
constructor 
method

public class Tester{
public static void main(String[] args){ 
String a[]={"rat","cat"};
String str="bat"; 
a[1]=str; str="mat";
for(int i=0;i<str.length(),i++) 
{ //line1 //line2 }}}
Ans:-  int x =str.charAt(i)-32 
System.out.print((char)x);

public static void main(String [] args){ 
Set mySet =new HashSet();
mySet.add("Z");
mySet.add("P");
mySet.add("M"); } 
Ans:- mySet.add(null);
mySet.add(12.56);
mySet.add("A");
mySet.add(false);

public class ExamThread extends Thread { 
public void run(){
System.out.print("Run!); }
public static void main(String args[]) throws InterruptedException{ 
Thread examThread = new ExamThread();
examThread.start(); 
System.out.print("Eat!"); 
examThread.join();
System.out.println("Relax!"); }
Ans:- when excecuted ,it print one of the following eat!run! relax! or Run! Eat! Relax!

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;j< Line3 ;j++){ 
int sum=sum+ Line4; 
result[i]=sum; }}
for(int i=0;i<result.length;i++){ 
System.out.println(result[i]); }}}
it is required to find the sum of values in each row of intArray and it in result array 
choose from below
a valid option to complete the above code
in the order as ifappear,thet will give the output as 67 
Ans:-new int[intArray.length]
intArray.length
intArray[i].length
intArray[i][j]

class TechVersentThread extends Thread{
public static void main(String[] args) throws Exception{ 
Thread.sleep(2000);
System.out.println("Accenture"); } }
Ans:-The code executes normally and prints 'Accenture” 

public class ExectionHandling {
public static void main(String[] args) { 
try {
System.out.println("Hello"); 
throw 89; }
catch(Exception ex)
{ System.out.println("World"); } } } 
Ans :- Compilation Error

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"); } } 
Ans:-Object created is an instance of i1
Object created is an instance of i3

pubic class ExcepctionHandle{ 
public static void main(String [] args){ 
try{ throew new IOException(); } 
catch(IOException|Exception ex){ 
System.out.println(ex + "handled"); } 
Anss:- Compilation Error
public static void main{ 
Try{
FileOutputStream fout=new FileOutputStream("file.txt"); 
fount.write(65); fount.close();}
catch(Exception e){ 
System.out.println(e);}} 
Ans:- A

which one of the following is not a severity in SonarQube? 
Ans:- issues

which one of following cannot be declared as static? 
Ans:- Constructor

Refer the class given below 
class Customer{
private int customerid; 
private String customerName; }
identify the correct paramterized constructor declarations 
Ans:- public Customer(int customerid){
this.customerid=customerid; }
public Customer(String customerName){ 
this.customerName=customerName; }
Choose from below the CORRECT statements about main (STARTER) method 
Ans:-The main method must be declared as public static void,
Java virtual machine calls the main method directly, 
Program execution starts from main method only

Who is responsible for prioritizing Product backlog 
Ans:- Product Owner

interface A {
default void display() { 
System.out.print(""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(); } }
Ans:- Demo

Which of the following is not a Build Tool 
Ans:- Jenkins

Chhose the below CORRECT statement. Statement A:Every instance of the class shares the class variable, 
which is in one fixed memory Statement B:Every instance of the class get seperate copy of instance variable. 
Ans:- Statement A and B

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 
Ans :- for, int number, numbers

public class Main {
public static void main(String[] args) { 
int t=5; try{
System.out.print("java"+""+t/0); } 
catch(ArithmeticException e){
System.out.print("Standard Edition"); }}} 
Ans:- Standard Edition

class Person{ 
void display(){
System.out.println("Person display method"); } }
class Employee extends Person{ public void display(){//Line 8 
System.out.println("Employee display method"); } }
public class Test{
public static void main(String[] args){
Person employee=new Employee(); //Line 15 employee.display(); } } 
Ans:- Employee display method
which of the following align with agile principles? 
Ans:-welcome changing requirements 
ensure customer satisfaction

Which od the following is full software development kit of java? 
Ans:- JDK

public class Tester{
public static void main(String[] args){ 
String test = "a b c d";
String str[] = test.split(" "); 
for(int i=0;i<str.length;i++){
System.out.print(str[i].charAt(0)-32+ " "); 
}}}
Ans:- 65 66 67 68

public class Tester{
public static void main(String[] args) { 
String s="helloo";
int count =0;
char [] c =s.toCharArray(); 
for(int i=0;i<c.length;i++){ 
int first = s.indexOf(c[i]); int 
last = s.lastindexOf(c[i]); 
if(first==last){
Count++; }}
System.out.println(count); }} 
Ans:- 2

Which keyword ensures that at a time only one thread should execute the method? 
Ans:- Synchronized

which one of the following is not a primary component of sonarQube? 
Ans:- Sonarlint

Amrita want to use software configuration management in her project. pick need of scm usage from below list 
of options
Ans:- ensure integration of code changes 
maintain revision history

Which modifiers are allowed to the methods of a java 8 interface? 
Ans:- Default
Static

public class Tester{ 
int x =10; static{ 
int x =20;
System.out.println(x); }
public static void main(String[] args){
Tester t = new Tester(); System.out.println(t.x); }} 
Ans:- 20 10

Refer the incomplete code given below 
class Sample {
public void m1(int a,float b) {
System.out.println("inside m1 method"); }
public void m1(----------,------------) { //Line 6
System.out.println("inside overloaded m1 method"); } 
public static void main(String ar[]) {
Sample d=new Sample(); d.m1(20,20); //LIne 12 } 
Ans:- int a, int b
Float a, float b

public class Tester{
public static void main(String[] args) {String name = "computer";
StringBuffer sb = new StringBuffer(name);
StringBuffer sb1 = new StringBuffer();
String name1 = // Line 1 
char[] c = // Line 2
for(int i=0;i<c.length;i++) { 
sb1.append(c[i]);
sb1.append("-"); }
System.out.println(//Line 3); }}
Choose from below a valid option to complete the above code, in the order as it appears, that will give the 
output as r-e-t-u-p-m-o-c
Ans:- Line1:- sb.reverse().toString() 
Line2:- name1.toCharArray()
Line3:- sb1.substring(0,sb1.length() - 1)

public class Employee {
private int id=1000; 
public Employee() { id++; }} 
Ans:- Static

class Printer{
int inkLevel; void printInkLevel() { 
System.out.println(inkLevel); } } 
class LaserPrinter extends Printer{ 
int pagesPerMin;
void printPagesPerMin() {
System.out.println(pagesPerMin); } 
public static void main(String[] args) { 
Printer myPrinter=new LaserPrinter();
System.out.println( Line1 .pagesPerMin); Line2 .printInkLevel(); } }
Choose from below a valid option to complete the above code in the order as it appears 
Ans:- ((LaserPrinter)myPrinter)
myPrinter

public static void main(String[] args) { 
try { int i; for(i=0;i<1;i++)
continue; System.out.println(i+" "); } 
finally{ System.out.println("Continue"); } } 
Ans:- 1 continue

class Sample {
public void m1(int a,float b) {
System.out.println("inside m1 method"); } 
public void m1(float a,int b) { //Line 6
System.out.println("inside overloaded m1 method"); } 
public static void main(String ar[]) {
Sample d=new Sample(); 
d.m1(20,20); //LIne 12 } }
Ans:- compilation error aat Line12 method m1(int,float) is ambiguous

class TechVersantThread extends Thread { 
public void run() {
System.out.println("Accenture"); }
public static void main(String[] args) throws InterruptedException { 
Runnable r=new TechVersantThread ();
Thread myThread=new Thread(r); myThread.start(); } }
Ans:- Accenture OR The program will compile with no errors and will print “Accenture” in the console. 

class A { static {
System.out.println("A-static"); } }
class B extends A {static {
System.out.println("B-static"); } }
public class tester { static {
System.out.println("tester-static");} 
public static void main(String[] args) { 
A a=null; A a2= new A(); B b1=new B(); } } 
Ans:- tester-static
A- static 
B-static

interface I1{
int i = 1111; void method1(); }
interface I2{ int i =2222; public void method1(); }
interface I3 extends I1, I2{
int i =3333; public void method1(); } 
class A implements I3{
public void method1(){ 
System.out.println(i); } } 
Ans:- 3333 3333 3333

interface l1{ 
void display();
int methodA(int x); }
interface l2{
int methodB(int x); }
Ans:- class A implements l1,l2{
public void display() {}
public int methodA(int x) {return x;}
public int methodB(int y) {return y;} }
class A extends Thread implements l1,l2{
public void display() {}
public int methodA(int x) {return x;}
public int methodB(int y) {return y;} }

1. Product owner: Ans:- B(creates and maintain product backlog)
2.Scrum master: Ans:- C (conducts daily standup meetings)
3.Scrum team: Ans:- A (develops working software ) 
Ans:- 1-b, 2-c, 3-a

public class Tester{
public static void main(String[] args){
Line1 data={"1001,Jack,2000","1002,Dan,1000","1003,Jane,2000","1004,Stuart,1000"}; 
int salary[]=new int[data.length];
int sum=0;
for(int i=0;i<data.length;i++){ 
Line2 row=data[i];
Line3 normalData=row Line4; 
int sal= Line5 (normalData[2]); 
sum=sum+sal;
salary[i]=sal;}
System.out.println("Salary details"); 
for(int i=0;i<salary.length;i++) { 
System.out.println(salary[i]);} 
System.out.println("Sum is "+sum);}}
It is required to get the sum of salary and populate the salary array with salary. choose 
the valid option
Ans:- String[] , String , String[] , split(",") , Integer.parseInt

public class TryCatch {
public static void main(String[] args) { 
try{ int i,num; num = 10; for(i=-1;i<3;++i){ 
num=(num/i); } }
catch(ArithmeticException e) {
System.out.print("ArithmeticException"); } 
System.out.print(num); } }
Ans:- CTE

interface TestInterface{
void display(String message); } 
public class Demo {
public static void main(String[] args) {
//Line -X TestInterface obj=new TestInterface() { 
public void display(String message) {
System.out.println(message); } }; //Line -Y 
obj.display("Java"); } }
Ans:-TestInterface obj=(message)->System.out.println(message); 
TestInterface obj=(String message)->System.out.println(message);

public class A{ 
static int c=0;
public static void main(String[] args) {
A a1=c(); A a2=c(a1); A a3=c(a2); A c4=c(a3); } 
private A() { System.out.print("c=" + c+" "); } 
static A c() { return c++>=0?new A() : null; } 
static A c(A a) { return c++==0?new A():null; } } 
Ans:- c=1, c=2 OR c=1,c=2,c=3,c=4

which interface are implemented by outputstream? 
Ans:- Closable, Autocloseable, Flushable

which of the folowing is not part of agile manifesto 
Ans:- working software over following a plan

In a Project, DevOps is adopted by adhering to the below characterstics. 
Choose the correct characterstics offered by DevOps
1.Stable and operable software
2.Consistent and optimised release process
3.High risk and low throughput of changes
4.Low available and dependable environments 
Ans:- Statement 1 and 2 are true

Choose from below the correct statement 
Ans:-
Java Interpreter convert byte code into machine code and execute it. 
Java compiler do transaction at once.

public class Demo {
public static void main(String ar[]) { 
String game="your game";
do{ game=game.concat(" plan"); 
System.out.println(game); } 
while(game.length()<10); }}
Ans:- will print YOUR GAME PLAN only once

public class Main {
public static void main(String[] args){ 
byte myValues[] ={81,82,83,84,85,86}; 
String m1 = new String(myValues); 
System.out.println(m1);
String m2 =m1.substring(2,5); 
System.out.println(m2); }} 
Ans:-
QRSTUV 
STU

import java.io.IOException; 
public class Demo{
public static String m1(){try {
System.out.println("In try Block"); return "return from try-catch"; } 
catch(Exception e) { return "return from the catch"; }
finally { System.out.println(" In Finally Block"); } } 
public static void main(String ar[]) {
System.out.println(m1()); } } 
Ans:-in try block
in finally block 
return from try-catch

interface I1 {
public void calculate(int x); } 
interface I2 {
public void calculate(int x); 
public void cube(int x); } 
class A implements I1 { 
public void calculate(int x) {
System.out.println("Square value: "+(x*x)); } 
public void cube(int x) {
System.out.println("Cube value: "+(x*x*x)); }
................(continue question) 
Ans:-
I1 , A 
A,A

class Employee { 
double salary=1000; } 
class Increment {
public void incrementEmp(Employee employee) { 
employee.salary=employee.salary+1; }
public void incrementint(int a) { 
a=a+1; }}
public class Main{
public static void main(String arg[]) { 
Employee employee=new Employee(); 
int a=10;
Increment increment=new Increment();
increment.incrementEmp(employee); increment.incrementint(a); 
System.out.println("Salary :"+employee.salary);
System.out.println("a :"+a);}} 
Ans:-
Salary:1001.0 
a:10

66 dekhna h mcq nupur
Scrum is used for managing a product/application. One of the team member, Peter has a responsibility of .. 
overal project vision.What is the scrum role played by him?
Ans:- Product Owner

public class ExceptionHandler {
public void divide(int a, int b) {try { int c=a/b; 
System.out.println(c); }catch(Exception e){ 
System.out.println("Exception"); }
finally { System.out.println("Finally"); } } 
public static void main(String[] args) {
ExceptionHandler obj = new ExceptionHandler();obj.divide(0,3); } } 
Ans:-
0 
Finally

choose from the below INVALID Loops 
Ans:- for(int i=3;i<=99;i*2)

which one of the following is not a value for 'dependency scope' in maven 
Ans:- Export

public class Tester {
public static void main(String[] args) { 
int sum = 0;
String test="hello i love java";
String str=test.indexOf('e')+" "+test.indexOf('a')+" "+test.indexOf('l')+" "+test.indexOf('a') 
for(int i=0;i<str.length();i++){
if(str.charAt(i)!=' ') {
sum = sum+str.charAt(i);}} 
System.out.print(sum);}} 
Ans:- 309

Class A1{ static int x =20; static int y=30; static{
X++; –y;} public static void updation(){ x = ++x; y= ++y; 
System.out.print(x+””); System.out.print(y);}
Static{ x–; ++y;}
……….. (continue question) 
Ans:- 20 30 21 31

class vehicle{
public vehicle(int manufacturingyear){ 
display();
System.out.println("vehicle manufactured in the year:"+manufacturingyear);} 
public vehicle(String registrationNo){ display();
System.out.println("vehicle created with registration no:"+registrationNo);} 
public void display(){
System.out.println("vehicle display method");}} 
class car extends vehicle{ public car(){ 
super(2020); S.o.pln("car created");}
public car(int manufacturingYear){ 
super(manufacturingYear);
S.O.PLN("Car manufactured in the year:"+manufacturingYear); 
Ans:-
car display method
vehicle manufactured in the year:2020 
car created

public class Student //code //Line 1 { 
int id; String name;
public Student(int id, String name) { 
this.id=id; this.name=name; } }
public class Client { public static void main(String[]args) { 
Student student=new Student(101, "Mark");
try {
ObjectOutputStream object=new ObjectOutputStream(new FileOutputStream ("student.txt")); 
//Line 2 }
catch (Exception e) { e.printStackTrace(); } } } 
Ans:- Serializable, object.writeObject();

class Hotel {
public int bookings; private void book() { 
bookings++; } }
class SuperHotel extends Hotel {
public void book() { bookings--; }
public void book(int size) { book(); bookings+=size; } }
public class TestHotel {
public static void main(String ar[]) { 
Hotel hotel=new Hotel(); hotel.book(2); 
sop(“hotel bookings);}}
Ans:-
change line 3 to public void book() and line 20 to hotel.book(); 
change line 19 to SuperHotel hotel=new SuperHotel();

public class Client {
public static void main(String[]args) {
Student student=new Student(101, "Mark"); try {
ObjectOutputStream object=new ObjectOutputStream(new FileOutputStream ("student.txt")); 
//Line 2 } catch (Exception e) {
e.printStackTrace(); } } }
Ans:- ObjectOutputStream.writeObjrct……….

Tina adopted Agile and Devops in her project. What are the benefits offered by Agile in DevOps practice 
Ans:- faster Delivery
Failing Fast or Avaibility

Topic: Agile and DevOps Sub Topic:
DevOps Overview Sean, a DevOps Engineer is planning to adopt continuous deployment is his project for 
faster delivery of the product.Which tool can ber used to accomplish his goal?
Ans:- Jenkins


Leave a Reply

Your email address will not be published. Required fields are marked *