Skip to content

Commit

Permalink
HTML and other new quiz added (#1546)
Browse files Browse the repository at this point in the history
* latest c++,git and CSS question added

* latest react quiz

* html new quiz question added

* style changes

* space changes

* remove extra lines

* CHANGE OF REACT QUIZ

Co-authored-by: Balkrishna Bhatt <BalkrishnaBhatt@MacBook-Pro.local>
  • Loading branch information
BalkrishnaBhatt and Balkrishna Bhatt authored May 17, 2021
1 parent 6f53e90 commit 5a769a3
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 1 deletion.
82 changes: 81 additions & 1 deletion c++/c++quiz.md
Original file line number Diff line number Diff line change
Expand Up @@ -1096,4 +1096,84 @@ void std::mutex::lock(){
void std::mutex::lock(){
while(this->try_lock());
}
```
```
#### Q.62 What is the output of this code?

```c++
printf("1/2 = %f",(float)(1/2));
```
- []1/2 = 0.499999
- []1/2 = 0
- []1/2 = 0.000000 << correct
- [] 1/2 = 0.5
### Q.63 What is the difference between a public and a private class member?
- [] Public members are the same as global variables, so every part of the code has access to them. Private members are the same as automatic variables, so only their class has access to them.
- [] Public members are made accessible to any running application. Private members are made accessible only to the application where the object is instantiated.
- [] Public members will be compiled as shared variables in a multithreaded environment. Private members will be compiled as Thread-local variables.
- [] Public members can be accessed by any function. Private members can be accessed only by the same class's member functions and the friends of the class.
### Q.64 What is the value of x after running this code?
```c++
int x=10, a=-3;
x=+a;
```
- []3
- []7
- []-3
- [] 13
### Q.65 Which statement is true?
- []Only classes can have member variables and methods.
- []C++ supports multiple inheritance.
- []C++ supports only single inheritance.
- [] Only structs can inherit.
### Q.66 Consider a pointer to void, named ptr, which has been set to point to a floating point variable g. Which choice is a valid way to dereference ptr to assign its pointed value to a float variable f later in the program?
```c++
float g;
void *ptr=&g;
```

- []float f=*(float)ptr;
- []float f=(float *)ptr;
- []float f=(float)*ptr;
- [] float f=*(float *)ptr;

### Q.67 What is the .* operator and what does it do?

- []It is the same as the class member access operator, or arrow operator (->), which allows you to access a member of an object through a pointer to the object.
- []It is the pointer to member operator, and it allows you to access a member of an object through a pointer to that specific class member.
- []It is the member access with address of operator, which returns the address of a class or struct member.
- [] It is a combination of the member access operator (.) and the dereference operator (*), so it allows you to access the object that a member pointer points to

### Q.68 For these declarations, which choice shows four equivalent ways to assign the character "y" in the string to a char variable c?

a) c = buff[16];
C = str[5];
C = * (buff+16);
c = * (str+5);
b) C = *(buff[15]);
C = * (str[4]);
c = buff+15;
C-str+4;
c) c = buff[15];
C = str[4];
c = (buff+15);
C = *(str+4);

#### Q.69 What is the output of this code?
```c++
printf("1/2 = %f",(float)(1/2));
```
- [] 1/2 = 0.499999
- [] 1/2 = 0
- [] 1/2 = 0.000000 << correct
- [] 1/2 = 0.5
6 changes: 6 additions & 0 deletions html/html-quiz.md
Original file line number Diff line number Diff line change
Expand Up @@ -1168,3 +1168,9 @@ From [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr): The HT
<base>
<source>
```
#### Q75. Which snippet of HTML, when clicked, makes a phone call on a mobile device?

- [x] <a href="tel: 802-555-1212">Call me</a>
- [ ] <a href="phone">802-555-1212</a>
- [ ] <a href="tel">802-555-1212</a>
- [ ] <a href="phone: 802-555-1212">Call me</a>
85 changes: 85 additions & 0 deletions react/reactjs-quiz.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,3 +633,88 @@ const Star = ({ selected = false }) => <Icon color={selected ? 'red' : 'grey'} /
- [ ] red
- [x] grey
- [ ] white

#### Q60. Which answer best describes a function component?(Not sure answer)
- [ ] `A function component is the same as a class component.`
- [ ] `A function component accepts a single props object and returns a React element.`
- [ ] `A function component is the only way to create a component.`
- [ ] `A function component is required to create a React component.`

#### Q61.Which library does the fetch() function come from?
- [ ] `FetchJS`
- [ ] `ReactDOM`
- [X] `No library. fetch() is supported by most browsers.`
- [ ] `React`

#### Q62.What is the difference between the click behaviors of these two buttons(assuming that this.handleClick is bound correctly)

```javascript

A. <button onClick=fthis.handleClickl>Click Me</button>
B. <button onClick={event => this.handleClick(event)}>Click Me</button>

```

- [ ] `Button A will not have access to the event object on click of the button`
- [ ] `Button A will not fire the handler this.handleClick successfully`
- [ ] `There is no difference`
- [ ] `Button B will not fire the handler this.handleClick successfully`

#### Q63.What will happen when this useEffect Hook is executed, assuming name is not already equal to John?

```javascript
useEffect(() => {
setName("John");
}, [name]);
```


- [ ] `It will cause an error immediately.`
- [ ] `It will execute the code inside the function, but only after waiting to ensure that no other component is accessing the name variable.`
- [ ] `It will update the value of name once and not run again until name is changed from the outside.`
- [ ] `It will cause an infinite loop.`

#### Q64. How would you add to this code, from React Router, to display a component called About?

```javascript
<Route path="/:id" />
```

- [ ] ```javascript
<Route path="/:id"> <About />
</Route>
```
- [ ] ```javascript
<Route path="/tid" about={Component} />
```
- [ ] ```javascript
<Route path="/:id" route={About} />
```
- [ ] ```javascript
<Route>
<About path="/:id" />
</Route>
```

#### Q65. Which class-based component is equivalent to this function component?

```javascript
const Greeting ({ name }) > <h1>Hello {name}!</h1>;
```

- [ ] ```javascript
class Greeting extends React.Component {
constructor() { return <h1>Hello (this.props.name)!</h1>; }
}
```
- [ ] ```javascript
class Greeting extends React.Component { <h1>Hello (this.props.name}!</h1>; }
```
- [ ] ```javascript
class Greeting extends React.Component { return <h1>Hello (this.props.name) 1</h1>; }
```
- [ ] ```javascript
class Greeting extends React.Component ( render({ name }) {
return <h1>Hello (name)} !</h1>;
})
```

1 comment on commit 5a769a3

@denizetkar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All questions added to the C++ quiz file are duplicated. Please, kindly remove them and take a look at this pull request which also suggests improvements there: #1561 .

Please sign in to comment.