Json - Interview Questions and Answers for 'L' - 8 question(s) found - Order By Newest Q1. What are the benefits of JSON over XML ? Json
Ans. Lighter and faster than XML as on-the-wire data format
Object Representation - Information is presented in object notations and hence better understandable.
Easy to parse and conversion to objects for information consumption.
Support multiple data types - JSON supports string, number, array, boolean whereas XML data are all string. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  json   markup language Asked in 1 Companies intermediate   frequent Try 1 Question(s) Test Q2. What is JSON ? Json
Ans. JSON is "JavaScript Object Notation", primarily used for client-server or server-server communication. Its a much lighter and readable alternative to XML. JSON is language independent and is easily parse-able in all programming languages. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  json   markup language   client server communication Asked in 26 Companies basic   frequent Try 2 Question(s) Test Q3. Which function is used to convert a JSON text into an object ? Json
Ans. eval Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  json   markup language Q4. Which data types are supported by JSON ? Json
Ans. Number String Boolean Array Object null Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  json   markup language   client server communication Q5. Which markup languages can be used in restful web services ? Rest
Ans. XML and JSON ( Javascript Object Notation ). Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   web services   rest   java   j2ee   xml   json   architecture basic   frequent Q6. Can you explain JSON specification ? JSON
This question was recently asked at 'One Click Retail'.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 1 Companies Q7. Can comments be added in JSON ? JSON
Ans. No, It should all be data. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Markup languages Q8. Why would you use XML over JSON when using ajax ? JSON
This question was recently asked at 'SoftLayer'.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  xml  ajax  json Asked in 1 Companies Q9. 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
Q10. 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
Q11. 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
Q12. 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
Q14. 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
Q15. 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
Q16. 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");
Q17. 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
Q18. 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
Q19. 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
Q20. 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
Q21. Which of the following is true for == operator ? Core Java
a. For primitives, == checks if the variables on left and right have same data type b. For primitives, == checks if the variables on left and right have same value c. For Objects, == checks if the references on left and right have same data type d. For Objects, == checks if the references on left and right have same valueAns.b. For primitives, == checks if the variables on left and right have same value
Q22. Which of the following is equivalent to following logic ?
Not X && Not Y Core Java
a. x || Y b. Not(X || Y) c. Not(X && Y) d. Not X && YAns.b. Not(X || Y)
Q23. Optional has been introduced in Java 8 to get away with which of following exception ? Reference Core Java
a. ArithmeticException b. ParseException c. NullPointerException d. FileNotFoundExceptionAns.c. NullPointerException
a. Abstract Class is only meant to be sub classed and not supposed to be instantiated. b. Abstract class handlers can be used to handle derived class objects. c. We can't have an abstract class without abstract methods. d. Abstract class has member elements. Ans.c. We can't have an abstract class without abstract methods.
a. String b. StringBuffer c. StringBuilder d. None of these create immutable objects.Ans.a. String
a. String b. StringBuffer c. StringBuilder d. None of theseAns.b. StringBuffer
Q27. Which of the following methods are used by Java Garbage Collection Mechanism ? Core Java
a. final b. finally c. finalize d. All of the aboveAns.c. finalize
Q28. Which of the following about Garbage collection is false ? Core Java
a. We can call Garbage collection explicitly b. Garbage Collection guarantees that the application will not run out of memory c. finalize method is used by Java for Garbage Collection d. Garbage Collection Mechanism delete unclaimed objects that are no longer requiredAns.b. Garbage Collection guarantees that the application will not run out of memory
a. Feature to load the dependencies from Cache b. Feature to load all objects and relationships in advance before they can be used c. Feature to not load dependencies and relationship in advance and load when required d. Feature to not load the dependencies and relationships at allAns.c. Feature to not load dependencies and relationship in advance and load when required
Q30. Which of the following is not the benefit of Lazy Initialization in Hibernate ? Hibernate
a. Laod When required provides better performance b. Object stays lighter c. Less number of Database calls d. Less load on DatabaseAns.c. Less number of Database calls