Page 1 :
COR) | cc TL, , oswal mcq.pdf - Saved, , , , CONSTRUCTORS, , KNOW THE TERMS, , ass, , 4, , > Defaalt Constructor - It the no-angument comstractor that it eutomatically created by compiler in the absence, of explicit constructoc It will initiakze all the class members to the default value as per their Data Type, , > Explicit Constructor - 11 i the constructor that is created by the programmer, , > Parameterized Constructor - That constructor are required to pass parameters on creation of objects, , > Constructor Overloading - Constructor overloading is the way of having more than one constructor with, diferent parameters list. in such a way that each constructor performs a different task, , GLOSSARY, , > New: Java Unary Operator, , 1% Toker: Internal Value Assagned, , > Separators Comma and Terminators, > Signatures: Function calling parameters, , PT Pp vires cuoice questions, , Ostanv ALONE MCQs, , , , Q. 1. Constructor generated by compiler is known as, (A) copy constrector, (8) default constructor, (C) static constructor, (D) parametessed constructor, Ans. Option (B) i correct:, Explanation: Option A: copy constructor & a, type of constructor which comes into action, only after constructor is define. Hence, wrong., Option C there is no such constructor exist, Mence, wrong,, Option D> It is & type of constructor having, parameter bet, Hence wrong, Option 8: When no constructor is defined in a, program the compiler creates 4 construct or its, own. Hence, option B is right, (Q 2. Which unut of the class gets called when the object, of the class s created?, (A) method, (C) constructor, Ans. Option (C) is correct., Explanation: Option A: method ane called, through the object of the cass after the, creanon of the object Hence, wrong., Option B : object is the part of the class which, invokes the constructor not called Mence,, wrong, And Option D: parameter are the part of the, method Hence, wrong., QB. The technique of calling another constructor from, , B) cher, (D) parameter, , ‘one constructor is called, (A) super constructor (8) Chaining, (©) Overtoading (D) Calling, , Ans. Option (B) is correct., , Explanation: Option A : super constructor no, fech constructor eust. Hence, wrong, Option C : Overloading , is » more than one, constructors with the same class name but of, different form. Hence, wrong and option D is, also wrong,, Option B > is true fact hence, right, Q. 4. What is false about constructor?, (A) Constructors cannot be synchronized in Java, (B) Java does not peovide detaull copy constructor, (Q) Constructor can have a return type, (D) “this” and “super” can be used im a constructor, Ans. Option (C) is correct., | oe, return type. It should create and return new, objects., Q. 5. What would be behavior if the constructor has 4, feturn type?, (A) Compilation error, (B) Rentime error, (©) Compilation and runs successfully, (D) Only Sering return type is allowed, Ass, Option (A) is correct., Explenation: The constructor cannot have, a return type. Hence, error message will be, displayed at the tune of compilation., Q. 6. The technique of having two (or more} constructors, wn a dase ot known as, (A) Constructor creation, (8) Constructor overtoading, 1C) Constructor overriding, (0) None of the above, Ans, Option (B) is correct, , , , Explanation A dass having more than, one constructor in diferent forms is called, constructor overloading., , Ormnal ICSE MCQS Chapternine Question Sank fr Semestent SOMPUTER APPLICATIONS] Clans — x, , (A) Syntax error, (B) Runtime error, (©) Compiler error or compilation error
Page 2 :
0.0KB/s .ull, , oswal mcq.pdf - Saved, , , , ass, , , , Explanation: A dass having more than, one constructor in different forms i called, constructor overioading, , Q.7. A constructor without any number of agement is, , known as, , (A) parameterized constructor, , {B) constructor overloading, , (CQ) Non-parametenzed constructor, (D) Default constructor, , Ams, Option (A) is correct., , Explanation: «Option = B: constructor, overloading is number of constructors with, the same name as of the class but of different, forms. Hence, wrong., Option C: Non-parsmeterited constructor is &, type of constructor without any argument or, parameter Hence, wrong, Option D: When no constructor is defined in, a program the compiler creates 2 constructor, known as default constructor Hence, wrong, Option A : constructor having parameter(s) is., called parametensed constructor, Hence, right, Q.8. A constructor that creates an object initializing, another object of the same class is called, (A) Prameterined constructor, , Q.9, What is the retum type of the constructor, fA) ine, (B) double, (CQ) void, (D) Doesn't not have return value, Ans, Option (D) is correct,, Explanetion: constructor does not return any, value not ever void, Q.10. Identify the error in the program code given, below, , import java.io";, lass TestConsts3, {, int m_x, m_y;, public TestConstr’Wint x, int y), {, mxzexmy=y, system. owt priewtin(n_x +7 “+ m_yi:, +, public stata void main(String argsi]), {, ‘TestConste3 obj = new TestConstr3 (, int x = & int y = 10;, ,, ,, , Onaaal SE MCQS Chaptermine Quesnon Rank for Semester EEMPUTER APPLICATIONS! Clots — x, , (A) Symtax error, , (8) Runtioe exroe, , (C) Compiler error or compilation error, , (D) No error, , Ans. Option (C) is correct., Explanation: Since there 1 error in Constructor, invoke. Constructor method defined is &, constructor with two arguments, , ‘but when this constrector is invoked no, values passed, Here, compiler will give error, message actual and formal list differ Hence, error is compiler exroc., , Q. 11 Name the type of the conseructor whach cannot be, owerloaded, , (A) Copy constructor, (B) Parameterised constructor, (CQ) Detsult constructor, (D) Now-parameterised constructor, Ans. Option (C) is correct., | ocepseatvru ards ennec, is the characteristic of the default constnectoe, , Q. 12 The statement to invoke the defeult constructor of, , a class “State” is:, , (A) State obj= new state ;, (B) Stave obj ~ State();, (C) State obj= new Seater);, (D) State obj= new State(), , Ans. Option (C) is correct., Explanation: Option A : beaces () to represent, fanetion 36 mating, Option 8: Keyword mew is minting,, Option C : correct, Option D : semicolon () to show end of, statement is missing, , Q. 13. Constroctor that creates objects by passing value is, , called, , (A) Default constructor, , (B) Paraeneterined constructor, , (©) Copy constructor, , (D) Now -parameterized constructor, Ans. Option (8) is correct., , | Explanation: By definition option Bis right — |, Q.34. The argument of a copy constructor is always, , passed by, , (A) Reference {(B) Value, , (©) ByAand Both — (D) None of the abowe, Ans. Option (A) is correct., , Sees ers |, constructor, , Q. 15. The keyword which Refers to the current object is, (A) new (B) private, (©) void (D) this, , Ana. Option (D) is correct., , eae |, , 74 of 80
Page 3 :
CO D490 | cc TL, , oswal mcq.pdf - Saved, , , , ass, , , , USER-DEFINED METHOO:, , 33, , 08) ET, , Osztano ALONE MCQs, , , , Q. 1 In java method signature is the combination of, (A) Method Name (B) ascvess specifier, (©) Return type (D) All the above, Ans. Option (D) is correct., ‘Explanation: Java method definition must have, Access specifier (public,private protected),, return type ( depends upon data type of, return value) and function name followed by, list of argument along with respective type., Q.2 Which of the following return statement is wrong, (A) return 0; (B) return (sk, (C) return(s,p); (D) return (4);, Ans. Option (C) is correct., , Explanation: Punction can return only one, value can not return more than one value, , hence, return(s,p) is wrong as it returns two, value., , Q. 3. A function is invoked through:, , (A) Obdject of the class (B) Return type, , (C) Parameter (D) None of the above, Ans. Option (A) is correct., , Explanation: functions(non-static) are the, members of the class, they belong to the object, of the class . Hence , can be accessed through:, the object of the class, Q. 4 Which of the following is used for a non returnable, function?, (A) int, (©) void, Ans. Option (C) is correct., Q. 5. Which of the following modifier can be used with, function name?, (A) float, (C) parameter, Ans. Option (B) is correct., , Explanation: Functions are of two types static, and non-static does not have any key word, Before the name. Only static method, keyword “static” before the name of the of the, method. In the questions other options are not, associated with the type., Hence , answer is static (option D) Q. 6. The function which change or modify the state of, the argument(s) that are received when invoked is, called, , (B) Goat, (D) double, , (B) static, (D) double, , (A) new function, (©) pure function, Ans. Option (D) is correct., , Explanation:, , Option A — there is no function such as new, , function Hence, wrong, , Option B — static function related to access, , the member of the class., , Option C — pure function does not change, , the state of the argument Hence, wrong, , Option D — impure function change the state, , of the argument it receives. Hence, correct, Q.7. What type of data is passed in function call by, , value =, , (A) Object of a class, , (B) Array, , (C) Reference data type, , (D) Primitive data type, , Ans, Option (D) is correct., , Explanation: Option A — is wrong as it is not, associated with data type, Option B — An array is a collection similar, type variables referenced by using single name, Which cannot be passed by value. Hence,, , wrong., Option C — Reference data types are passed, by reference . Hence, wrong, Option D — Primitive data types are stored in, separate memory locations hence are passed, by values, Q. 8. What type of data is passed in function call by, reference, (A) Object of a class = (B) Array, (C) Reference data type (D) All of the above, Ans. Option (D) is correct., Explanation: Option A — is wrong as it is not, associated with data type, Option B — An array is a collection similar, type variables referenced by using single, mame which cannot be passed by value., ‘Hence, wrongdata ., Option D — Primitive data types are stored in_
Page 4 :
COR) | cc TL, , oswal mcq.pdf - Saved, , , , ass, , , , Explanation:, , ‘Option A —No such term, , Option B — polymorphiem & 2 property of, OOP programming in which a function can, take different forms. In fenction overloading, the function takes various form. Hence, (B) is, the correct option, , Option C — Function signature related to, function declaration, , Option D — It is related to name of the, function, , Q. 10. a prograsn has 4 return statements, how many, return statenvent will be executed,, , fA) nome (B) Tro, (Q) one (D) all four, Ans. Option (C) is correct., , Explanation: A program can have many retum, satements but it can return only one value., Hence, option C is correct, , Q. 11 What makes the two or more functions having the, , same nane difserent?, (A) Nusiber af arguements, (8) Type of arguments, , {C) Return type, (0) A and B both, Ans. Option (DD) is comect., , Explanation: Above is the process of function’, method (Compiler can identity, the methods ( same name) only either number, of arguments are different on the type., Hence, methods can be different by both, yn, , Q. 12 Which of the following is a correct prototype of a, function check which receives a chasacter ch and, , integer 9 and returns troe or false, , (A) pubic int check( char ch,int n);, , {B) pudlic booiean chk(ehar ch, int);, , {C) pubic boolean check{char ch, integer si);, , {D) pudlic boolean check{ char ch, int 9);, Ans, Option (D) is correct., , @case-saseo MCQs, , 1. Read the paragraph given below and answer the, questions given below:, A functon is called pure function if it always returns, the sume result for same argument values and it, has no side effects like modifying an argument (or, global vanable) or outputting something. The only, result of calling a pure function Is the return value, Examples of pure functions are sirlen(), pow),, sqrt() ete, , Impure functions, also called modifier functions,, , are those that can caste a change of state in the, , object That means, values of the object's instance, , , , , , , Cumaal ICSE MCQS Chapter-mise Question Sank for Semester, GOMPUTER APPLICATIONS] Class - x, , Option C — data type of second argument is, wrong it should be int (primutive type), Option D— all are correct,, Q. 13. Can main method be overloaded ?, (A) No, (8) Yes, (C) Yes, any number of times, (D) Only Once, Ans. Option (C) is correct., Q. 14. void mathéint i, int j), Type of argument passing im the above function, defirenon, , (A) Passing argument by integer, (8) passing argument by reference, (©) passing argument by interchange, (D) none of the above, , Ans. Option (D) is correct., , Q. 15. The retum eype of the main{ ) methad ise, (A) vod {B) float, (C) string {(D) vod, Ans. Option (D) is correct., , variables get modified or, , on the current state of the abject on which the, , function operates., , Example of impure fusctions:, , * Incrase the value of its argument by 1, each, time the function ts called., , * Modify the length of a ribbon by taking the, length and the amount of change, , Mechanisms for Side Effects, , A side elfect method i a method which modilies, , some cate variable valuefarguments passed havieyg, , geequence beyond its scope, that is to say it, , 66 of 80
Page 5 :
COR) | cc TL, , oswal mcq.pdf - Saved, , , , KNOW THE TERMS, , ass, , % Class: A class is a blueprint that represents a set of similar objects having a common structure and behaviour, > Object: It is an identsfiabie identity with some characteristics or sate and behaviour, , GLOSSARY, > Byte Code: Java portable code, + Applet: Small Java Program, > Bean : fava Software, > Void: Null Value, > ‘Template : Generic Class, , 8), , Ostano ALONE MCQs, , Q. 1. Whach of the following term means a combination, of data and logic that represencs some seal world, entity?, , (A) Object, (C) Method, , Ans. Option (A) is correct., , Explanation: To know about object, consider an, , example of 2 Maruti automobile. The Maruti, , cam be in @ computer programs as, an object. The “data” part of this object would, be the car's name, colour, number of doors,, price, and so forth The “logic” part of the, object could be a collection of prograens., , Q.2. In which system, everything is an object?, , (A) Procedural (B) Object-oriented, , (C) Serial (D) None of these, , Ans, Option (B) Is correct., , A spreadshert, 8 cell ino, spreadsheet, a bar chart, a tithe in a bar chart, a, report, 2 number or telephone number, 2 file,, a folder, a printer, a word or sentence, even a, single character all are exanyples of an object., Each of us deals with objects daily. Some, ebjects, such as a telephone, are #0 common, , (B) Chass, (D) None of these, , in a certain place., Q.3. An object is an instance of 2, (A) Class (8) Method, {C) Java (D) Library function, , Ans, Option (A) is correct., , , , , , Q.4 Which of the following is used to distinguish one, type of object from another?, (A) Classes, (C) Encapsulation, Ans. Option (A) is cornect., , Frpfunation: In the contest of object-oriented:, Systems, 2 class is a set of objects that share a, common structure and a common behaviour,, a single object is simply an instance of a, lass, A clase is a specification of strocture, (retance variables), behaviour (methods),, and inheritance for objects.) Classes are an, important mechanism for classtying objects., Q.5. Which of the following a class defines that, implement the data structure and operations of, the date respectively?, (A) Attributes, Objects (B) Objects, Attributes, (C) Altributes, Methods (D) None of these, Ans. Option (C) is correct., , Explanation; Class ts nothang but a template:, for object you are going to create or i's a, Dlue print by using this we create an object, In senple word we can say it's a specification, ore which we define and every object, we define will follow that pettern., Q. 6 Which of the following repeesent the state of an, ebject?, (A) Properties, (©) Colour, Ans. Option (A) is correct., , Frplanation: To understand the properties, of an object, let's take an example, like, the, properties of a car, such as colour manufacturer,, and cost, are abstract descriptions., , It ts possible to represent each property in, several ways in a programming language For, colour, we could choose to use a sequence of, characters such as red, or the (stockjnumber, , {B) Methods, {D) Inheritance, , (8) Name, (D) None of these, , , , , , , , , tw-| EOMPUTER APPLICATIONS) Claus — x, , ) is correct,, , The Java compiler needs to, the names of items in the program, , For example, it must recognize the names of, , variables, methods, and component elements, , sil ai Ace I et,