0% found this document useful (0 votes)
21 views

Lab (HTML) REPORT

This lab report contains multiple choice questions (MCQ) from chapters 3 to 11 of a textbook. There are 11 sections with 10 questions each, covering topics like data types, variables, operators, classes, objects, inheritance, polymorphism, exceptions, arrays, and collections in Java. The questions test fundamental concepts and each answer is provided in 1-2 words or a short phrase.

Uploaded by

Swet Sheersh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Lab (HTML) REPORT

This lab report contains multiple choice questions (MCQ) from chapters 3 to 11 of a textbook. There are 11 sections with 10 questions each, covering topics like data types, variables, operators, classes, objects, inheritance, polymorphism, exceptions, arrays, and collections in Java. The questions test fundamental concepts and each answer is provided in 1-2 words or a short phrase.

Uploaded by

Swet Sheersh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

CGI

LAB REPORT

MCQ

SWET SHEERSH
7/22/2023

This report contains questions and their answer from chap. 3 to 11


1|Page

L3
1 How many Data types in java? 2 (primitive & Non-primitive)
3(instance var.,local var.,static
2 how many types of variable?? var)
3 "native" is keywowd, is it true?? Yes True
4 keywords are?? Reserved identifiers
5 what is the size of float?? 32 bit
6 which data type having size 1 bit?? boolean
7 Logical NOT (!) is a type of ?? unary operator
8 "++" operator is used for?? Increment
9 " !=" is which type of operator? Relational Operator
10 In Java, string is an object that represents ?? sequence of char values

L4
1 object is an?? Instance of class
2 class is blue print of?? object
3 packages are used to reduce?? Naming conflict
4 private keyword is?? Access Modifiers
5 static import is used for importing static members
6 which pakage contains sqrt method?? java.lang.Math
7 static methods of class can be called without creating instance
8 private variable cannot be accessed outside the class
9 private variable with getter and setter is used for Encapsulation

10 Constructor name strictly should be same as class

L5
1 which keyword is used for creating an object? New
2 object is parent class for every java class implicitily TRUE

3 toString() method is used ?? describe object in string


4 wrapper class for int is?? Integer
5 Integer.parseInt("123") is used to convert string to int
6 how many type of type casting 2
7 int c=(int)(5.7/2) is it works?? yes, downcasting
8 float c=5 which type of type casting? widening
9 child class can be cast into? parent class
10 stringBuilder is used for?? Modify a string

L6
characteristics and property from
1 inheritance is the mechanism of inheratating parent class
2 inheritance is used for enhancement and alteration
2|Page

3 Java supports only which types of inheritance Single, Multilevel, and Hierarchical
4 which keyword is used for inheritance? extend
5 Any class preceding a specific class in the hierarchy is said to be super class
6 super keyword is used to refer?? instance of parent class
7 instanceof keyword is ued for check whether object is instance of class
8 ways in which polymorphism is implemented 2
9 Method Overloading is compile time polymorphism TRUE
10 Method overriding is run time polymorphism TRUE

L7
1 Abstruct class can only have abstruct methods FALSE
2 we can't create an instance of abstruct and interface
3 Abstruct class can only be implemented by using extends keyword
4 Interface can be implemented by using implements keyword
5 Abstruct method can have implemented method Yes
6 Interface methods can only be implemented if it is static or default
7 default method is used in interface (after java 8)
8 can default method be overriden?? yes
9 static method is accessed without creating an object
10 static method can be overriden FALSE

L8
1 What does the "^" represent in a regex? start
2 method in Java is used to find the first occurrence find
3 "\d" is used to match what type of character? digit
4 "[A-Za-z]" is used to match ? Letters
5 what does the metacharacter "." represent? Any Character
6 "\b" is used to match word boundary

7 method used to replace a regex match with a new replate


to match starting from a and ends
8 "a*b" regex exp. is used with b
9 what does '$' represent in regex? end
10 regex is imported from?? util.rejex

L9
1 What is an exception in Java? Error
2 keyword is used to handle exceptions in Java? try
3 Which block is used to handle the exception? catch
4 which block executes regardless of any exception? finally
What is the process of creating your own exception class in
5 Java? Customization
6 What is the root class of all Java exceptions? Throwable
3|Page

What type of exception occurs when an inappropriate


7 argument? IllegalArgumentException
What type of exception occurs when an array index is out of
8 bounds? IndexOutOfBoundsException
9 What type of exception occurs when a file is not found? FileNotFoundException
What type of exception occurs when an arithmetic operation
10 produces an undefined result? ArithmeticException

L1
0
1. What is a fixed-size data structure that stores elements of
the same type in contiguous memory locations in Java?
Answer: Array

2. In Java, the index of the first element in an array is always:


Answer: 0

3. Which keyword is used to declare an array in Java?


Answer: new

4. :What is the maximum number of dimensions an array can


have in Java?
Answer: 3

5. The length of an array in Java can be obtained using which


method?
Answer: length()

6. In Java, arrays are of which data type?


Answer: Object

7. Which of the following is the correct way to access an


element in a one-dimensional array with the index 'i'?
Answer: array[i]

8. What happens if you try to access an index that is out of


the bounds of an array in Java?
Answer: It throws an ArrayIndexOutOfBoundsException

9. To sort an array in ascending order, you can use which


method from the Arrays class in Java?
Answer: sort()

10. Which method is used to copy elements from one array to


another in Java?
Answer: System.arraycopy()

L1
1
1. What is a "Collection" in Java?
Answer: Group

2. Does "List" allow duplicates?


Answer: Yes
4|Page

3. Is "Set" an ordered collection?


Answer: No

4. Which interface stores key-value pairs?


Answer: Map

5. Does "HashSet" allow duplicate elements?


Answer: No

6. Is "LinkedList" a dynamic data structure?


Answer: Yes

7. Does "TreeMap" maintain a sorted order?


Answer: Yes

8. Does "ArrayList" use an array to store elements?


Answer: Yes

9. Is "Iterator" used for sequential access?


Answer: Yes

10. Is "HashMap" synchronized?


Answer: No

You might also like