JavaBasics Practice Question and Answers

  Java Practice Question and Answers

 

  



 

Java Variables and Data types

Find the Answers for the following Questions

  1. What is Literal? In Java.
  2. What data you have always written in double quotes ("").
  3. Class name should start with _______.
  4. Why to use variables.
  5. What  datatype you used to store text data in java.
  6. To store integers, what datatype you use?
  7. What is the use of ++.
  8. What is the default method in java ?give the name.
  9. Difference between char and String?
  10. How to convert one data type to another in Java?
  11. How to store character data in a variable in java, give an example?
  12. How to declare float value, give an example?
  13. How many types of scopes available for variables?
  14. What are Escape sequence characters, give 2 examples.
  15. What symbols you can use in a variable name.
  16. What is the maximum length of the variable name.
  17. How do you comment multiple lines in Java?

 

Java Methods

  1. What is method? Where it is created.
  2. Types of methods in java
  3. How many types of user defined methods
  4. Write an example of predefined method
  5. What is method signature
  6. What is void will do in java method.
  7. What is method overloading in java
  8. Difference between static method and instance method
  9. How to call static method
  10. Where static variable, methods are stored in Java?

 Java Classes with Answers

What is class
    class, is a template for an object

What are members of the class
     - properties
     - methods
     - constructors
     - blocks
     - inner classes.

What is an object
     - object is a copy/blue print of a class. It holds the data.
Why we use methods in class
     - methods used to operate on object data.

What is the use of object

     - To store data of an entity.

What is instantiating

     - creating an object
Which operator used to create an object.
     - new operator
What object reference, how to do you create it.
     - It points to an object. Using Class, object reference is created.
       Ex. Student s1;
In which  memory, object is created.

     - heap memory 
What are instance or object variables
     - by defautl all variable declared in class are belongs to object/instance.

What are class variables how you create them

     - class variables stored in class itself. They created using static keyword.
 
How to set data to properties of an object

      using set methods
          ex. setName("John");

How to display data an of object
     - using methods
     - ex. getName()

What are the different ways to set data to an object.
     - using method
     - using constructor.

Types of Methods in java

coding-zon-java-types-of-methods


 

 Types of Constructors in java

 

coding-zon-Java-types-of-constructors

 

What is this keyword
    - this is reference to an object.

What is method overloading in class

     - Same method name with different parameter-lists and different return type. Overloading occurs in the same class.

What are access modifiers

     - controls the accessibility of the members in a class.
    ex. public, private, protected, default
 

How many types of access modifiers 

    1. Access modifiers - ex. public,private,protected,default

      2. Non access modifiers - static, final, abstract, transient, volatile etc.



coding-zon-java-types-of-access-modifiers

 

Java Inheritance

What is Inheritance?
Creating a new class (derived class) from an existing class (base class).

Which keyword used to extend from one class to another

-- super keyword

Where 'super' keyword is used?


--Used to invoke parent class constructor from the child class.
 

What is method overriding

-- redefining  parent class method in child class


how to do you implement multiple inheritance in java?

-- using interfaces

Interface start with --------- keyword


-- interface

Interface contains only method -------------------

-- declarations.

What keyword is used, to implement interface by child class


-- implements


All the interface method declarations must be a ---------


-- public

What is the rule while implementing interface by child class


-- All the methods must be implemented by child class.

What is abstract class


--partially implemented class is known as abstract class.

Which class cannot create an object

-- abstract class

what is Concrete class


-- fully implemented class

Comments

Popular posts from this blog

Using javascript pass form variables to iframe src

Creating a new PDF by Merging PDF documents using TCPDF

Import excel file into mysql in PHP