0% found this document useful (0 votes)
17 views7 pages

15 46 10 12 03 2024 MCQS

The document contains a series of multiple-choice questions related to programming concepts, particularly in Java. Topics covered include data types, control structures, object-oriented programming principles, and methods. Each question provides four answer options, testing knowledge on syntax, functionality, and programming practices.

Uploaded by

Anika Amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views7 pages

15 46 10 12 03 2024 MCQS

The document contains a series of multiple-choice questions related to programming concepts, particularly in Java. Topics covered include data types, control structures, object-oriented programming principles, and methods. Each question provides four answer options, testing knowledge on syntax, functionality, and programming practices.

Uploaded by

Anika Amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1) The process of restricting the free flow of data from the outside world is known as:

(a) encapsulation (b)inheritance (c) function (d) class


2) Which type of data is not accessed in a derived class?
a) Public b) Private c) Protected d) None
3) Which of the following is a non-primitive data type?

a) Int (b) double (c) char (d) String


4) Given: String st = (a>= 90)? "Excellent": "Best"; Predict the output, when a = 90.
(a) Best (b) Excellent: Best (c) Best: Excellent (d) Excellent
5) Which of the following makes a function non-returnable?
(a) public (b) static (c) void (d) new
6) The while statement repeats the execution of a block only when the given condition is:
a) False (b) True (c) 1 (d) 0
7) If m, n, p are three integers, then which of the following holds true, if (m==n) && (n!=p)?
(a) m, n are equal (b) n, p are equal (c) m, p are equal d) None
8) If a=1, b=2; ouput of System.out.println(--b - ++a + ++b - --a);
(a) 0 (b)3 (c) 5 (d) 7
9) For which purpose a constructor is used?
a) To initialize the instance variables b) To provide the instance variables
c) To organize the instance variables d)To simplify the instance variables.
10)_______ statement will repeat a loop for the next iteration after ignoring some statements
of loop.
(a) Break (b) Continue (c) Labelled break (d) None
11) A method with many definitions is called:
(a) multiple method b) method overloading (c) floating method (d) none
12)Parameters used in method call statement are known as:
(a) defined parameter (b) passed parameter (c) actual parameter (d) formal parameter
13)The method which changes the state of an object is known as:
(a) pure method (b) impure method (c) replace method (d) none of the above
14) Find the odd one out:
(a) Method overloading (b) Polymorphism
(c) Abstraction (d) Multiple forms of same
15) A method is invoked through an:
(a) object (b) system (c) parameter (d) none
16) A package is a_________
(a) Collection of data (b) collection of functions
(c) collection of classes (d) a nested class
17) A constructor is always:
(a) private (b) protected (c) secure (d) public
18) Which of the following is the correct usage?
a) int a[-40] (b) int a[40] (c) float a[0 - 40] (d) None
19) Which of the following function finds the size of array
char m[] = {'I', 'N', 'D', 'I', 'A', 'N' };?
a) m.sizeof (a) (b) m.elementsof (m) (c) m.length (d) None
20) Which of the following functions is used to remove leading and trailing white spaces
from the string?
a) trim( ) (b)trail( ) (c) truncate( ) (d)slice( )
21) The process of restricting the free flow of data from the outside world is known as:
(a) encapsulation (b)inheritance (c) function (d) class
22) Which type of data is not accessed in a derived class?
a) Public b) Private c) Protected d) None
23) Which of the following is a non-primitive data type?

a)Int (b) double (c) char (d) String

24) Given: String st = (a>= 90)? "Excellent": "Best"; Predict the output, when a = 90.

