PHP Tutorial

PHP Examples

PHP Practice

PHP JSON Aptitude Questions and Answers

PHP JSON Aptitude Questions and Answers: This section contains aptitude questions and answers on PHP JSON. By Nidhi Last updated : December 15, 2023

This section contains Aptitude Questions and Answers on PHP JSON.

1) There are the following statements that are given below, which of them are correct about JSON in PHP?
  1. JSON stands for JavaScript Object Notation.
  2. JSON stands for JavaScript OOPS Notation.
  3. JSON is a data format that is used to store and exchange data.
  4. JSON is a text-based format.

Options:

  1. A and C
  2. B and C
  3. A, C, and D
  4. D

2) Which of the following function is used to encode the data into JSON format?
  1. jsonencode()
  2. json_encode()
  3. encode_json()
  4. None of the above

3) What is the correct output of given code snippets in PHP?
<?php
$roll_no = array(
    "SHAURYA" => 101,
    "DUGGU" => 102,
    "Joe" => 103
);
echo json_encode($roll_no);
?>
  1. {"SHAURYA":101,"DUGGU":102,"Joe":103}
  2. {"SHAURYA"->101,"DUGGU"->102,"Joe"->103}
  3. {"SHAURYA"=>101,"DUGGU"=>102,"Joe"=>103}
  4. None of the above

4) What is the correct output of given code snippets in PHP?
<?php
$students = array(
    "SHAURYA",
    "DUGGU",
    "Joe"
);
echo json_encode($students);
?>
  1. {"SHAURYA","DUGGU","Joe"}
  2. ["SHAURYA","DUGGU","Joe"]
  3. <"SHAURYA","DUGGU","Joe">
  4. ("SHAURYA","DUGGU","Joe")

5) What is the correct output of given code snippets in PHP?
<?php
$students = '["SHAURYA","DUGGU","Joe"]';
echo json_decode($students);
?>
  1. {"SHAURYA","DUGGU","Joe"}
  2. Error
  3. Array
  4. None of the above

6) What is the correct output of given code snippets in PHP?
<?php
$students = '["SHAURYA","DUGGU","Joe"]';
echo var_dump(json_decode($students));
?>
  1. {"SHAURYA","DUGGU","Joe"}
  2. ["SHAURYA","DUGGU","Joe"]
  3. array(3) { [0]=> string(7) "SHAURYA" [1]=> string(5) "DUGGU" [2]=> string(3) "Joe" }
  4. None of the above

7) What is the correct output of given code snippets in PHP?
<?php
	$students = {"SHAURYA":101,"DUGGU":102,"Joe":103};
	echo var_dump(json_decode($students));
?>
  1. object(stdClass)#1 (3) { ["SHAURYA"]=> int(101) ["DUGGU"]=> int(102) ["Joe"]=> int(103) }
  2. {"SHAURYA","DUGGU","Joe"}
  3. Garbage value
  4. Error

8) What is the correct output of given code snippets in PHP?
<?php
$students = '{"SHAURYA":101,"DUGGU":102,"Joe":103}';

$data = json_decode($students);
echo $data->DUGGU;
?>
  1. 102
  2. DUGGU
  3. Error
  4. None of the above

9) What is the correct output of given code snippets in PHP?
<?php
$students = '{"SHAURYA":101,"DUGGU":102,"Joe":103}';

$data = json_decode($students);
echo $data['DUGGU'];
?>
  1. 102
  2. DUGGU
  3. Error
  4. None of the above

10) Can we transfer JSON data using the web-method call in the web service implementation?
  1. Yes
  2. No

Learn PHP programming with our PHP tutorial.

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.