Download object oriented programming quiz 1 and more Exercises Object Oriented Programming in PDF only on Docsity! Name: ____________________________________Roll#.________________________________ 1. Identify the errors in section of code shown below [2 Marks] public class Test { public static void main(String[] args) { int a = 3; int b = 4; int c = 20; average = (a + b + c)/5.0; System.out.println(average);}} ___________________________________________________________________________ 2. Decide whether each statement below is TRUE or false. [1 Marks] a. Java case-sensitive. b. The purpose of substring is to search for whether a word is found in a sentence. 3. Take 10 elements of integer type in one dimensional array and find out their sum [2 Marks] __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY BIOINFORMATICS DEPARTMENT FALL 2019 OBJECT OORIENTED PROGRAMMING (CS-224) Quiz 1(A) Semester: IV Batch: 2018 Max Time: 15 mins Max Marks: 05 Instructions: Attempt all questions Name: ____________________________________Roll#.________________________________ 1. What is the difference between print and println? [2Marks] ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ 2. Identify the errors in section of code shown below [1 Mark] public class Test { public static void main(String[] args) { Scanner console = new Scanner(System.in); int n = console.nextInt(); } } _________________________________________________________________________ 3. Take 10 elements of integer type in one dimensional array and find out their average.[2 Mark] __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY BIOINFORMATICS DEPARTMENT FALL 2019 OBJECT OORIENTED PROGRAMMING (CS-224) Quiz 1(B) Semester: IV Batch: 2018 Max Time: 15 mins Max Marks: 05 Instructions: Attempt all questions Name: ____________________________________Enrolment#.________________________________ 1. How a constant is defined in java? [2 Marks] ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ 2. If you run the code below, what gets printed out? [1 Marks] String s=new String("Bicycle"); int iBegin=1; int iEnd=3; System.out.println(s.substring(iBegin,iEnd)); ____________________________________________________________ 3. Write a Java program to test the equality of two arrays. [1 Marks] __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY BIOINFORMATICS DEPARTMENT FALL 2019 OBJECT OORIENTED PROGRAMMING (CS-224) Quiz 1(E) Semester: IV Batch: 2018 Max Time: 15 mins Max Marks: 05 Instructions: Attempt all questions __________________________________________________________________ ________________________________________________________ Name: ____________________________________Roll#.________________________________ 1. What is the argument type of program’s main( ) method? [2 Mark] ______________________________________________________________________ 2. Which type cast must be used to convert a larger value into a smaller one?(Implicit/Explicit) [1 Mark] ___________________________________________________________________________ 3. Add code to the program so that it reads the user's first and last name (read an entire line as a single string), then prints the last name followed by a comma and the first initial. (Assume that the user types a valid name.) [2 Mark] Example: Type your name: Jessica Miller Your name is: Miller, J. __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY BIOINFORMATICS DEPARTMENT FALL 2019 OBJECT OORIENTED PROGRAMMING (CS-224) Quiz 1(F) Semester: IV Batch: 2018 Max Time: 15 mins Max Marks: 05 Instructions: Attempt all questions