Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Amit
questions
1 Answer(s)      3 years and 9 months ago
Posted in : Java Beginners






Q. 1 programes on if....else 1. write a program to check whether entered year is leap year or not 2. write a program to check whether entered no. ends with 5 or not 3. write a program to find minimum of 3 nos using nested if else. 4. write a program to check whether entered no. is divisible by 5 or 7 or both 5. write a program to input score of a student out of 100 and print grades using else .... if ladder





Q. 2 programes on switch 1. write a program to design menu driven arithmetic calculator 2. write a program to print no of days in a given month





Q. 3 programes on while loop 1. write a program to calculate sum of an entered digit 2. write a program to find gcd and lcm of 2 positive integers





Q. 4 programes on do... while 1. write a program to print reverse of a given digit 2. write a program to check whether entered digit is palindrome or not 3. write a program to check whether entered no. is Armstrong or not





Q. 5 programes on for loop a. write a program to find squares and cubes of 1st 10 integers b. write a program to to calculate factorial of a no. c. write a program to print Fibonacci series d. write a program to check whether entered no is prime or not e. write a program to print given pattern * * * * * * * * * * * * *





Q. 6 programes on array a. write a program to find max and min element in an array of an integer b. write a program to convert decimal no. to binary and back to decimal. c. write a program to do following:- i) addition of two matrices ii) subtraction of two matrices iii) multiplication of two matrices iv) find transpose of an matrix





Q. 7 programes on strings a. write a program to copy one array to another array using System.arrayCopy() method. b. write a program to check whether entered string is palindrome or not





Q. 8 programes on methods 1. write a program to implement bubble sort 2. write a program to demonstrate call by value and call by reference.(pass objects as parameters) 3. write a program to calculate factorial of a no. using recursive function 4. write a program to concatenate two strings entered by user 5. design a class called cricket to store information of players. Read information of 50 players and display information w.r.t. batting

average.





Q. 9 write a program to store information of 50 products(code, quantity and price). Calculate the total cost (quantity*price) of each product

and print the information.





Q. 10 write a program to calculate volume of a cube, cylinder, rectangular box using method overloading





Q. 11 WAP to demonstrate a) static data members b) static methods

In our java programming language we have 2 types of variables those are static variables and instance variables.In the same way we have 2 types

of methods those are instance methods and static methods.

Methods and Variables in Java

In our java programming language we have 2 types of variables those are static variables and instance variables. In the same way we have 2

types of methods those are instance methods and static methods. Instance variables and methods do not preceded by the static keyword where as

static variables methods followed by the keyword static.

Instance variables

Instance data members are those whose memory space is creating each and every time when we create an object. If any data member is taking a

specific value then that data member is recommended make as instance data member that means any data member is created in a class it will

belongs to only those objects. Programmatic instance data members declaration should not followed by a keyword static.

Main points

1.Each and every instance data member must be accessed with respect to object. 2.the value of instance data member is not sharable. 3.Instance data members are also known as object level members since they depend on object name but independent from class name.

Static Data Members :

Static data members are those whose memory space is creating only once when ever the class is loaded in main memory irrespective of number of

objects are created. If any data member is taking a specific value then that data member common value for many numbers of objects then that

data member is recommended make as static variable. Programmatic static variables declaration must be preceded by a keyword static.

Main points

  1. All static data members accessed with respect to class name.
  2. the value static data member is always sharable.
  3. Static members also known as class level data member since they depend on class and independent from object.

Instance Methods

Instance methods are those which perform repeated operation such as such as reading the data form file, reading the data from data base and

etc. Programmatic if we want make any method as instance method that method can not preceded by the keyword static.

Syntax for Instance method

Return-type method-name(list of parameters if any){

// Block of statements;

}

Main points

  1. Instance methods in java must be accessed with respect to object name. Ex. object-name.sum(); 2.Instance methods are also known as object level method since they depend on object name since they depend on the object name and independent

from the class name.

Static methods

Static methods are those which are recommended to perform one time operations such as opening a file either in read or write mode, opening the

data base connection, verification of user name and password and etc. programmatic if we want make any method as static then the definition of

such method must be preceded by keyword static

Syntax for the Static method

static Return-type Method-name(list of parameters if any){

//Block of statements.

}

