Section - Computer Science. int main() {! int a=10,b=20;! printf("a:%d B:%d\n",a,b);! a=(a+b)-(b=a);! printf("a:%d B:%d\n",a,b);!

Similar documents
Section - Computer Science

INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS

Pointers, Dynamic Data, and Reference Types

CSC 1600 Memory Layout for Unix Processes"

Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions?

In Java we have the keyword null, which is the value of an uninitialized reference type

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #1 Examination 12:30 noon, Tuesday, February 14, 2012

Chapter 2 (Dynamic variable (i.e. pointer), Static variable)

CSCI 262 Data Structures. Arrays and Pointers. Arrays. Arrays and Pointers 2/6/2018 POINTER ARITHMETIC

Low-Level C Programming. Memory map Pointers Arrays Structures

Suppose we find the following function in a file: int Abc::xyz(int z) { return 2 * z + 1; }

CS Programming In C

CS201 Some Important Definitions

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

C Introduction. Comparison w/ Java, Memory Model, and Pointers

Instructions: Submit your answers to these questions to the Curator as OQ02 by the posted due date and time. No late submissions will be accepted.

Largest Online Community of VU Students

Lectures 5-6: Introduction to C

Dynamic Memory: Alignment and Fragmentation

Dynamic Memory. Dynamic Memory Allocation Strings. September 18, 2017 Hassan Khosravi / Geoffrey Tien 1

CSCI 2132 Software Development. Lecture 29: Dynamic Memory Allocation

Short Notes of CS201

Name: Username: I. 20. Section: II. p p p III. p p p p Total 100. CMSC 202 Section 06 Fall 2015

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #07. Topic: Pointer in C Date:

CS201 - Introduction to Programming Glossary By

Lecture 2: C Programm

THE GOOD, BAD AND UGLY ABOUT POINTERS. Problem Solving with Computers-I

1. Which of the following best describes the situation after Line 1 has been executed?


The combination of pointers, structs, and dynamic memory allocation allow for creation of data structures

Notes on the Exam. Question 1. Today. Comp 104:Operating Systems Concepts 11/05/2015. Revision Lectures (separate questions and answers)

CS201- Introduction to Programming Current Quizzes

Quiz 0 Review Session. October 13th, 2014

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

Comp 204: Computer Systems and Their Implementation. Lecture 25a: Revision Lectures (separate questions and answers)

Computer Science 217 Final Exam May 15, :30pm-4:30pm

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

SEMANTIC ANALYSIS TYPES AND DECLARATIONS

Dynamic Allocation of Memory

Contents of Lecture 3

Question 1. Notes on the Exam. Today. Comp 104: Operating Systems Concepts 11/05/2015. Revision Lectures

04-17 Discussion Notes

Algorithms & Data Structures

Midterm Review. PIC 10B Spring 2018

Class Information ANNOUCEMENTS

CS 241 Data Organization Binary Trees

Memory Organization. The machine code and data associated with it are in the code segment

Declaring Pointers. Declaration of pointers <type> *variable <type> *variable = initial-value Examples:

Introduction to Linked Lists

M1-R4: Programing and Problem Solving using C (JAN 2019)

CE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings

Kurt Schmidt. October 30, 2018

CS 3330 Final Exam Spring 2016 Computing ID:

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

Dynamic Memory Allocation and Linked Lists

Quiz Start Time: 09:34 PM Time Left 82 sec(s)

A program execution is memory safe so long as memory access errors never occur:

CP2 Revision. theme: dynamic datatypes & data structures

Kapi ap l S e S hgal P T C p t u er. r S. c S ienc n e A n A k n leshw h ar ar Guj u arat C C h - 8

CA31-1K DIS. Pointers. TA: You Lu

CS201 Latest Solved MCQs

APS105. Malloc and 2D Arrays. Textbook Chapters 6.4, Datatype Size

CMSC 330: Organization of Programming Languages

ECE 2035 Programming HW/SW Systems Fall problems, 5 pages Exam Three 28 November 2012

pthreads CS449 Fall 2017

o Code, executable, and process o Main memory vs. virtual memory

Character Strings. String-copy Example

Introduction. This project will focus primarily on processes.

Pointers and Arrays CS 201. This slide set covers pointers and arrays in C++. You should read Chapter 8 from your Deitel & Deitel book.

COMP 524 Spring 2018 Midterm Thursday, March 1

Introduction to C Language (M3-R )

Fall 2015 COMP Operating Systems. Lab #3

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS

Data Structure (CS301)

Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University

Practice Sheet #07 with Solutions

Week 3 Lecture 2. Types Constants and Variables

cout << "How many numbers would you like to type? "; cin >> memsize; p = new int[memsize];

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.

CA341 - Comparative Programming Languages

C Programming Basics II

Pointers and References

Dynamic Allocation in C

Dynamic Memory Allocation and Command-line Arguments

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

School of Information Technology and Computer Science CSCI192 - Spring Session Revision

CS261: HOMEWORK 2 Due 04/13/2012, at 2pm

Processes. Johan Montelius KTH

CMSC 330: Organization of Programming Languages. Memory Management and Garbage Collection

Lecture 3: C Programm

Computer Systems II. First Two Major Computer System Evolution Steps

What is Pointer? Pointer is a variable that holds a memory address, usually location of another variable.

FORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam II:

A process. the stack

a data type is Types

CSCI 237 Sample Final Exam

CMSC 330: Organization of Programming Languages

Intro to C: Pointers and Arrays

C Multiple Choice Questions and answers MCQ with Ans.

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ...

Transcription:

Section - Computer Science 1. What will be the output of the following piece of code? int! int a=10,b=20;! printf("a:%d B:%d\n",a,b);! a=(a+b)-(b=a);! printf("a:%d B:%d\n",a,b);! return 1; (i) A: 10, B: 20 (ii) A: 20, B: 10 (iii) A: 30, B: 20 (iv) A: 20, B: 30 2. What will be the result of the following C language program?! int a = 0; int b = 20; char x = 1; char y = 10; if(a,b,x,y)! printf("welcome"); (i) Welcome (ii) Blank (iii) Compiler error (iv) Linker error 3. What will be the result of the following C language program? void!! int const *p = 5;! printf("%d",++(*p)); (i) 6 (ii) 5 (iii) Linker error (iv) Compiler error

4. Given any initial natural number, consider the sequence of numbers generated by repeatedly following the rule: divide by two if the number is even or multiply by 3 and add 1 if the number is odd. Suppose that the initial number is 23. Which of the following numbers appear in the resulting string of numbers? (i) 1 (ii) 12 (iii) 36 (iv) 150 5. What will be the result of the following C language program? struct date;! struct student! char name[30];! struct date dob; stud; struct date int day, month, year; ; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month); (i) Compiler error: Undefined structure dob (ii) Compiler error: Undefined structure name (iii) Compiler error: Undefined structure date (iv) Linker error 6. What does the following C language declaration mean?!! int (*decl)[30] (i) array[30] of pointer to int (ii) function returning pointer to int 30 (iii) pointer to array[30] of int (iv) None of the above 7. With respect to the C++ programming language, which is the parameter that is added to every non-static member function when it is called? (i) this pointer (ii) that pointer (iii) datatype (iv) return value

