CUET Information practice (IP) Chapter 5 GUI Programming and Access Specifier

  • Board
    CBSE
  • Textbook
    NCERT
  • Class
    Class 12
  • Subject
    Informative Practices (IP)
  • Chapter
    CUET Information practice (IP) Chapter 5 GUI Programming and Access Specifier
  • Chapter Name
    Chapter 5 GUI Programming and Access Specifier
  • Category
    CUET (Common University Entrance Test) UG

Practice MCQ Based questions for CUET Information practice (IP) Chapter 5 GUI Programming and Access Specifier

This page is created by HT experts and consists of MCQ-based questions with detailed explanations for CUET Information practice (IP) Chapter 5 GUI Programming and Access Specifier. All the important concepts of Chapter 5 GUI Programming and Access Specifier for the CUET entrance exam are covered by MCQ questions with detailed explanations. Do solve chapter-wise MCQ questions for CUET Computer Science and CUET IP prepared by experts. 

MCQ Based questions for CUET Information practice (IP) Chapter 5 GUI Programming and Access Specifier Set-A

Informatics Practices - MCQ on JAVA GUI PROGRAMMING REVISION TOUR - III

Class XII

Q.1. An identifiable entity with some characteristics and behaviour is known as

a) class.

b) object.

c) group.

d) module.

Answer:

(b)

Explanation: An object is a real-world entity that has certain attributes and behaviour.

Q.2. The process of creating an object is called

a) object creation.

b) object formation.

c) instantiation.

d) instant object.

Answer:

(c)

Explanation: An object is an instance of a class. It is the root of class hierarchy and the process of creating an object is called instantiation.

Q.3. A class represents a group of

a) similar objects.

b) different types of objects.

c) different entities.

d) same variables and different data types.

Answer:

(a)

Explanation: A class is a way to bind the data describing an entity and its associated functions together.

Q.4. Static data members are declared

a) within the class definition.

b) outside the class definition.

c) outside the main().

d) with virtual keyword always.

Answer:

(a)

Explanation: For making a data member static, the declaration is done within the class definition always.

Q.5. In java the class variables and methods are always declared with the

a. instance keyword.

b. public keyword.

c. volatile keyword.

d. static keyword.

Answer:

(d)

Explanation: The methods and fields of a class declared with static are also known as class fields and class methods. Static members belong to a class as a whole and not to a particular instance (object).

Q.6. Static data members are also called

a) variables.

b) fundamental data types.

c) class variables.

d) abstract data members.

Answer:

(c)

Explanation: Since, static data members are associated with class itself rather than with any class object, they are also known as class variables.

Q.7. A static member function can access

a) static members of the same class only.

b) static members of any class.

c) static and non-static members of the same class.

d) static and non-static members of any class.

Answer:

(a)

Explanation: A member function that accesses only the static members of a class may be declared as static.

Q.8. If we declare the object of a particular class type and the class does not have a constructor, then

a) it would be compiler error.

b) default constructor gets called automatically.

c) default constructor has to be called explicitly.

d) it would give run time error.

Answer:

(b)

Explanation: When no constructor is present in the class, the compiler builds an implicit constructor.

Q.9. Reusability of classes is one of the major characteristics of OOPS. It is implemented through

a) polymorphism.

b) inheritance.

c) data abstraction.

d) encapsulation.

Answer:

(b)

Explanation: Inheritance is the property by which derived class inherits the characteristics and properties of base class.

Q.10. The operator which is used to create a new object is

a) create.

b) create object.

c) new.

d) create obj.

Answer:

(c)

Explanation: New operator creates a new object and allocates space for it.

For example:

XYZ obj = new XYZ();

Here, obj is an object of XYZ class type

Q.11. A method having same name as that of class is called

a) identity.

b) same.

c) class.

d) constructor.

Answer:

(d)

Explanation: A constructor is used to initialize an object as soon as it is created and has the same name as that of the class.

Q.12. The operator used to refer to members of a class with object reference is

a) dot (.) operator.

b) reference operator.

c) relational operator.

d) this operator.

Answer:

(a)

Explanation: The operator that we use to refer to the members of a class with object reference is dot(.) operator.

Dot(.) operator is used in the following format:

objectreference.membername.

Q.13. The difference between static variable and a static function is that a

a) static variable has a function scope but the static function has a program scope.

b) static variable has a file scope but the static function has a program scope.