Main points

1.All static members in java must be accessed with respect to class name. Syntax: class-name.static-method-name();

Example: Integer.parseInt("100");

2.The result of static method is always sharable. static methods are also known as class-level methods since they depend on class.

eg

// Demonstrate static variables, methods, and blocks.
class UseStatic {
static int a = 3;
static int b;
static void meth(int x) {
System.out.println("x = " + x);
System.out.println("a = " + a);
System.out.println("b = " + b);
}
static {
System.out.println("Static block initialized.");
b = a * 4;
}
public static void main(String args[]) {
meth(42);
}
}
class StaticDemo {
static int a = 42;
static int b = 99;
static void callme() {
System.out.println("a = " + a);
}
}
class StaticByName {
public static void main(String args[]) {
StaticDemo.callme();
System.out.println("b = " + StaticDemo.b);
}
}
Here is the output of this program:
a = 42
b = 99





Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java





Q. 13 WAP to demonstrate multiple inheritance using interfaces

ANS.......

/* Area Of Rectangle and Triangle using Interface * /

interface Area { float compute(float x, float y); }

class Rectangle implements Area { public float compute(float x, float y) { return(x * y); } }

class Triangle implements Area { public float compute(float x,float y) { return(x * y/2); } }

class InterfaceArea { public static void main(String args[]) { Rectangle rect = new Rectangle(); Triangle tri = new Triangle(); Area area; area = rect; System.out.println("Area Of Rectangle = "+ area.compute(1,2));

area = tri; System.out.println("Area Of Triangle = "+ area.compute(10,2)); } } /* OUTPUT *

Area Of Rectangle = 2.0 Area Of Triangle = 10.0 */


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Java - Java Interview Questions
Java  Questions on Java
servlet questions
servlet questions  pls send servlet interview questions to anvesh2406@gmail.com
Advertisements
beginners questions
beginners questions  I need all the possible Java beginners questions to prepare for an Interview
interview questions - Java Interview Questions
interview questions for Java  Hi Any one can u please post the interview point of questions.Warm Regards, Satish
java questions - Java Interview Questions
java questions  HI ALL , how are all of u?? Plz send me the paths of java core questions and answers pdfs or interview questions pdfs or ebooks :) please favor me best books of interviews questions for craking
java - Java Interview Questions
Helpful Java Interview questions   Need Helpful Java Interview questions
javascript questions on date
javascript questions on date  how to add some days to an existing date
Hi - Hibernate Interview Questions
Hi   please send me hibernate interview questions
interview - Java Interview Questions
interview  kindly guide me some interview questions of Java
JAVA QUESTIONS - Java Beginners
java questions asked in interview oracle  Hi all, Does anyone have a list of Java questions that is generally asked in Interview at Oracle
Hibernate - Hibernate Interview Questions
hibernate interview questions and answers  Hi, Can anyone give me the best reference of hibernate interview questions and answers?Thanks in advance
programming questions
programming questions  this is my assignment questions please help me... the programs in c# language Describe the following with respect to creating Web Forms in .Net environment: a. Web Form Life Cycle b. Creating a Web Form
Questions about Java's String pool
Questions about Java's String pool  Questions about Java's String pool
help me - Java Interview Questions
interview questions java pdf   Do you have any PDF for Java Interview questions
multiple choice questions program
multiple choice questions program  how can i implement the program to store 10 multiple choice questions in one class to develop a oneline quiz with using java language
multiple choice questions program
multiple choice questions program  how can i implement the program to store 10 multiple choice questions in one class to develop a oneline quiz with using java language
About interview questions
About interview questions   I want interview questions on IDE's Please send links
Java Interview Questions
Java Interview Questions  Hi, Can anyone tell the urls of Java Interview Questions on roseindia.net? Thanks
Example questions of JSP & Servlet
Example questions of JSP & Servlet  Give me some JSP & Servlet Question and their answers
intervw questions for an Android
intervw questions for an Android  Hi Friends, plz send me some important Q&A for an android interview
Struts - Java Interview Questions
Struts Interview Questions  I need Java Struts Interview Questions and examples
jvm - Java Interview Questions
jvm  Can you provide some JVM Questions for Java Interview preparation
 

 

 

DMCA.com