0% found this document useful (0 votes)
47 views3 pages

2 Marks Java 2

The document is a model answer sheet for the Summer 2022 Java Programming examination by the Maharashtra State Board of Technical Education. It includes important instructions for examiners on assessing student answers, as well as a series of questions and their corresponding model answers. The document covers various Java programming concepts, including logical operators, functions, interfaces, inbuilt packages, file class methods, and compile-time errors.

Uploaded by

hemrajpache
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)
47 views3 pages

2 Marks Java 2

The document is a model answer sheet for the Summer 2022 Java Programming examination by the Maharashtra State Board of Technical Education. It includes important instructions for examiners on assessing student answers, as well as a series of questions and their corresponding model answers. The document covers various Java programming concepts, including logical operators, functions, interfaces, inbuilt packages, file class methods, and compile-time errors.

Uploaded by

hemrajpache
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

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2022 EXAMINATION


MODEL ANSWER
Subject: Java Programming Subject Code: 22412

Important Instructions to examiners:


1) The answers should be examined by key words and not as word-to-word as given in the
model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try
to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the
figure. The figures drawn by candidate and model answer may vary. The examiner may give
credit for anyequivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed
constant values may vary and there may be some difference in the candidate’s answers and
model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant
answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on
equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi
and Bilingual (English + Marathi) medium is introduced at first year of AICTE diploma
Programme from academic year 2021-2022. Hence if the students in first year (first and
second semesters) write answers in Marathi or bilingual language (English +Marathi), the
Examiner shall consider the same and assess the answer based on matching of concepts
with model answer.

Q. Sub Answer Marking


No Q.N. Scheme
1. Attempt any FIVE of the following: 10
a) Enlist the logical operators in Java. 2M
Ans. && : Logical AND 1M each
|| : Logical OR Any two
! : Logical NOT operators
b) Give the syntax and example for the following functions 2M
i) min ( )
ii) Sqrt ( )
Ans. i) min()
Syntax: (Any one of the following) 1M for
static int min(int x, int y) Returns minimum of x and y each
static long min(long x, long y) Returns minimum of x and y function
static float min(float x, float y) Returns minimum of x and y with
static double min(double x, int y) Returns minimum of x and y example
Page 1 / 26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2022 EXAMINATION


MODEL ANSWER
Subject: Java Programming Subject Code: 22412

Example:
int y= [Link](64,45);
ii)Sqrt()
Syntax:
static double sqrt(double arg) Returns square root of arg.
Example:
double y= [Link](64);
c) Define the interface in Java. 2M
Ans. Interface is similar to a class.
It consist of only abstract methods and final variables. 1M for
To implement an interface a class must define each of the method each point,
declared in the interface. Any two
It is used to achieve fully abstraction and multiple inheritance in points
Java.
d) Enlist any four inbuilt packages in Java. 2M
Ans. [Link] ½ M for
[Link] each
[Link] package
[Link] Any four
[Link] packages
[Link]
e) Explain any two methods of File Class 2M
Ans.1. 1. boolean createNewFile(): It creates a new, empty file named by 1M for
this abstract pathname automatically, if and only if no file with the each
same name exists. method
if([Link]()) Any two
[Link]("A new file is successfully created."); methods

2. 2. String getName(): It returns the name of the file or directory


denoted by the object‟s abstract pathname.
[Link]("File name : " + [Link]());

3. 3. String getParent(): It returns the parent‟s pathname string of the


object‟s abstract pathname or null if the pathname does not name a
parent directory.
[Link]("Parent name : " + [Link]());

Page 2 / 26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2022 EXAMINATION


MODEL ANSWER
Subject: Java Programming Subject Code: 22412

4. 4. boolean isFile(): It returns True if the file denoted by the abstract


pathname is a normal file, and False if it is not a normal file.
[Link]("File size (bytes) : " + [Link]());

5. 5. boolean canRead(): It returns True if the application can read the


file denoted by the abstract pathname, and returns False otherwise.
[Link]("Is file readable : " + [Link]());

6. 6. boolean canWrite(): It returns True if the application can modify


the file denoted by the abstract pathname, and returns False
otherwise.
[Link]("Is file writeable : " + [Link]());

7. 7. boolean canExecute(): It returns True if the application can execute


the file denoted by the abstract pathname, and returns False
otherwise.
[Link]("Is file executable : " + [Link]());

f) Write syntax of elipse. 2M


Ans. Syntax: void fillOval(int top, int left, int width, int height) 2M for
The filled ellipse is drawn within a bounding rectangle whose upper- correct
left corner is specified by top and left and whose width and height are syntax
specified by width and height

OR
Syntax: void drawOval(int top, int left, int width, int height)
The empty ellipse is drawn within a bounding rectangle whose upper-
left corner is specified by top and left and whose width and height are
specified by width and height

g) Enlist any four compile time errors. 2M


Ans. 1)Missing semicolon ½ M for
2)Missing of brackets in classes and methods each error
3)Misspelling of variables and keywords.
4)Missing double quotes in Strings. Any four
5)Use of undeclared variable. can be
6)Incompatible type of assignment/initialization. considered
7)Bad reference to object.

Page 3 / 26

You might also like