c) static variable has a function scope but the static function has a file scope.

d) static variable has a file scope but the static function has a function scope.

Answer:

(c)

Explanation: A static function is a function whose scope is limited to the current source file. A static function has a file scope instead of program scope.

Q.14. The benefit of using functions is

a. reduced program size.

b. non-readable to user.

c. increased ambiguity.

d. complex program handling.

Answer:

(a)

Explanation: Use of function avoids ambiguity. It reduces the program size; thus, makes the program more readable and understandable to the programmer.

Q.15. The values passed to a calling function are known as

a) parameters.

b) arguments.

c) formal parameters.

d) function call.

Answer:

(b)

Explanation: When you invoke the method, the values you pass are called the arguments. Arguments refer to the values passed by the caller.

For Example:

Calcsum(2,5;

// Calcsum() is the invoked method

// 2 and 5 are arguments

Q.16. The variables that receive the incoming values in a function, are known as

a) Actual parameters.

b) Formal parameters.

c) Functional parameters.

d) Global parameters

Answer:

(b)

Explanation: Formal parameters are the variables declared in the parameter list of a subprogram (such as a procedure or a function) specification.

Q.17. The non-parameterized constructor is called

a) explicitly.

b) automatically.

c) forcefully.

d) locally.

Answer:

(b)

Explanation: The default or (non – parameterized) constructor is called automatically. It is not necessary to implement non-parameterized constructor into the program.

Q.18. The number of constructors a class can have is

a) only one.

b) two.

c) three.

d) many.

Answer:

(d)

Explanation: A class can have a multiple number of constructors. There are three types of constructor available in java, i.e., default constructor, parameterized constructor and copy constructor.

Q.19. The difference between constructors and the other member function is that the

a) constructors cannot be overloaded.

b) constructors have a return type.

c) constructors do not return any value.

d) constructors are called explicitly.

Answer:

(c)

Explanation: Constructors are special member functions that have the same name as the class name. It can be overloaded. The only difference is that the constructors do not return any value.

Q.20. The new operator requires a call to a/an

a) object.

b) constructor.

c) destructor.

d) pointer.

Answer:

(b)

Explanation: The new operator instantiates a class by allocating memory for a new object.

The syntax of using new operator for creating object is as follows:

XYZ obj = new XYZ();

Here, obj is an object of XYZ class.

Q.21. A user-defined data type

a) contain main method.

b) do not contain main method.

c) is same as primitive data type.

d) is same as fundamental data type.

Answer:

(b)

Explanation: A user-defined composite data type is different from an application, in the context that it does not contain main method. In java, class is considered as user-defined data type because it gets created by user.

Q.22. An application has a class

a) containing main method.

b) that does not contain main method.

c) containing secondary method.

d) that contains instance method.

Answer:

(a)

Explanation: In java an application always contain a main( ) method. The prototype of main() method is:

public static void main(String args[]).

Q.23. A blue-print defining the characteristics (data items) and behaviour(methods) of a set of similar objects is called

a) object.

b) class.

c) instance.

d) data type.

Answer:

(b)

Explanation: Class is a programming language construct that describes the state and behaviour of all the objects created.

Q.24. A method that calls another method is called

a) called method.

b) declared method.

c) calling method.

d) defined method.

Answer:

(c)

Explanation: A calling method is the method that calls another method.

For example

void method-name(int x, int y)

{

int a = sum();

}

Here, sum( ) method is called by method-name. So method-name is the calling method.

Q.25. An instance of a class is referred to as

a) method.

b) data.

c) function.

d) object.

Answer:

(d)

Explanation: An object represents an entity with specific characteristics and behaviour. It is an instance of a class type.

CUET Information practice (IP) Chapter 5 GUI Programming and Access Specifier Set-B

Q.26. If I create an object obj of car type, then drive, move, applying brake are its

a) Classes.

b) Data.

c) Functions.

d) Attributes.

Answer:

(c)

Explanation: These are the functions which can be performed on an object.

Q.27. Once a class is declared, we can create and declare variables of this class type, known as

a) final.

b) static.

c) objects.

d) functions.

Answer:

(c)

Explanation: Objects are the basic run-time entities in an object oriented system. It is an instance of class type.

Q.28. There is an Object which is passed by reference, but if you make any changes in the formal parameter, the changes will not be reflected back to the actual parameter. This object is known as

a. primitive data types.