(a) Best (b) Excellent: Best (c) Best: Excellent (d) Excellent
25) Which of the following makes a function non-returnable?
(a) public (b) static (c) void (d) new
26) The while statement repeats the execution of a block only when the given condition is:
a) False (b) True (c) 1 (d) 0
28) If a=1, b=2; System.out.println(--b - ++a + ++b - --a);
(a) 0 (b)3 (c) 5 (d) 7
29) For which purpose a constructor is used?
b) To initialize the instance variables b) To provide the instance variables
c) To organize the instance variables d)To simplify the instance variables.
30)_______ statement will repeat a loop for the next iteration after ignoring some statements
of loop.
(a) Break (b) Continue (c) Labelled break (d) None
31)Parameters used in method call statement are known as:
(a) defined parameter (b) passed parameter (c) actual parameter (d) formal
parameter
32)The method which changes the state of an object is known as:
(a) pure method (b) impure method (c) replace method (d) none of the above
34) Find the odd one out:
(a) Method overloading(b) Polymorphism (c) Abstraction (d) Multiple forms of same
35) A method is invoked through an:
(a) object (b) system (c) parameter (d) none
36) A package is a_________
(a) Collection of data (b) collection of functions (c) collection of classes
(d) a nested class
38) Which of the following is the correct usage?
b) int a[-40] (b) int a[40] (c) float a[0 - 40] (d) None
39) Which of the following function finds the size of array
char m[] = {'I', 'N', 'D', 'I', 'A', 'N' };?
b) m.sizeof (a) (b) m.elementsof (m) (c) m.length (d) None
40) Which of the following functions is used to remove leading and trailing white spaces
from the string?
b) trim( ) (b)trail( ) (c) truncate( ) (d)slice( )
41) A method with the same name as of the class and with arguments and no return data
type is termed as
(a)parameterized constructor (b)Default constructor
(c )non-parameterized constructor (d) wrapper class method
(42)the method to check if a character is an alphabet or not is:
(a) isLetter(char) ( b)isAlpha(char)
(c) is Uppercase(char) (d)is Lowercase(char)
(43)The scanner class is a _____________class
(a) primitive (b) Derived (c) Wrapper (d) superclass
(44)The output of Double.parseDouble(“71.25”) + 0.75 is :
(a) 72.0 (b) 72 (c) 71.0 (d) 71.75
(45)The output of the method “MATHEMATICS”.substring(5,9) is___
(a) EMATI (b) MATIC (c) MATI (d) EMATIC
(46)When a primitive data type is converted to the corresponding Object of its class, it is
termed as______
(a) Boxing (b) Explicit type conversion
(c) UnBoxing (d) Implicit type conversion
47)The return type of the library function CompareTo( ) is __________
(a) boolean (b) int (c) char (d) string
(48)Data members declared as __________are accessible within the same package (or)
subclasses in different packages.
(a) public (b) private (c) protected (d) default
(49)If a = 22 result of a/ = (a++) ─ (++a) + a;
(a) 2 (b) 0 (c) 1 (d) 11
(50) pick the odd one out
(a) Inheritance (b)Polymorphism
(c)Overloading (d)Overriding
(51)A variable that is bounded to the object itself is called
(a)Instance Variable (b)Class Variable
(c) Local Variable (d) Argument Variable
(52) The value of a[3] ─ 1 of the array elements {2,4, 5, 6,7,8};
(a) 2 (b) 3 (c) 5 (d) 6
(53) Java Programming language is __________
(a) Robust and easy to learn (b) simple and secure
(c) Object Oriented (d) All of the above
(54) The output of Math.sqrt (Math.min (64,42.25)) is_________
(a) 8.0 (b) 6.25 (c) 6.5 (d) 6.05
(55) A class is ____________
(a) Not a primitive data type (b) A specification for objects
(c)A blue print to create objects(object factory) (d) All of these
(56)valueOf( ) function converts
(a) Primitive type to String (b) String to primitive type
(c) character to String (d) None
(57)_______ statement will repeat a loop for the next iteration after ignoring some statements
of loop.
(a) Break (b) Continue (c) Labelled break (d) None
58) A method with many definitions is called:
(a) multiple method ( b) method overloading
(c) floating method (d) none of these
59)Parameters used in method call statement are known as:
(a) defined parameter (b) passed parameter
(c) actual parameter (d) formal parameter
60)The method which changes the state of an object is known as:
(a) pure method (b) impure method
(c) replace method (d) none of these
61)The maximum number of objects of a class can be created as:
a) 1 b) 2
c) On the user's choice d) Number of variables
62)A class contains:
a) Attributes and methods b) A number of object of same types
c) Data and member function d) All of the above
63)___________ members are accessible from anywhere in the program.
a) Public b) Private
c) Protected d) All of the above
64)Which of the following is not a keyword?
(a) void (b) byte (c) object d)public
65)A variable whose value is not associated to an object and its value exists throughout the
life of the program is ____________
(a) local variable (b) static variable
(c) final variable (d) None of these
66)The method which changes the state of an object is known as:
a) pure method b) impure method
c) replace method d)none of the above
67)Parameters used in the method definition are called:
a) forward parameter b) actual parameter
c) formal parameter d) none of the above
68)The process of calling a method in such a way that the change in the formal arguments
reflects on the actual parameter is known as:
a) pass by reference b) pass by value
c) pass by method d) none
70)Which of the following type can be used for a non-returnable method?
a). int b). float c). double d)void
71)A method is invoked through an:
a) object b) system c) parameter d) none
72) A constructor is always:
a) private b) protected c) secure d) public
73) A constructor is used when an _______ is created
a) object b) class c) method d) none
74) For which purpose a constructor is used?
a) To initialize the instance variables b) To provide object
c) To organise the class d)To calculate problem.
75) Given Double a = -8.35; Double p = Math.abs(Math.floor(a));
What will be the final value stored in the variable p?
a) 9.0 b)8.0 c)7.0 d) 8.5
76) Given double b = Math.ceil(3.4) + Math.pow(2,3);
What will be the final value stored in the variable b?
a) 12.0 b)11.0 c)11.4 d)11.5
77) The keyword _________ is used to include a package in a program.
a) Void b) Import c) Public d) new
78) Given: x += x++ + ++x + --x
Find the value, when x=5.
a) 23 b) 21 c) 22 d) 24
79) Assigning a value of 24.3 to a variable that is defined as int type is __________ error.
a) Syntax b) Logical c) Runtime d) Executional
80) Which of the following keywords can be used to terminate a switch case as well as a loop
construct?
a) continue (b) void c) break d) stop
(81) ________________ means that the same function may behave differently on different
classes. (a) Inheritance (b) Encapsulation
(c)Abstraction (d) Polymorphism
(82) The process of wrapping the data and instructions together into a single object is
called_____________(a) Encapsulation (b) Data Abstraction
(c) Polymorphism (d) Inheritance
(83)A package is a collection of ______________________________
(a) Data members (b)Functions (c) Classes (d) Small elements
(84) A function body is enclosed within a pair of ________
(a) [ ] (b) ( ) (c) { } (d) “ “
85)Condition is essentially formed by using _______ operators
(a) Arithmetic (b) Relational (c) Logical (d) All
(86)BlueJ is window-based platform is suitable for________
(a) Experts (b) Professionals (c) Beginners (d) Teachers
(87) __________________are the Java programs that are executed in a web browser or using
internet.
(a) Application (b) Applet (c) Object (d) Webpages
(88) The errors occur due to the grammatical errors in programming language
(a) Logical error (b) Syntax error
(c) Runtime error (d) None
(89) The output of Math.sqrt (Math.max (64,42.25)) is_________
(a) 8.0 (b) 6.25 (c) 6.5 (d) 6.05
(90)__________package includes the “math class” and it is implemented (or) imported by
default by the java compiler
(a) java. lang (b) java.util
(c) java.io (d) java.awt
(91) In a switch case, when the switch value does not respond to any case then the execution
transfers to:
(a)a break statement (b)a default case (c) a loop (d)None

