Friday, 22 March 2013

how can i use a default package inside another class

Q:- how can i use a default package inside another class?
ANS:- if we make our second class in default package in any other destination then we can use the default package

Friday, 8 March 2013

can we execute a class without main

Q:- can we execute a class without main?
Ans:- The ans is yes as well as no
  yes because before release of final version of jdk 7 we can execute a class having only static block in it
and no because after jdk7 no class can be executed without a main function

Thursday, 28 February 2013

can a return type play role in function overloding in java

Q:-can a return type play role in function overloding in java
ANS:- no because in java our jvm not checks the return type it only checks the function name and arguments

A int And boolean type is incaptible in java

we know that java take all its syntax from c but in c this program works but not in java
class Demo
{
  
  public static void main(String... S)
   {
     boolean x=1;
     while(x)
     {
      
       System.out.println("program is correct");
      }
      System.out.println("not good");
    }
}


this will give compilation error and said int are not campatble with boolean in java why?

diffrence b/w class and object

Difference between Class and object in Java

In Java,  Class is a blue print used to create objects. In other words, a Class is a template that defines the methods (Functions) and Members (variables) to be included in a particular kind of Object.
Here, “Student” is a class. And “Jenna” is an object of the class “Student”. And “John” is another object of the class “Student”. A Class is a template for an object, a user-defined datatype that contains the variables and methods in it.
A class defines the abstract characteristics of a thing (object), including its characteristics (its attributes, fields or properties) and the thing’s behaviors (the things it can do, or methods, operations or features). That is, Class is a blue print used to create objects. In other words, each object is an instance of a class. One class can have multiple number of instances. (There can be Number of instances of the class “Student”, like “Jenna”, “John” etc).
A class is a predefined frame of an object, in which its mentioning what all variables and methods an object (object of that class) can have.

Wednesday, 20 February 2013

can we have more then one classes in one java file

Answer is yes reason is because the jvm tool present in java makes the separate .class file for each class in which main is present after the compilation process and we can run each class separately

how to run a c program written in notepad in command prompt

step 1
write your c program in notepad file and save it with .c extension 
step 2
open command prompt and set path by set path="your Tcc folder path"
step 3
set the path of file by the command cd file path
step 4
now by the command tcc filename.c your program will compile 
step 5 
by writing the program name you can execute your program

how to run a c program written in notepad in visual studio

step 1
write your c program in notepad and save it with .c extension
step 2
go to start menu click on microsoft visual studio then open the visual studio tools and then click on the visual studio command prompt
step 3
now set the path where your file is on your computer with cd path command
step 4
now write the cl file name in the command prompt it will create the filename.exe file in given folder by compiling it
step 5
double click on the filename.exe file and you will see your program output