b. array.

c. string.

d. this.

Answer:

(c)

Explanation: The string objects are immutable in java which means when they are created, they cannot be changed. That is why even though strings are passed by reference, the changes made to the formal parameter will not be reflected back in the actual parameter.

Q.29. In java, the composite data type is

a. string.

b. class.

c. primitive data types.

d. array.

Answer:

(b)

Explanation: A class is also known as Composite data type. A class is based on different primitive or fundamental data types and is created by a user.

Example of class as a composite data type:

class Demo {

int a;

float b;

char c;

void getdata() {

: : }

void display() {

: : }}

Q.30. A named unit of group of program statements is called

a. class.

b. object.

c. method.

d. identifier.

Answer:

(c)

Explanation: Method is a named unit in java which consists of a set of program statements for performing a specific task or action.

The syntax of a method is:

Return-type method-name (parameter list)

{

//set of statements

}

Q.31. Region within which a variable or piece of code is accessible is called

a. program.

b. scope.

c. access specifier.

d. class.

Answer:

(b)

Explanation: It defines the extent of information hiding the visibility and accessibility of variables from different parts of the program.

Q.32. The keyword that stores the address of the current object is

a. address of.

b. size of.

c. this.

d. current.k

Answer:

(c)

Explanation: The “this” keyword is used in java to refer to currently calling object in a program. It returns the reference to the current object.

Q.33. Methods reside in

a. data types.

b. objects.

c. scope.

d. class.

Answer:

(d)

Explanation: Class is the single unit which is used to bind data-items and methods together.

The syntax of a class is

Access-Specifier class class-name

{

[Member variables];

[Member functions];

}

Q.34. The first line of method declaration that tells about the type of return value along with number and type of arguments is called

a. called.

b. calling.

c. definition.

d. prototype.

Answer:

(d)

Explanation: Method prototype tells the program about the type of the value returned by the method and the number and type of arguments.

For Example:

int absval(int a)

Q.35. Look at the following code:

void method-name(int x, int y)

{

int a = sum();

}

Here, sum() method is known as

a. calling method.

b. called method.

c. return type method.

d. simple method.

Answer:

(b)

Explanation: A calling method is the method that calls another method and the method being called is the called method. Here, sum() method is called by method-name() method so, it is called “called” method.

Q.36. A constructor that creates objects through values passed to it is called

a. simple constructor.

b. parameterized constructor.

c. default constructor.

d. argument constructor.

Answer:

(b)

Explanation: There are two types of constructor in java: non-parameterized and parameterized.

Parameterized constructor is a constructor that receives parameters.

Q.37. A constructor that does not receive parameters called

a. simple constructor.

b. argument constructor.

c. non - parameterized constructor.

d. parameterized constructor.

Answer:

(c)

Explanation: There are two types of constructor in java: non-parameterized and parameterized.

Non-parameterized constructor does not receive any parameter. It is also known as default constructor because it is automatically called by compiler.

Q.38. A constructor generally declared as

a. public.

b. private.

c. protected.

d. default.

Answer:

(a)

Explanation: A constructor can be define as private as well as protected, but generally we define it as public because its objects can be created in any method.

Q.39. In an application, the prototype of main() method is

a. Public static void main(String args).

b. Public static void main(String[] args).

c. Public void main(String[] args).

d. Private static void main(String[] args).

Answer:

(b)

Explanation: In an application the prototype of a main() method is as follows:

Public static void main(String[] args).

Q.40. A class is created through the keyword called

a. class.

b. create.

c. using.

d. public static void.

Answer:

(a)

Explanation: The syntax of a class is

Access-Specifier class class-name

{

[Member variables];

[Member function];

}

In the above code, class is a keyword.

Q.41. To access an instance member, we need to use dot operator with the

a. object reference.

b. class reference.

c. class name.

d. method name.

Answer:

(a)

Explanation: The instance method is always called using dot (.) operator with the object reference. The syntax of calling an instance method using dot (.) operator is as follow:

Classname obj = new classname();

Obj.method1();

Where obj is the object of classname and method1 is the method of classname.

Q.42. An instance method is defined without the keyword

a. final.

b. public.

c. static.

d. create.

Answer:

(c)

Explanation: An instance method is always defined without the keyword “static”. Static keyword makes a method class method.

Q.43. The class members are that members that are declared with

a. non-static keyword.

b. static keyword.

