The document contains a Java programming assignment with multiple questions:
1. It asks for differences between pure and impure functions, call by value and call by reference, and the use of the new operator. It also asks for two types of access specifiers and what static data members and static methods are.
2. It asks about encapsulation in Java, the this keyword, and how to implement encapsulation.
3. It asks to fill in the blanks with terms like class, static, wrapper.
4. It gives two code snippets and asks for the output and number of iterations of loops. It also asks about instance and static variables.
5. The final question defines a Movie class
The document contains a Java programming assignment with multiple questions:
1. It asks for differences between pure and impure functions, call by value and call by reference, and the use of the new operator. It also asks for two types of access specifiers and what static data members and static methods are.
2. It asks about encapsulation in Java, the this keyword, and how to implement encapsulation.
3. It asks to fill in the blanks with terms like class, static, wrapper.
4. It gives two code snippets and asks for the output and number of iterations of loops. It also asks about instance and static variables.
5. The final question defines a Movie class
The document contains a Java programming assignment with multiple questions:
1. It asks for differences between pure and impure functions, call by value and call by reference, and the use of the new operator. It also asks for two types of access specifiers and what static data members and static methods are.
2. It asks about encapsulation in Java, the this keyword, and how to implement encapsulation.
3. It asks to fill in the blanks with terms like class, static, wrapper.
4. It gives two code snippets and asks for the output and number of iterations of loops. It also asks about instance and static variables.
5. The final question defines a Movie class
The document contains a Java programming assignment with multiple questions:
1. It asks for differences between pure and impure functions, call by value and call by reference, and the use of the new operator. It also asks for two types of access specifiers and what static data members and static methods are.
2. It asks about encapsulation in Java, the this keyword, and how to implement encapsulation.
3. It asks to fill in the blanks with terms like class, static, wrapper.
4. It gives two code snippets and asks for the output and number of iterations of loops. It also asks about instance and static variables.
5. The final question defines a Movie class
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 2
Batch-Java 2019(CA)
Time:-1 hrs.. Marks= R E F L E X E S
Attempt all questions.
Question 1 *1 a) Write any two difference between pure and impure functions?. b) What is the difference between call by value and call by reference? c) Write down the use of new operator? d) Name any two types of access specifiers with its definition? e)what is static data members and static member methods? Question 2*1 a) What is encapsulation and how is it useful in java ? b) What is this keyword? c) How do we implement encapsulation in java? ?
3.Fill in the blanks *1
1. A class containing the main method is called……………………. 2. ………………………..members are accessible from anywhere in the class 3. Data types based on primitive data types are called………………………….data type? 4. …………………………..are variable declared within a class 5. Static binding………………………………………………………………….. 6. Method in a java program resides in……………………………………. 7. A nested function is………………………………………………………………….
4.(A) Give output of the following method: [2]
public static void main(String[] args) {
int a = 5; a++; System.out.println(a); a – = (a – –) – (- – a); System.out.println(a); }
(B) public void sampleMethod()
{ for( int i=0; i<3; i++ ) { for( int j=0; j<2; j++) { int number = (int)(Math.random() * 10); System.out.println(number); } } } (i) How many times does the loop execute? (ii) What is the range of possible values stored in the variable number? (C) Consider the following class: [2] public class myClass { public static int x = 3, y = 4; public int a = 2, b = 3; } (i) Name the variables for which each object of the class will have its own distinct copy. (ii) Name the variables that are common to all objects of the class. Question 4. 15 marks Define a class named movieMagic with the following description: Instance variables/data members: int year – to store the year of release of a movie String title – to store the title of the movie. float rating – to store the popularity rating of the movie. (minimum rating = 0.0 and maximum rating = 5.0) Member Methods: (i) movieMagic() Default constructor to initialize numeric data members to 0 and String data member to “”. (ii) void accept() To input and store year, title and rating. (iii) void display() To display the title of a movie and a message based on the rating as per the table below. Rating Message to be displayed 0.0 to 2.0 Flop 2.1 to 3.4 Semi-hit 3.5 to 4.5 Hit 4.6 to 5.0 Super Hit
Write a main method to create an object of the class and call the above member methods.