Java- A cup of Coffee


Multiple Choice Questions

1     1. What dose the Java compiler translate the java program into?
a.            Byte Code                          b.            Hill  
c.             Code                                  d.            Source Code
2     2. Command javac is used for?
a.            Interpretation                      b.            Compilation
c.             Running                             d.            Execution
3     3. Which one of the following is used to create a new class based on an existing class?
a.                   Polymorphism                   b.            Inheritance
c.            Encapsulation                     d.            Class
4     4. What is the extension of saved Java file ?
a.                   .java                                  b.            .doc
c.             .png                                   d.            .jpeg                     
5     5. Which one of the following is used to create a new class based on an existing class?
a.            Class                                 b.            Data  Abstraction
c.             Encapsulation                   d.            Polymorphism

Fill in the Blanks :-

11.  Java is an example of oops programming.
22.  An object is an instance of class.
33.  The objects interact with each other by sending messages.
44.  The main() method shows from where the program will start running.

55.  The existing class in inheritance is known as base class

Subjective Qustions :-

Qus.: List of Advantages of OOPs.
Ans:
(1) Elimination of redundant coding system and usage of existing classes through inheritance.
(2) Program can be developed by sharing existing modules.
(3) Possibilities of multiple instance of an objects without any interference.
(4) Security of data values from other segment of the program through data hiding.

Qus. – Distinguish between data abstraction and data encapsulation.

BASIS FOR COMPARISON
ABSTRACTION
ENCAPSULATION
Basic
Shows, what elements are necessary to build a system.
Hides the complexity of a system.
Application
During 'design level'.
During 'Implementation level'.
Focus-1
Focus is on "what" should be done
Focus is on "how" it should be done.
Achieved
Achieved through encapsulation.
Achieved through making the members of a class as 'private'.
Focus-2
Implementation hiding.
Information hiding.
Example
The GUI of a mobile phone, it has some icons to click on, which on click perform the specific function.
After the icon is clicked, the end user has no idea regarding its implementation details


Qus.- What is JRE.
Ans. :- JRE stands for “Java Runtime Environment”. It consists of all the programs and files required to run application in the Java programming language. The Software JRE consists of JVM(Java Virtual Machine) and the Java class libraries.

Qus.-  Describe the feature of the Java programming language ?
Ans. :- Basic features of Java programming language as follows:
i) It is an object oriented language.
ii) Java program is both compiled and interpreted.
iii) Java program can be application or applet.
iv) Java is case sensitive language, i.e. it distinguished upper and lower case letters.

Qus.-  What is the main() method of Java ?
Ans. :- main() is the method of java from where a program execution begins. This method is called when we execute the program. In the main method, we can create an object of the defined class and have an access to the member method by using the dot(.) operator. The beginning and ending of the main method is done by using‘{‘ and ‘}’respectively.

Lab Question :

Qus. : Write a program to print ‘life is awesome’.
Solution :-
class Print
            {
            public static void main(String args[])
                        {
System.out.println(“life is awesome”);
                        }
            }

Qus. : Identify the output of the following program.
class Lab
{
public static void main(String[] args)
                        {
                        System.out.println(“Hello how do you do”);
                        }
}
Solution :-
output :-          Hello how do you do

Qus. – Identify the errors in the given program :
  1. class Demo
  2.             {
  3.             main(String[] args)
  4.                         {
  5.                         System.println(“all izz well”)
  6.                         }
  7.             }
Solution :
-          At line number 3 “public static void” is missing before main word.
-          At line number 5 “out” is missing after System word.
-          At line number 5 “;” is missing at the end of the line.

0 comments:

Post a Comment