8. The following piece of code will be allowed to execute by the compiler? struct A int a; int f() const return a++; ; 9. In C++, pass by value always invokes the function or returns a value that is based on the value. This value is passed as a constant or a variable with value. (i) Yes, always (ii) Only sometimes (iii) No, never (iv) None of the above 10. In following C language program, which statement would you add in the function fun so that the address of a gets stored in j?! int *j;! void fun(int **);! fun(&j); void fun(int **k)! int a = 0;! /* Add the statement here*/ (i) **k = &a (ii) *j = &a (iii) *k = &a (iv) *a = &k 11. What will be the result of the following C language program?!!! int i = 258;! int *iptr = &i;!! printf("%d %d", *((char*)iptr), *((char*)iptr+1) ); (i) 258 0 (ii) 1 0 (iii) 2 1 (iv) 1 2

12. Which of the following statements is not true? (i) A message provides response to a method (ii) Objects communicate by sending messages to each other (iii) A dangling pointer arises when you use the address of an object after its lifetime is over. (iv) An wrapper class is a class with no functionality of its own. 13. Which of the following statements is not true? (i) A memory leak occurs when a program loses the ability to free a block of dynamically allocated memory. (ii) Objects that point to other objects are called null objects. (iii) A handle class is a class that maintains a pointer to an object that is programmatically accessible through the public interface of the handle class. (iv) A common form of an action class is a simple class containing just one virtual function. 14. Which of the following statements is not true? (i) NULL can be a value for pointer type variables. (ii) VOID is type identifier which has no size. (iii) null *ptr = VOID (iv) void *ptr = NULL 15. How many different trees are possible with 10 nodes? (i) 1024 (ii) 1014 (iii) 1000 (iv) 1034 16. For the following tree, the pre-order traversal can be represented by (i) F, G, H, I, A, B, C, D, E, (ii) F, B, G, A, D, I, C, E, H (iii) A, B, E, D, C, F, G, H, I (iv) A, B, C, D, E, F, G, H, I 17. Which of the following statements are incorrect? (i) Spatial locality, refers to the reuse of specific data, and/or resources, within a relatively small time duration. (ii) Temporal locality, refers to the use of data elements within relatively close storage locations. (iii) Both are incorrect. (iv) Neither one is incorrect.

18. You can search the data in a linked list by using (i) Binary search (ii) Hash search (iii) Self-organizing search (iv) Linear search 19. The following piece of code will be allowed by the C++ compiler? class A class B; public: class B ; ; 20. Context switching can occur only in the kernel mode. 21. What will be the output of the following lines of program code?! fork(); printf("hello World!"); (i) Hello World! (ii) Hello World!Hello World! (iii) Blank (iv) None of the above 22. The stack is where the malloc() gets memory. 23. When a process creates a new process using the fork() operation, which of the following is shared between the parent process and the child process? (i) Shared memory segments (ii) Stack (iii) Heap (iv) All of the above

24. Consider the following piece of code. class A /*... */ ; class B /*... */ ; class C /*... */ ; class Z : A class Y : B class X : C int f(); /*... */ ; ; ; int Z::Y::X f() char j; return 0; Here, the search for the name j in the definition of function f follows the order: (i) In body of f --> In X and C --> In Y and B --> In Z and A --> Global Scope (ii) In body of f --> In X and C --> In Y and B --> In Z and A (iii) In body of f --> In Z and A --> In Y and B --> In X and C (iv) In body of f --> In Z and A --> In Y and B --> In X and C --> Global Scope 25. Which of the following statements is not true? (i) Kernel threads need not be associated with a process whereas every user thread belongs to a process (ii) User level threads are unknown to the kernel whereas the kernel is aware of the kernel threads (iii) Kernel threads are less expensive to maintain that user threads (iv) Thread creation typically uses less resources than process creation