Interview Questions and Answers - Order By Newest Q2611. Will the following code give any error
let result: string | number;
result = 'true'; Typescript
Ans. No Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q2612. Will the following code give any error
let result: boolean;
result = false | true; Typescript
Ans. Yes, | is a bitwise operator and not boolean or. Use || instead Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q2613. Will this code give any error ?
let result: boolean;
result = false || true; Typescript
Ans. No Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q2614. Will this code give any error ?
let result: boolean | string;
result = false || 'true'; Typescript
Ans. No Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q2615. Will this code give any error ?
let result: string;
result = false || 'true'; Typescript
Ans. No Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q2616. What is systemd in Unix ? Unix
This question was recently asked at 'Broadcom, Symantec'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies Q2617. What is Array.Map function ? What will be output of following ?
const myArray = [1, 4, 9, 16];
const result = myArray.map(x => x * 2); Javascript
Ans. It will create an array with each value as x*2
[2, 8, 18, 32] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies Q2618. What would you use the span element for ? HTML
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   a. Constructor without parameters declared by user b. Constructor provided by Java if no constructor is declared c. Constructor with empty body d. All of the aboveAns.b. Constructor provided by Java if no constructor is declared
Q2620. How can we create objects if we make the constructor private ? Core Java
a. We can't create objects if constructor is private b. We can only create objects if we follow singleton pattern c. We can only create one object d. We can create new object through static method or static blockAns.d. We can create new object through static method or static block
Q2621. What will be the output of following ?
String str1 = new String("String1");
String str2 = new String("String1");
System.out.print(str1 == str2);
System.out.print(str1.equals(str2));
str1 = str2;
System.out.print(str1 == str2); Core Java
a. falsetruetrue b. truetruetrue c. truetruefalse d. falsetruefalseAns.a. falsetruetrue
Q2622. What will be the output of following code ?
String str1 = "String1";
String str2 = "String1";
System.out.print(str1 == str2);
System.out.print(str1.equals(str2));
str1 = str2;
System.out.print(str1 == str2); Core Java
a. falsetruetrue b. falsefalsetrue c. truetruetrue d. falsefalsefalseAns.c. truetruetrue
Q2623. Which method needs to be implemented if a class is implementing comparable interface ? Core Java
a. comp b. compare c. compareTo d. compareEqualsAns.c. compareTo
Q2624. Which of the following is false ? Core Java
a. A Class cannot override both hashcode and equals method. b. A class can override both hashcode and equals method. c. A Class must override hashCode method if its overridding equal method. d. A Class can override hashCode even if its not overridding equals method.Ans.a. A Class cannot override both hashcode and equals method.
a. interface b. abstract class c. final class d. util classAns.d. util class
Q2626. Which of the following can throw ClassCastException ? Core Java
a. UpCasting b. DownCasting c. Casting to incompatible data type d. Casting to StringsAns.b. DownCasting
Q2627. x instanceOf y returns false .. Core Java
a. if x is an instance of y class b. if x is an instance of class implementing y interface c. if x is an instance of class extending y class d. if x is an instance of Class which is a parent of Y classAns.d. if x is an instance of Class which is a parent of Y class
a. java.lang.Object b. java.lang.Thread c. java.lang.Runnable d. java.lang.ImplementAns.a. java.lang.Object
Q2629. if classes B and C extends Class A, Which of the following initialization is correct ? Core Java
a. B b = new C(); b. C c = new B(); c. B b = new A(); d. A a = new B();Ans.d. A a = new B();
Q2630. If X implements Y and Y extends Z, Which of the following initialization is correct ? Core Java
a. X x = new Y(); b. X x = new Z(); c. Z z = new Y(); d. Z z = new X();Ans.d. Z z = new X();
Q2631. If class A implements X interface, and Class B implements Y interface, and X is the parent of Y, Which of the following initialization is correct ? Core Java
a. A a = new B(); b. Y y = new A(); c. X x = new B(); d. Y y = new A();Ans.c. X x = new B();
Q2632. What will be the output of executing following class ?
public class BuggyBread {
static {
System.out.println("Static Block");
}
{
System.out.println("Initialization Block");
}
BuggyBread(){
System.out.println("Constructor");
}
public static void main(String[] args){
System.out.println("Main Method");
}
}
Core Java
a. Static Block
Main Method b. Static Block
Instance Initialization Block
Main Method c. Static Block
Constructor
Main Method d. Static Block
Instance Initialization Block
Constructor
Main MethodAns.a. Static Block
Main Method
Q2633. What will be the output upon executing following class ?
public class BuggyBread {
static {
System.out.println("Static Block");
}
{
System.out.println("Instance Initialization Block");
}
BuggyBread(){
System.out.println("Constructor");
}
public static void main(String[] args){
System.out.println("Main Method");
new BuggyBread();
}
} Core Java
a. Instance Initialization Block
Constructor
Static Block
Main Method b. Static Block
Instance Initialization Block
Constructor
Main Method c. Main Method
Static Block
Instance Initialization Block
Constructor d. Static Block
Main Method
Instance Initialization Block
ConstructorAns.d. Static Block
Main Method
Instance Initialization Block
Constructor
Q2634. With the following code, Which is a valid way to initialize ?
public class BuggyBread {
private String element1;
private String element2;
private BuggyBread(String element1, String element2){
this.element1 = element1;
this.element2 = element2;
}
public static class Builder {
private String element1;
private String element2;
Builder(BuggyBread buggybread){
element1 = buggybread.element1;
element2 = buggybread.element2;
}
Builder withElement1(String element1){
this.element1 = element1;
return this;
}
Builder withElement2(String element2){
this.element2 = element2;
return this;
}
BuggyBread build(){
BuggyBread buggybread = new BuggyBread(element1,element2);
return buggybread;
}
}
} Core Java
a. BuggyBread buggybread = new BuggyBread(); b. BuggyBread buggybread = new BuggyBread("element1","element2"); c. BuggyBread.Builder builder = new BuggyBread.Builder(); d. BuggyBread.Builder builder = new BuggyBread.Builder("element1","element2");Ans.d. BuggyBread.Builder builder = new BuggyBread.Builder("element1","element2");
Q2635. What will be the output of following code ?
public class BuggyBread {
private int x;
private int y;
BuggyBread(int x,int y){};
public static void main(String[] args){
BuggyBread buggybread = new BuggyBread();
System.out.println(buggybread.x);
}
} Reference Core Java
a. 0 b. null c. compilation error due to uninitialized element d. compilation error due to constructorAns.d. compilation error due to constructor
Q2636. What will be the output of following ?
public class BuggyBread {
private int x;
private Integer y;
BuggyBread(int x,int y){};
public static void main(String[] args){
BuggyBread buggybread = new BuggyBread(1,2);
System.out.println(buggybread.x);
System.out.println(buggybread.y);
}
} Reference Core Java
a. 0 0 b. 0 null c. null 0 d. null nullAns.b. 0 null
Q2637. What will be the output of following code ?
public class BuggyBread {
private int x;
private Integer y;
private BuggyBread(int x,int y){};
public static void main(String[] args){
BuggyBread buggybread = new BuggyBread(1,2);
System.out.println(buggybread.x);
}
} Core Java
a. compilation error due to private constructor b. compilation error due to uninitialized elements c. 0 null d. 0 0Ans.c. 0 null
Q2638. What will be the output of following code ?
public class BuggyBread {
private int x;
private BuggyBread(int x){
x = x;
};
public static void main(String[] args){
BuggyBread buggybread = new BuggyBread(5);
System.out.println(buggybread.x);
}
}
Core Java
a. compilation error b. undefined c. 0 d. 5Ans.c. 0
Q2639. What will be the output of exceuting main method ?
public static void main(String[] args){
List list = new ArrayList();
list.add(1);
list.add(2);
list.add(3);
System.out.println(list);
} Core Java
a. 1,2,3 b. Order cannot be determined c. compilation error d. 3,2,1Ans.a. 1,2,3
Q2640. What will be the output upon executing main method ?
public static void main(String[] args){
Set set = new HashSet();
set.add(1);
set.add(2);
set.add(3);
System.out.println(set);
} Core Java
a. 1,2,3 b. Order cannot be determined c. Compilation error d. 3,2,1Ans.b. Order cannot be determined