Q 1 - Which of the following is true about super class? A - Variables, methods a
ID: 3606061 • Letter: Q
Question
Q 1 - Which of the following is true about super class?
A - Variables, methods and constructors which are declared private can be accessed only by the members of the super class.
B - Variables, methods and constructors which are declared protected can be accessed by any subclass of the super class.
C - Variables, methods and constructors which are declared public in the superclass can be accessed by any class.
D - All of the above.
Answer:
Q 2 - What is function overloading?
A - Methods with same name but different parameters.
B - Methods with same name but different return types.
C - Methods with same name, same parameter types but different parameter names.
D - None of the above.
Answer:
Q3 – if s =”text”, what is the value returned by s.length ()?
A – False
B – True
C – 4
D – 5
Answer:
Q4 – A Compound statement is:
A collection of one or more statements enclosed in braces.
A Statement involving if and else
A way of declaring variables
A way of setting the value of a variable
Answer:
Q5 – What is the value stored in result after executing the following line in a program?
result = 9/3 * 5;
10
15
9
Wrong
Answer:
Q6 - Who invented Java?
Netscape
Microsoft
Sun
None of the above
Answer:
Explanation / Answer
Hi,
It is not encouraged to ask multiple questions as one, since these are small enough i am going to answer them here, please refrain from doing so in future
1. Super class is a class from which there will be sub classes, this forms the basis of Inheritance in Object Oriented Programming
now, they have the following properties
access specifier private means only members of super class can access them
access specifier protiected means only members of super class and derived subclasses can access them
access specifier public means ALL members of ALL classses can access them
therefore it is option D
2.Function overloading in OOP refer to defining functions with same name but different parameters
ex: fun(int a) and fun(double a)- here fun is overloaded
lets look at other options too
B- Methods with same name but different return types, this is also overloading but unfortunately not possible in java
C- Methods with same name, same parameter types but different parameter names- parameter names wont matterm as they will be treated as same function
3.s.length() returns the length of the string, hence its 4
4.A compound statement in java are group of statements enclosed in braces
B- is wrong becuase thats decision statement
C,D are wrong becuase they are declaration and assignment statements
5.first division is executed as per BODMAS rule, hence it will be 9/3 * 5 which is 15
6.Java was invented by Sun Microsystems
Thumbs up if this was helpful, otherwise let me know in comments
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.