(92) Arrange the operators given below in order of higher to lower precedence_
(a) ++ , % , && , >=
(b) ++ , && , >= , %
(c) ++, % , >=, &&
(d) % , >= , ++ , &&
(93) Which one of the following is not a binary operator?
(a) AND (b) = = (c) % (d) !
(96) What type of value is returned by Math.sqrt( ) ?
(a)Int (b) Short (c) float (d) double
(97)Give the output of the Math.ceil(65.6) ;
(a) 65 (b) 66 (c) 67 (d) 64
(98)Give the output of Math.abs(-4) + Math.max(-77.6, -87.4);
(a) -77.6 (b) -81.6 (c) -73.6 (d) -91.4
(99)The ASCII codes of uppercase alphabets range from
(a) 65 - 90 (b) 60 - 85 (c) 65 - 91 (d) 97 – 122
(100) The following which statement results in False
(a) 3 >1 || 0 < 4 (b) 3 == 4 & & 5==5
(c) ! (6 < 3) (d)5 + 3 > 7 && 7 >= 4+3

SHORT ANSWERS TYPE QUESTIONS

(1) Define source code and object code.


(2) What do you mean by type conversion?
(4) What is meant by a package? Name any two Java API packages?
(5) What is BlueJ ? write the features of BlueJ ?
(6) What is the difference between an object and a class?
(7) Write primitive data types with their sizes and non-primitive datatypes
(9)Write the difference between the scanner class element next() and nextline()?
(10)What do you meant by compound statement?
(11)Differentiate between isUppercase() and toUppercase() with example
(12)Mention five features of JAVA
13) What is a pure and impure method?
14) What is a Ternary operator? Explain with the help of an example
15) What is the difference between base class and derived class?
16) Why class is called an object factory? Explain
17) What is a constructor? When is it invoked?
18) Differentiate between
a) / and % operators b) = and = =
19) Differentiate between call by value (pass by value) and call by reference (pass by
reference).
20) Differentiate between Linear search and Binary search
21)Differentiate between if -else and switch statement.
22) Differentiate between call (pass) by value and call (pass) by reference.
23)If int[ ] = {1,2, 3, 5, 7, 9, 13, 16}, what are the values of X and Y?
X = Math.pow( n[4], n[2]);
Y = Math.sqrt( n[5] + n[7]);
24) Write two advantages of using functions in a program.
25)Differentiate between Single Dimensional And Double Dimensional Array
26) What is a constructor? When is it invoked?
27) Differentiate between
a) / and % operators b) = and = =
28) Differentiate between the Sorting and Searching
29)What are library classes? Give an Example.
30)Explain features of a constructor.
31)difference between actual and formal parameters
32)Discuss about passby value?and call by reference?
33)How does compare To(String s) function work? Explain with an example.
34)Discuss about static and local variables?
35)Difference between entry controlled and exit controlled loops?
36)Discuss about break statement and default case?
37)Discuss about input value using scanner class with syntax?
38)Differentiate between Selection sort and Bubble sort.
39)How does trim () function work? Explain with an example.
40)Differences between String and String Buffer objects.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy