Loading
- DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE-45www.dacc.edu.inPROF . SUPRIYA MANESUBJECT CODE: 501 SUBJECT: JAVA PROGAMMINGUnit 1 : Introduction to JAVA1.Which component is used to compile, debug and execute java program?a) JVMb) JDKc) JITd) JREAnswer: bExplanation: JDK is a core component of Java Environment and provides all the tools,executables and binaries required to compile, debug and execute a Java Program.2. Which component is responsible for converting bytecode into machine specific code?a) JVMb) JDKc) JITd) JREAnswer: aExplanation: JVM is responsible to converting bytecode to the machine specific code. JVM isalso platform dependent and provides core java functions like garbage collection, memorymanagement, security etc.3. Which component is responsible to run java program?a) JVMb) JDKc) JITd) JREAnswer: dExplanation: JRE is the implementation of JVM, it provides platform to execute java programs.
Page 1
- DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE-45www.dacc.edu.inPROF . SUPRIYA MANE4. Which component is responsible to optimize bytecode to machine code?a) JVMb) JDKc) JITd) JREAnswer: cExplanation: JIT optimizes bytecode to machine specific language code by compiling similarbytecodes at the same time. This reduces overall time taken for compilation of bytecode tomachine specific language.5. Which statement is true about java?a) Platform independent programming languageb) Platform dependent programming languagec) Code dependent programming languaged) Sequence dependent programming languageAnswer: aExplanation: Java is called ‘Platform Independent Language’ as it primarily works on theprinciple of ‘compile once, run everywhere’.6. Which of the below is invalid identifier with the main method?a) publicb) staticc) privated) finalAnswer: cExplanation: main method cannot be private as it is invoked by external method. Other identifierare valid with main method.7. What is the extension of java code files?a) .classb) .java
Page 2
- DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE-45www.dacc.edu.inPROF . SUPRIYA MANEc) .txtd) .jsAnswer: bExplanation: Java files have .java extension.8. What is the extension of compiled java classes?a) .classb) .javac) .txtd) .jsAnswer: aExplanation: The compiled java files have .class extension.9. How can we identify whether a compilation unit is class or interface from a .class file?a) Java source file headerb) Extension of compilation unitc) We cannot differentiate between class and interfaced) The class or interface name should be postfixed with unit typeAnswer: aExplanation: The Java source file contains a header that declares the type of class or interface,its visibility with respect to other classes, its name and any superclass it may extend, orinterface it implements.10. What is use of interpreter?a) They convert bytecode to machine language codeb) They read high level code and execute themc) They are intermediated between JIT and JVMd) It is a synonym for JITAnswer: bExplanation: Interpreters read high level language (interprets it) and execute the program.Interpreters are normally not passing through byte-code and jit compilation.
Page 3
- DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE-45www.dacc.edu.inPROF . SUPRIYA MANE11. Which of the following is not OOPS concept in Java?a) Inheritanceb) Encapsulationc) Polymorphismd) CompilationAnswer: dExplanation: There are 4 OOPS concepts in Java. Inheritance, Encapsulation, Polymorphismand Abstraction.12. Which of the following is a type of polymorphism in Java?a) Compile time polymorphismb) Execution time polymorphismc) Multiple polymorphismd) Multilevel polymorphismAnswer: aExplanation: There are two types of polymorphism in Java. Compile time polymorphism(overloading) and runtime polymorphism (overriding).13. When does method overloading is determined?a) At run timeb) At compile timec) At coding timed) At execution timeAnswer: bExplanation: Overloading is determined at compile time. Hence, it is also known as compile timepolymorphism.14. When Overloading does not occur?a) More than one method with same name but different method signature and different numberor type of parametersb) More than one method with same name, same signature but different number of signaturec) More than one method with same name, same signature, same number of parameters but
Page 4
- DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE-45www.dacc.edu.inPROF . SUPRIYA MANEdifferent typed) More than one method with same name, same number of parameters and type but differentsignatureAnswer: dExplanation: Overloading occurs when more than one method with same name but differentconstructor and also when same signature but different number of parameters and/or parametertype.15. Which concept of Java is a way of converting real world objects in terms of class?a) Polymorphismb) Encapsulationc) Abstractiond) InheritanceAnswer: cExplanation: Abstraction is the concept of defining real world objects in terms of classes orinterfaces.16. Which concept of Java is achieved by combining methods and attribute into a class?a) Encapsulationb) Inheritancec) Polymorphismd) AbstractionAnswer: aExplanation: Encapsulation is implemented by combining methods and attribute into a class.The class acts like a container of encapsulating properties.17. What is it called if an object has its own lifecycle and there is no owner?a) Aggregationb) Compositionc) Encapsulationd) AssociationAnswer: d
Page 5
- DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE-45www.dacc.edu.inPROF . SUPRIYA MANEExplanation: It is a relationship where all objects have their own lifecycle and there is no owner.This occurs where many to many relationships are available, instead of one to one or one tomany.18. What is it called where child object gets killed if parent object is killed?a) Aggregationb) Compositionc) Encapsulationd) AssociationAnswer: bExplanation: Composition occurs when child object gets killed if parent object gets killed.Aggregation is also known as strong Aggregation.19. What is it called where object has its own lifecycle and child object cannot belong to anotherparent object?a) Aggregationb) Compositionc) Encapsulationd) AssociationAnswer: aExplanation: Aggregation occurs when objects have their own life cycle and child object canassociate with only one parent object.20. Method overriding is combination of inheritance and polymorphism?a) Trueb) falseAnswer: aExplanation: In order for method overriding, method with same signature in both superclass andsubclass is required with same signature. That satisfies both concepts inheritance andpolymorphism.
Page 6
- DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE-45www.dacc.edu.inPROF . SUPRIYA MANE21. Which of these operators is used to allocate memory to array variable in Java?a) mallocb) allocc) newd) new mallocAnswer: cExplanation: Operator new allocates a block of memory specified by the size of an array, andgives the reference of memory allocated to the array variable.22. Which of these is an incorrect array declaration?a) int arr[] = new int[5]b) int [] arr = new int[5]c) int arr[] = new int[5]d) int arr[] = int [5] newAnswer: dExplanation: Operator new must be succeeded by array type and array size.23. What will be the output of the following Java code?int arr[] = new int [5];System.out.print(arr);a) 0b) value stored in arr[0]c) 00000d) Class name@ hashcode in hexadecimal formAnswer: dExplanation: If we trying to print any reference variable internally, toString() will be called whichis implemented to return the String in following form:classname@hashcode in hexadecimal form
Page 7
- DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE-45www.dacc.edu.inPROF . SUPRIYA MANE24. Which of these is an incorrect Statement?a) It is necessary to use new operator to initialize an arrayb) Array can be initialized using comma separated expressions surrounded by curly bracesc) Array can be initialized when they are declaredd) None of the mentionedAnswer: aExplanation: Array can be initialized using both new and comma separated expressionssurrounded by curly braces example : int arr[5] = new int[5]; and int arr[] = { 0, 1, 2, 3, 4};25. Which of these is necessary to specify at time of array initialization?a) Rowb) Columnc) Both Row and Columnd) None of the mentionedAnswer: aExplanation: None.26. What will be the output of the following Java code?1.classarray_output2.{3.publicstaticvoidmain(String args[])4.{5.intarray_variable [] =newint[10];6.for(inti = 0; i < 10; ++i)7.{8.array_variable[i] = i;9.System.out.print(array_variable[i] + " ");10.i++;11.}12.}13.}
Page 8
- DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE-45www.dacc.edu.inPROF . SUPRIYA MANEa) 0 2 4 6 8b) 1 3 5 7 9c) 0 1 2 3 4 5 6 7 8 9d) 1 2 3 4 5 6 7 8 9 10Answer: aExplanation: When an array is declared using new operator then all of its elements are initializedto 0 automatically. for loop body is executed 5 times as whenever controls comes in the loop ivalue is incremented twice, first by i++ in body of loop then by ++i in increment condition of forloop.output:$ javac array_output.java$ java array_output0 2 4 6 827. What will be the output of the following Java code?1.classmultidimention_array2.{3.publicstaticvoidmain(String args[])4.{5.intarr[][] =newint[3][];6.arr[0] =newint[1];7.arr[1] =newint[2];8.arr[2] =newint[3];9.intsum = 0;10.for(inti = 0; i < 3; ++i)11.for(intj = 0; j < i + 1; ++j)12.arr[i][j] = j + 1;13.for(inti = 0; i < 3; ++i)14.for(intj = 0; j < i + 1; ++j)15.sum + = arr[i][j];16.System.out.print(sum);17.}
Page 9
- DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE-45www.dacc.edu.inPROF . SUPRIYA MANE18.}a) 11b) 10c) 13d) 14Answer: bExplanation: arr[][] is a 2D array, array has been allotted memory in parts. 1st row contains 1element, 2nd row contains 2 elements and 3rd row contains 3 elements. each element of arrayis given i + j value in loop. sum contains addition of all the elements of the array.output:$ javac multidimention_array.java$ java multidimention_array1028. What will be the output of the following Java code?1.classevaluate2.{3.publicstaticvoidmain(String args[])4.{5.intarr[] =newint[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};6.intn = 6;7.n = arr[arr[n] / 2];8.System.out.println(arr[n] / 2);9.}10.}a) 3b) 0c) 6d) 1
Page 10
Download this file to view remaining 84 pages
Related documents:
- Root of equation & Error approximation - Assertion and Reasoning
- PRINCIPLES OF BANK LENDING - Banking regulation and operations (BRO) - Notes
- LABOUR COST CONTROL - Cost Acounting - Notes
- Element of Company Law - MCQ
- Modern India –II Unit 3 Questions with answers - Question Bank
- Sanskrit - Prose,Vrutha,Alankara,Theories of Poetics & Grammar MCQs - MCQ
- C programming paper - Question Paper
- Differential Equation (Solved MCQs and Notes) - Notes
- Chemical Engineering Paper I QP - Question Paper
- History of the USA 1776-1945 Question Bank (Fill in the Blanks) - Question Bank
- Political Science and International Relations (Paper II) 2015 Question Paper - Question Paper
- QP IFSM-23 GENERAL ENGLISH - Question Paper
- Rotationl Motion Notes and MCQs - Notes
- Retail Management MCQs with Answers - MCQ
- ADE (UNIT-III) MCQs - MCQ
- FINANCIAL STATEMENT ANALYSIS - Assignment
- High Performance Computing - MCQ
- CONCEPT RECAPITULATION TEST - II [CONCEPT RECAPITULATION TEST - II]
- Recent Trends in IT Solved MCQs - MCQ
- Engineering Graphics Jan 2018 Question Paper - Question Paper