c. public keyword.

d. private keyword.

Answer:

(b)

Explanation: The static variables and static methods are termed as class variables and class functions respectively in java because static variables and methods are associated with the class itself rather than the individual objects.

Q.44. Static members are called by using

a. fields name.

b. program name.

c. class name.

d. method name.

Answer:

(c)

Explanation: The class methods, i.e., declared with static keyword, are called

<class name> . Method()

For Example -

Lnum() class method is get invoked as

A.Lnum() // A is the name of the class

Q.45. A method returns value through

a. closing braces.

b. return_value statement.

c. return statement.

d. value statement.

Answer:

(c)

Explanation: In java, if a method has to return a value, then we can use “return” statement for that.

It is used as:

return [<variable name>];

CUET Information practice (IP) Chapter 5 GUI Programming and Access Specifier Set-C

Q.46. In java, all primitive data types are

a. passed by value.

b. passed by reference.

c. passed by object.

d. called by reference.

Answer:

(a)

Explanation: All primitive data types are passed by value in a function. Primitive data types are also referred as the fundamental data type.

Q.47. In java, all reference type data are passed by

a. value.

b. parameters.

c. arguments.

d. reference.

Answer:

(d)

Explanation: All reference type data, i.e., strings, array and objects are passed by reference in a function.

Q.48. In a method, String is always passed as

a. public.

b. protected.

c. reference.

d. value.

Answer:

(c)

Explanation: In java, strings are considered as object. So, a String is always passed as reference in a function.

Q.49. Methods not returning a value are declared with

a. no data type.

b. zero value.

c. no-return.

d. void data type.

Answer:

(d)

Explanation: A method that does not return any value will always be declared with void keyword. Void is a data type that refers to the empty set of values.

Q.50. To carry out a specific task, we use

a. methods.

b. variables.

c. class.

d. fields.

Answer:

(a)

Explanation: Methods are prepared to accomplish some specific task. It is the set of statements for some specific action.

Q.51. There is an object named “car” of class “vehicle” with the colour, gears, power, length, width as

a. features.

b. functions.

c. methods.

d. attributes.

Answer:

(d)

Explanation: An object is an instance of class and each object has some attributes.

Q.52. Final keyword is a

a. parameter.

b. method name.

c. modifier.

d. access specifier.

Answer:

(c)

Explanation: Final keyword is a modifier. A final method means that the functionality defined inside this very method can never be changed.

Q.53. In java, the concept of hiding details from public is known as

a. encapsulation.

b. abstraction.

c. overloading.

d. overriding.

Answer:

(b)

Explanation: Abstraction represents the outlook of an object. It hides the details from the public and reduces complexity for the users.

Q.54. The method in which the defined functionality can never be changed is known as

a. static method.

b. class method.

c. final method.

d. instance method.

Answer:

(c)

Explanation: Final keyword is a modifier. A final method means that the functionality defined inside this very method can never be changed.

Q.55. One of the conventions for method-naming is that

a. there should not be a single capital letter at all.

b. start with special character.

c. start with capital letter.

d. start with lower case.

Answer:

(d)

Explanation: The conventions followed for method-naming in java are

Should be meaningful or related with action

Should begin with a lowercase letter

º printReportcard

º getMarks

Should begin with a verb followed by one or more nouns

º readData

º findFile

º calculateInterestAmount

Q.56. Every object is associated with

a. data items and functions.

b. class.

c. data types.

d. modifiers.

Answer:

(b)

Explanation: An object is an instance of a class. So, every object is directly associated with the class.

Q.57. Objects of a class interact by sending

a. variables.

b. messages.

c. calls.

d. definitions.

Answer:

(b)

Explanation: In java, object is an instance of a class. Objects interact with each other using messages. A message can be thought of as a call to an object’s method requesting that it performs some specified action.

Q.58. The data type that specify the empty set of values is

a. ’\u0000’.

b. null.

c. void.

d. return.

Answer:

(c)

Explanation: Void is a data type that specifies the empty set of values.

Q.59. One of the conventions of method-naming is that the method name should always begin with a\an

a. noun.

b. adjective.

c. action.

d. verb.

Answer:

(d)

Explanation: The conventions followed for method–naming in java are

Should be meaningful or related with action

Should begin with a lowercase letter

º printReportcard

º getMarks

Should begin with a verb followed by one or more nouns

º readData

º findFile

º calculateInterestAmount

Q.60. Parameters that you can pass in a method are of

a. one type.

b. two types.

c. null types.

d. void types.

Answer:

(b)

Explanation: A method or function always accepts parameter of two types, i.e., Formal parameter and Actual parameter.

Q.61. int sum(int x, int y)

{

return x + y;

}

In the above code, x and y are

a. data types.

b. actual parameters.

c. formal arguments.

d. formal parameters.

Answer:

(d)

Explanation: In the above code, sum is the defined function. In the definition of a function, the parameters that we pass are always of formal types.

Q.62. Invoking a method means

a. declaring a method.

b. defining a method.

c. prototyping a method.

d. calling a method.

Answer:

(d)

Explanation: In java, invoking a method means calling a method.

Q.63. In the following code,

int a = 20;

int b = 30;

int c = sum(a,b);

a and b are

a. actual parameters.

b. actual arguments.

c. formal parameters.

d. formal arguments.

Answer:

(c)

Explanation : In the called function the passed parameters are known as formal parameters. Here, sum() function is the called function.

Q.64. In “pass by value” mechanism, the values of actual parameter are copied into

a. original parameter.

b. formal parameter.

c. identifier.

d. data type.

Answer:

(b)

Explanation: In “pass by value” mechanism, the values of actual parameters are copied into the formal parameters. Thus, in call by value method, changes are not reflected back to the original values.

Q.65. The parameters that appear in function definition are called

a. original parameter.

b. formal parameter.

c. actual parameter.

d. parameterized.

Answer:

(b)

Explanation: In the following definition of sum method, x and y are formal parameters:

int sum(int x,int y)

{

return x + y;

}

Q.66. In call by value method, changes are not reflected back to the

a. formal arguments.

b. original value.

c. formal value.

d. formal parameter.

Answer:

(b)

Explanation: There are two methods for passing parameters in a function, i.e., call by value and call by reference. In call by value mechanism, the changes are not reflected back to the original value.

Q.67. A reference stores

a. memory location.

b. reference.

c. value.

d. identifier.

Answer:

(a)

Explanation: A reference stores a memory location of a variable.

Q.68. The data that can be accessed only through the member functions of that class is

a) public data.

b) private data.

c) public or private data.

d) protected data.

Answer:

(a)

Explanation: Private data is accessible within a class only.

Q.69. The data that can be accessed by the non–member functions through the objects of that class is

a) protected data.

b) private data.

c) public data

d) local data.

Answer:

(c)

Explanation: Public data is accessible even outside the class.

Q.70. The data members that are usually maintained to store values common to the entire class are

a) non-static members.

b) static data members.

c) initialized members.

d) abstract members.

Answer:

(b)

Explanation: A static data member is globally available for all the objects of that class type. That is why, it is also known as class variables.

Q.71. A method may contain several

a. return statement.

b. main() method.

c. other defined methods.

d. object.

Answer:

(a)

Explanation: A method may contain “several” return statement. However, only one of them gets executed because the execution of the method terminates as soon as a return statement is encountered.

Q.72. The method terminates as soon as the

a. “continue” statement is encountered.

b. “break” statement is encountered.

c. semicolon is encountered.

d. “return” statement is encountered.

Answer:

(d)

Explanation: The method terminates as soon as a return statement is encountered. The return statement is used to return a value to the calling method.

Q.73. In java, we do not need to create the object called

a. this.

b. string.

c. class.

d. array.

Answer:

(a)

Explanation: “This” is the object which is automatically created and initialized by java.

Q.74. To test your grammar, your English teacher purposely writes grammatically incorrect passage on her sheet and gives it to you for corrections. So, you copy down the given passage on your own sheet and make correction there. his situation is analogous to the

a. “call by method” in java.

b. “call by value” in java.

c. “call by method” in java.

d. “call by reference” in java.

Answer:

(b)

Explanation: In java, “call by value” mechanism copies the values of actual parameters into formal parameters. Here, changes are not reflected back to the original value. So in the discussed situation, student copied the passage into his own sheet and made corrections there. So, the correction is not reflected back in the actual sheet. That is why it is same as the “call by value” mechanism.

Q.75. A composite data type is based on

a) object data type.

b) secondary data type.

c) reference data type.

d) primitive data type.

Answer:

(d)

Explanation: Composite data type is that data type which is based on fundamental or primitive data types. In java, class is a composite data type.